Skip to content

Instantly share code, notes, and snippets.

@hontas
Created October 23, 2012 09:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hontas/3937905 to your computer and use it in GitHub Desktop.
Save hontas/3937905 to your computer and use it in GitHub Desktop.
JavaScript: PubSub
// Works in modern browsers + IE9, but Modernizr has a polyfill baked in for function.bind.
// Hat tip Paul Irish
var o = $( {} );
$.sub = o.on.bind(o);
$.unsub = o.off.bind(o);
$.pub = o.trigger.bind(o);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment