voke
v1.0.2
Published
event emitter
Downloads
2
Readme
Voke
Event emitter
Created as a learning project.
Installation
With NPM
npm install voke
index.js
var Voke = require('voke');
In the Browser:
Download dist/voke.min.js
first.
<script src='voke.min.js'></script>
Usage
Creating an emitter:
var emitter = new Voke();
Adding event listeners:
emitter.on('event', function(e) {
console.log(e);
// {type: 'event', myCustomData: true}
});
var handler = function() {};
emitter.on('event2', handler);
Removing event listeners:
emitter.off('event2', handler);
Global Event Listener:
emitter.on('*', function(e) {
// gets event object from all events
console.log(e);
});
Emitting an event:
emitter.emit('event');
emitter.emit('event', {myCustomData: true});
License
Licensed under the MIT License by Kabir Shah