Skip to content

Instantly share code, notes, and snippets.

@Bondifrench
Created February 21, 2014 03:57
Show Gist options
  • Save Bondifrench/9128471 to your computer and use it in GitHub Desktop.
Save Bondifrench/9128471 to your computer and use it in GitHub Desktop.
Javascript: PubSub test
//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