Skip to content

Leiopython/eventjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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-eventjs
bower

This package is published through bower under the name ms-eventjs

bower install ms-eventjs

Once 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

  1. Unit testing http://jasmine.github.io/2.4/introduction.html
  2. travis-ci integration
  3. 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"
});