forked from GitHub/dbot
Fixes for [#232]
This commit is contained in:
parent
bd75519047
commit
27e24a8173
@ -18,23 +18,31 @@ var timers = function(dbot) {
|
|||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
console.log('Running first timer at ' + new Date().toUTCString());
|
console.log('Running first timer at ' + new Date().toUTCString());
|
||||||
this.runningIntervals.push(this.api.addTimer(timeout, callback));
|
this.runningIntervals.push(this.api.addTimer(timeout, callback));
|
||||||
callback();
|
try {
|
||||||
|
callback();
|
||||||
|
} catch(err) {
|
||||||
|
console.log('Callback failed: ' + err);
|
||||||
|
}
|
||||||
}.bind(this), firstTimeout);
|
}.bind(this), firstTimeout);
|
||||||
} else {
|
} else {
|
||||||
this.runningIntervals.push(setInterval(function() {
|
this.runningIntervals.push(setInterval(function() {
|
||||||
console.log('Running subsequent timer at ' + new Date().toUTCString());
|
console.log('Running subsequent timer at ' + new Date().toUTCString());
|
||||||
callback();
|
try {
|
||||||
|
callback();
|
||||||
|
} catch(err) {
|
||||||
|
console.log('Callback failed: ' + err);
|
||||||
|
}
|
||||||
}.bind(this), timeout));
|
}.bind(this), timeout));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.onDestroy = function() {
|
this.onDestroy = function() {
|
||||||
for(var i=0;i<this.runningTimeouts;i++) {
|
for(var i=0;i<this.runningTimeouts.length;i++) {
|
||||||
clearTimeout(this.runningTimeouts[i]);
|
clearTimeout(this.runningTimeouts[i]);
|
||||||
}
|
}
|
||||||
for(i=0;i<this.runningIntervals;i++) {
|
for(i=0;i<this.runningIntervals.length;i++) {
|
||||||
clearTimer(this.runningIntervals[i]);
|
clearInterval(this.runningIntervals[i]);
|
||||||
}
|
}
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user