urban-emitter
v2.0.2
Published
Simple implementation of an event emitter.
Downloads
18
Maintainers
Readme
Urban-Emitter
This is a simple event emitter implementation.
Installation:
Node.js, browserify, and webpack users can install via npm:
npm install --save-dev urban-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 UrbanEmitter = require('urban-emitter');
var emitter = new UrbanEmitter();
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();