Evmit
A tiny, modern, bare bones event emitter for Node.js and the browser. For the latter it supports Internet Explorer 9+ and works with Browserify or as a standalone library.
Installation
npm
npm install evmit --save
Bower
bower install evmit --save
Usage
Initialization
Node.js and Browserify
var Evmit =var emitter =
Standalone
var emitter =
Evmit.on(name, fn)
Subscribe to an event.
name
is the name of the event.fn
is the function that gets called when the event is emitted.
emitteremitter
Evmit.once(name, fn)
Subscribe to an event only once.
name
is the name of the event.fn
is the function that gets called when the event is emitted.
emitteremitter
Evmit.emit(name[, ...])
Trigger an event.
name
is the name of the event....
is the arguments that gets passed to the event.
emitteremitter
Evmit.off([name, fn])
Unsubscribe from an event or all events.
name
is the name of the event.fn
is a specific function that's bound to the event.
If name
is not provided it'll unsubscribe from all events.
emitteremitteremitter
Evmit.listeners([name])
Return all events or a single event.
name
is the name of the event.
emitter// => { foo: [...], bar: [...] }emitter// => [...]