hij1nx/EventEmitter2 — pull request #60 by JerrySievert (2012-07-01 01:37:22+00:00)
Title: add idle() method

adds idle() method to ee2 - sets a timer, if an event has not been fired by the time the timer runs out then the callback is fired with the event and the arguments:

emitter.idle(event, timeout, callback, [arg1], [arg2], [...])

each time the event is emitted, the idle timer is reset. if the idle timeout occurs and the callback is fired, the idle timeout is canceled (no further timeouts until idle() is reset).

emitter.idle('hello', 100, function (event, arg1, arg2) {
console.log(event); // 'hello'
console.log(arg1); // 'foo'
console.log(arg2); // 'bar'
}, 'foo', 'bar');