Usage:
$.subscribe('eventName', function(data){ console.log(data.key) });
$.publish('eventName', { key: value });
// good idea: keep track of events using an array
events = {
eventName : 'EVENTNAME'
}
$.subscribe(events.eventName)
| (function($) { | |
| var o = $({}); | |
| $.subscribe = function() { | |
| o.on.apply(o, arguments); | |
| }; | |
| $.unsubscribe = function() { | |
| o.off.apply(o, arguments); | |
| }; | |
| $.publish = function() { | |
| o.trigger.apply(o, arguments); | |
| }; | |
| }(jQuery)); |