ms-eventjs
v2.0.1
Published
Library to manage events
Downloads
16
Maintainers
Readme
eventjs
eventjs will help you to manage you custom javascript events.
Setup
npm
This package is published through npm under the name ms-eventjs
npm install ms-eventjsbower
This package is published through bower under the name ms-eventjs
bower install ms-eventjsOnce installed, simply add dist/eventjs.min.js file into your html file.
Usage
#####Create event:
$event.eventbus.Create('eventName');#####Subscribe event:
$event.eventbus.Subscribe('eventName', Namespace.someFunction);#####Publish event:
// excecute all handlers in sync
$event.eventbus.Publish('eventName');
// excecute all handlers in async
$event.eventbus.Publish('eventName', true);
#####UnSubscribe event:
$event.eventbus.UnSubscribe('eventName', Namespace.someFunction);Examples
You can also checkout sample code in Examples folder.
##TODO
- Unit testing http://jasmine.github.io/2.4/introduction.html
- travis-ci integration
- Integrate document.events
Watcher
you can subscribe to the changes of any object. E.g.
var obj = {fName: 'Manoj', lName: 'Shevate'};
$event.watch(obj, function(c){
// This function will be called whenever any changes made to the object "obj"
});