Javascript: Sexy PubSub

Don Graham
2012-09-29T21:49:12Z

gistfile1

| // Works in modern browsers + IE9, but Modernizr has a polyfill baked in for function.bind.
| // Hat tip Paul Irish
|
| var o = $( {} );
| $.subscribe = o.on.bind(o);
| $.unsubscribe = o.off.bind(o);
| $.publish = o.trigger.bind(o);