Skip to content

Instantly share code, notes, and snippets.

@addyosmani
Forked from gbakernet/jquery.pubsub.js
Created November 30, 2010 06:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save addyosmani/721237 to your computer and use it in GitHub Desktop.
Save addyosmani/721237 to your computer and use it in GitHub Desktop.
(function($){
$.pubsub = (function(){
var mule = $({});
return {
subscribe:function(key, fn){
//Normalise
mule.bind(key, function(e, data){
fn.apply(null, [data]);
});
},
publish:function(key, data){
mule.trigger(key, data);
},
unsubscribe:function(key){
mule.unbind(key);
}
};
}());
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment