Skip to content

Instantly share code, notes, and snippets.

@antonagestam
Created March 6, 2012 22:52
Show Gist options
  • Save antonagestam/1989563 to your computer and use it in GitHub Desktop.
Save antonagestam/1989563 to your computer and use it in GitHub Desktop.
JavaScript: jQuery: Pub/Sub
// Works in modern browsers + IE9, but Modernizr has a polyfill baked in for function.bind.
// Hat tip Paul Irish
(function($){
var o = $( {} );
$.subscribe = o.on.bind(o);
$.unsubscribe = o.off.bind(o);
$.publish = o.trigger.bind(o);
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment