Bound
a simple way do a large amount of event bindings. Heavily inspired by backbones event bindings in views.
To Install
$ npm install node-bound
This also works with browserify.
Example Usage
Lets say you have a controller, that you want to consume some events from a common messaging system that uses events.
var emitter = new EventEmitter // new EventEmitter() bound = ; { ;} UserControllerprototype { console; // [ Object UserController ] };UserControllerprototype { /* ... */ };UserControllerprototype { /* ... */ };
This will bind all the events in the given context to the right method and keep the context that is given, which is great when in the context of a constructor.
;// eventEmitter ^ event : method ^ ^ context of method
There is also a bunch of aliases: bound.on
, bound.bind
, bound.addEventListener
, bound.addListener
You can also unbind events that get bound by bound
.
bound;
Unbinding also has aliases: bound.off
, bound.unbind
, bound.removeEventListener
, bound.removeListener
Contributing
To contribute you will need to make sure all the test are passing. To run the test you will need mocha. Then install the dependecies.
$ npm install
Then to run the test
$ npm test