ngraph.events
Small and powerful eventing in node and browser
Example
var eventify = require('ngraph.events');
var yourObject = {};
eventify(yourObject);
yourObject.on('beep', function(name) { console.log('Hello ' + name); });
yourObject.fire('beep', 'World!');
yourObject.off('beep');
More advanced examples:
var eventify = require('ngraph.events');
var yourObject = eventify({});
yourObject.on('beep', function () { console.log(this === yourObject); }, yourObject);
yourObject.fire('beep');
var onBop = function (x, y) { console.log(x + y); };
yourObject.on('bop', onBop);
yourObject.fire('bop', 40, 2);
yourObject.off('bop', onBop);
yourObject.off();
Why?
This module is a part of larger experiment which I'm currently working on. EventEmitter
seemed to be pretty heavyweighted for my needs, so I rolled out this tiny library :).
install
With npm do:
npm install ngraph.events
License
BSD 3-Clause