diff --git a/lib/index.js b/lib/index.js index eb3e98b..71d1e4c 100644 --- a/lib/index.js +++ b/lib/index.js @@ -99,6 +99,15 @@ function Reissue(opts) { * @type {Function} */ self._nextHandlerId = null; + + /** + * boolean flag set when we are waiting for user supplied function to + * complete. technically we should know this if self._nextHandlerId had + * a flag to show whether or not it had already been executed, but this is + * a safer way to do it. + * @type {Boolean} + */ + self._inUserFunc = false; } util.inherits(Reissue, events.EventEmitter); @@ -220,7 +229,7 @@ Reissue.prototype.start = function start(delay) { self._active = true; if (typeof delay === 'number') { - setTimeout(function _nextInvocation() { + self._nextHandlerId = setTimeout(function _nextInvocation() { self._execute(); }, delay); } else {