This provides the use of service iteration and usage is like below:
* API:
setServiceInterval(function, after, repeat);
* Parameters:
{func} The function |func| will run.
{repeat} The number of iteration is |repeat|.
The value 0 means infinite and default.
{after} The iteration interval is |after| ms and default is 1000 ms.
Change-Id: I5e50ddf9c11f6b7a49cf48aa4c526698c044794f
Signed-off-by: Youngsoo Choi <kenshin.choi@samsung.com>
this.timer_api.setTimeout = function(func, delay) {
_this.timeout_handlers.push(setTimeout(func, delay));
}
+ this.timer_api.setServiceInterval = function(func, after = 1000, repeat = 0) {
+ if (typeof func !== "function") {
+ console.log("Use function as the first parameter.");
+ return;
+ }
+ let count = 1;
+ let handler = this.timer_api.setInterval(function() {
+ func();
+ count++;
+ if (count > repeat && repeat !== 0) {
+ this.timer_api.clearInterval(handler);
+ }
+ }.bind(this), after);
+ }.bind(this);
}
getTimerAPI() {
return this.timer_api;
for(let key in global) {
_this.sandbox[app_id][key] = global[key];
}
- _this.sandbox[app_id]['timer_manager'] = new TimerManager();
- const timer_api = _this.sandbox[app_id]['timer_manager'].getTimerAPI();
+ _this.sandbox[app_id].timer_manager = new TimerManager();
+ const timer_api = _this.sandbox[app_id].timer_manager.getTimerAPI();
for(let key in timer_api) {
_this.sandbox[app_id][key] = timer_api[key];
}