An asynchronous event emitter for node.js and the browser. Heavily inspired by component/emitter.
component install matthewmueller/aemitter
npm install aemitter
var Emitter = ;var user = name: 'matt' ;;user;user;
fn. The signature of
fn will be all the arguments emitted + the
next(err) function. If this function is not specified,
Emitter#on will immediately return.
It's important to note that
next will be passed as the last argument. If
Emitter#emit passes four arguments,
next will be it's fifth.
Register a single-shot
removed immediately after it is invoked the
fn, or pass only the
name to remove all handlers for
event with variable option args, and a final, optional callback
fn will be called when all the event callbacks have finished.
Caveat: You will need to be consistent with the
emit signature, otherwise
Emitter#on() callbacks will be inconsistent and likely fail. For example:
user; // main signatureuser; // will NOT work as expecteduser; // will work as expecteduser; // will also work as expected
Return an array of callbacks, or an empty array.
Check if this emitter has
npm install . mocha test