Created
February 21, 2014 03:57
-
-
Save Bondifrench/9128471 to your computer and use it in GitHub Desktop.
Javascript: PubSub test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Works in modern browsers +IE9, but Modernizer has a polyfill baked in for function.bind | |
//From Sublime Nettuts tutorial, original credit from Paul Irish | |
var o=$( {}); | |
$.subscribe = o.on.bind('event name', eventData, function(event) { | |
/* Act on the event */ | |
}); | |
$.unsubscribe = o.off.bind(); | |
$.publish = o.trigger.bind(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment