https://github.com/mediapop/eventsmanager
For setting up the event binding idiom to your own javascript objects.
https://github.com/mediapop/eventsmanager
Last synced: 3 months ago
JSON representation
For setting up the event binding idiom to your own javascript objects.
- Host: GitHub
- URL: https://github.com/mediapop/eventsmanager
- Owner: mediapop
- Created: 2013-06-25T10:05:52.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2013-07-10T03:41:14.000Z (almost 12 years ago)
- Last Synced: 2025-01-24T08:11:38.966Z (5 months ago)
- Language: JavaScript
- Size: 107 KB
- Stars: 0
- Watchers: 8
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.mkd
Awesome Lists containing this project
README
# EventsManager
For adding the events idiom to your own objects.
function MyObject(){
var eventsManager = new EventsManger(this);
this.on = eventsManager.on;
this.off = eventsManager.off;
this.trigger = eventsManager.trigger;
}Or much better:
function MyObject(){};
MyObject.prototype = new EventsManager();# API
var myObject = new MyObject();
## On
Bind events.
myObject.on("crazyness", function(){
console.log(this); // MyObject;
console.log("Crazyness!");
})## Off
Unbind events.
myObject.off("crazyness")
## Trigger
Cause stuff to happen.
myObject.trigger("crazyness");
myObject.on("somethingy", function(wowArguments){
console.log(wowArguments);
});
myObject.trigger('somethingy', 1);# Test
npm install -g mocha
make test