add idle() method #60

wants to merge 1 commit into


None yet

4 participants


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');
Marak commented Jul 1, 2012

Neat idea.

What are you using this for?


i use it for monitoring whether devices have checked in - if a device hasn't emitted an event within the specified time period then a callback is executed so notification occurs.

this code has been accepted in eventreactor (which i have been making liberal use of), but i find myself needing some of the functionality from eventemitter2 as well. since there seem to be some philosophical differences that won't let the two libraries work together, i figured that this was the path of least resistance.

0x00A commented Aug 24, 2012

Can you add this to the file? After that I will merge it.


which part would you like added to the readme? whatever you need, i can add.



@JerrySievert The latest observing/eventreactor now also work with EventEmitter2;


@3rd-Eden, @hij1nx awesome. closing this then. keep up the good work, gentlemen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment