Skip to content

Instantly share code, notes, and snippets.

@donnelg
Created September 29, 2012 21:57
Show Gist options
  • Save donnelg/3805278 to your computer and use it in GitHub Desktop.
Save donnelg/3805278 to your computer and use it in GitHub Desktop.
Javascript: jQuery PubSub
(function($) {
var o = $( {} );
$.each({
on: 'subscribe',
trigger: 'publish',
off: 'unsubscribe'
}, function( key, api ) {
$[api] = function() {
o[key].apply( o, arguments );
}
});
})(JQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment