Created
December 2, 2012 04:51
-
-
Save yakcode/4187013 to your computer and use it in GitHub Desktop.
JavaScript: Sexy PubSub
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 Modernizr has a polyfill baked in for function.bind. | |
| // Uses Javascript's new bind function | |
| //Hat tip Paul Irish 'and tuts' | |
| var o = $( {} ); | |
| $.subscribe = o.on.bind(o); | |
| $.unsubscribe = o.off.bind(o); | |
| $.publish = o.trigger.bind(o); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment