Skip to content

Instantly share code, notes, and snippets.

@jCrip
Created March 12, 2012 16:02
Show Gist options
  • Save jCrip/2022986 to your computer and use it in GitHub Desktop.
Save jCrip/2022986 to your computer and use it in GitHub Desktop.
jQuery: pub/sub
// PubSub
(function( $ ) {
var o = $( {} );
$.each({
trigger: 'publish',
on: 'subscribe',
off: 'unsubscribe'
}, function( key, val ) {
jQuery[val] = 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