async-emitter

Non-blocking event emitter

npm install async-emitter
19 downloads in the last week
37 downloads in the last month

Emitter build status NPM version

A non-blocking event emitter. Non-blocking as in "if I call emitter.emit(), the emission of events to their handlers won't block".

Given the nature of "events", one would think event emission is always asynchronous. Looking at most implementations; that's not the case. This fixes it by running each handler with setTimeout/nextTick.

Install with npm

$ npm install async-emitter

Install with bower

$ bower install emitter

API

Class Properties

  • function Emitter.nextTick

  • boolean Emitter.warn

Instance Methods

  • {Emitter} emitter.on( string event, function|object handler )

  • {Emitter} emitter.once( string event, function|object handler )

  • {Boolean} emitter.emit( string event, [arg1], [arg2], [...] )

  • {Boolean} emitter.emitSync( string event, [arg1], [arg2], [...] )

  • {Emitter} emitter.removeListener( string event, function|object handler )

  • {Emitter} emitter.removeAllListeners( string [event] )

  • {Emitter} emitter.setMaxListeners( number value )

  • {Array} emitter.listeners( string event )

npm loves you