Skip to content

Instantly share code, notes, and snippets.

@aercolino
Forked from cowboy/HEY-YOU.md
Last active August 29, 2015 14:02
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 aercolino/cc74b7a39fdf21b98530 to your computer and use it in GitHub Desktop.
Save aercolino/cc74b7a39fdf21b98530 to your computer and use it in GitHub Desktop.
jQuery.news = (function($) {
var broker = $({});
return {
subscribe: function() {
$.fn.on.apply(broker, arguments);
},
unsubscribe: function() {
$.fn.off.apply(broker, arguments);
},
publish: function() {
$.fn.trigger.apply(broker, arguments);
}
};
}(jQuery));
@aercolino
Copy link
Author

Use it like $.news.publish, $.news.subscribe, $.news.unsubscribe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment