Created
July 19, 2018 10:22
-
-
Save artursopelnik/3955e3d42bfcacbec941066110c0a19b to your computer and use it in GitHub Desktop.
jQuery Tiny Pub/Sub - v0.8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* jQuery Tiny Pub/Sub - v0.8 - 07/19/2018 | |
* http://benalman.com/ | |
* Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT, GPL */ | |
(function($) { | |
var o = $({}); | |
$.subscribe = function() { | |
o.on.apply(o, arguments); | |
}; | |
$.unsubscribe = function() { | |
o.off.apply(o, arguments); | |
}; | |
$.once = function (args, callback) { | |
return $.subscribe(args, callback, function () { | |
callback(); | |
$.unsubscribe(args); | |
}); | |
}; | |
$.publish = function() { | |
o.trigger.apply(o, arguments); | |
}; | |
}(jQuery)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment