Skip to content

Instantly share code, notes, and snippets.

@fearphage
Forked from cowboy/HEY-YOU.md
Created October 29, 2011 02:20
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 fearphage/1324007 to your computer and use it in GitHub Desktop.
Save fearphage/1324007 to your computer and use it in GitHub Desktop.
jQuery Tiny Pub/Sub: A really, really, REALLY tiny pub/sub implementation for jQuery.
/* jQuery Tiny Pub/Sub - v0.7 - 10/27/2011
* http://benalman.com/
* Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT, GPL */
(function($, a, i) {
var o = $({});
while (i) {
$[a[--i]] = (function(f) {
return function() {
f.apply(o, arguments);
};
})(o[a[--i]]);
}
}(jQuery, 'on6subscribe6off6unsubscribe6trigger6publish'.split(6), 6));
/* jQuery Tiny Pub/Sub - v0.7 - 10/27/2011
* http://benalman.com/
* Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT, GPL */
(function(a,b,c){var d=a({});while(c)a[b[--c]]=function(a){return function(){a.apply(d,arguments)}}(d[b[--c]])})(jQuery,"on6subscribe6off6unsubscribe6trigger6publish".split(6),6)
@fearphage
Copy link
Author

Now smaller and illegible but theoretically faster.

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