Skip to content

Instantly share code, notes, and snippets.

@straydogstudio
Created June 13, 2012 20:19
Show Gist options
  • Save straydogstudio/2926264 to your computer and use it in GitHub Desktop.
Save straydogstudio/2926264 to your computer and use it in GitHub Desktop.
JavaScript: Sexy PubSub
// Works in modern browsers + IE9, but Modernizr has a polyfill baked in for function.bind.
// Hat tip Paul Irish
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