airship-emitter
v2.0.0
Published
Simple implementation of an event emitter.
Downloads
11
Maintainers
Readme
Airship-Emitter
This is a simple event emitter implementation.
Installation:
Node.js, browserify, and webpack users can install via npm:
npm install --save-dev airship-emitter
Available at github and npm repository.
Testing:
npm test
Documentation:
JSDoc documentation is housed in the doc folder.
Usage:
// Create an event emitter
var EventEmitter = require('airship-emitter');
var emitter = new EventEmitter();
var fxn = function(element) {
// Do something awesome...
}
// Adds a handler that can be invoked more than once
emitter.add('onclick', fxn);
// Adds a handler that is invoked only once
emitter.once('onchange', fxn);
// Invokes all handlers for the event passing them all other arguments
emitter.emit('onclick', args);
// Removes/clears the handlers
emitter.remove('onclick', fxn);
emitter.clear();