Created — forked from cowboy/HEY-YOU.md

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View jquery.ba-tinypubsub.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
/*!
* jQuery Tiny Pub/Sub - v0.2pre - 11/3/2010
* http://benalman.com/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
 
(function ($) {
var bind = $.fn.bind, unbind = $.fn.unbind, trigger = $.fn.trigger, win = {
"0": window,
"length": 1
};
$.subscribe = function () {
bind.apply(win, arguments);
};
$.unsubscribe = function () {
unbind.apply(win, arguments);
};
$.publish = function () {
trigger.apply(win, arguments);
};
}(jQuery));

Not tiny enough! :P

BTW I just made it slightly smaller/better: https://gist.github.com/661855

I know, I had far too much fun with this. If anything, I suppose it could be considered a testament to jQuery's powerful use of duck-typing. :)

I like your updated version better, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.