Skip to content

Instantly share code, notes, and snippets.

@imnutz
Forked from biabsnippets/gist:4224404
Created August 22, 2013 03:20
Show Gist options
  • Select an option

  • Save imnutz/6302858 to your computer and use it in GitHub Desktop.

Select an option

Save imnutz/6302858 to your computer and use it in GitHub Desktop.
/*
* Sexy Pub/Sub (jQuery Edition)
*
* Hat tip Paul Irish & Jeffrey Way.
*/
(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