Skip to content

Instantly share code, notes, and snippets.

@eschie
Created November 11, 2013 00:40
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 eschie/7405986 to your computer and use it in GitHub Desktop.
Save eschie/7405986 to your computer and use it in GitHub Desktop.
My First Pub/Sub
/* MY FIRST PUB/SUB jQuery
* ESCHIE/DESIGN_PATTERNS
*
*/
(function($) {
var o = $( {} );
$.each({
trigger: 'publish',
on: 'subscribe',
off: 'unsubscribe'
}, function( fn, api ){
jQuery[api] = function() {
o[fn].apply( o, arguments );
};
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment