var mediator = (function() {
  var subscribe = function(channel, fn) {
    if (!mediator.channels[channel]) mediator.channels[channel] = [];
    mediator.channels[channel].push({ context: this, callback: fn });
    return this;
  },

  publish = function(channel) {
    if (!mediator.channels[channel]) return false;
    var args = Array.prototype.slice.call(arguments, 1);
    for (var i = 0, l = mediator.channels[channel].length; i < l; i++) {
      var subscription = mediator.channels[channel][i];
      subscription.callback.apply(subscription.context, args);
    }
    return this;
  };

  return {
    channels: {},
    publish: publish,
    subscribe: subscribe,
    installTo: function(obj) {
      obj.subscribe = subscribe;
      obj.publish = publish;
    }
  };

}());

@@ -1,13 +1,13 @@
 var 
-m
+M
 ediator 
@@ -22,365 +22,864 @@
 ion(
-) %7B%0A  var subscribe = function(channel, fn) %7B%0A    if (!mediator.channels%5Bchannel%5D) mediator.channels%5Bchannel%5D = %5B%5D;%0A    mediator.channels%5Bchannel%5D.push(%7B context: this, callback: fn %7D);%0A    return this;%0A  %7D,%0A%0A  publish = function(channel) %7B%0A    if (!mediator.channels%5Bchannel%5D) return false;%0A    var args = Array.prototype.slice.call(arguments, 1);%0A    
+window, undefined) %7B%0A %0A%09function Mediator() %7B%0A%09%09this._topics = %7B%7D;%0A%09%7D%0A %0A%09Mediator.prototype.subscribe = function mediatorSubscribe(topic, callback) %7B%0A%09%09if (!this._topics.hasOwnProperty(topic)) %7B%0A%09%09%09this._topics%5Btopic%5D = %5B%5D;%0A%09%09%7D%0A %0A%09%09this._topics%5Btopic%5D.push(callback);%0A%09%09return true;%0A%09%7D;%0A %0A%09Mediator.prototype.unsubscribe = function mediatorUnsubscrive(topic, callback) %7B%0A%09%09if (!this._topics.hasOwnProperty(topic)) %7B%0A%09%09%09return false;%0A%09%09%7D%0A %0A%09%09for(var i = 0, len = this._topics%5B topic %5D.length; i %3C len; i++) %7B%0A%09%09%09if (this._topics%5Btopic%5D%5Bi%5D === callback) %7B%0A%09%09%09%09this._topics%5Btopic%5D.splice(i, 1);%0A%09%09%09%09return true;%0A%09%09%09%7D%0A%09%09%7D%0A %0A%09%09return false;%0A%09%7D;%0A %0A%09Mediator.prototype.publish = function mediatorPublish() %7B%0A%09%09var args = Array.prototype.slice.call(arguments);%0A%09%09var topic = args.shift();%0A %0A%09%09if (!this._topics.hasOwnProperty(topic)) %7B%0A%09%09%09return false;%0A%09%09%7D%0A %0A%09%09
 for
- 
 (var
@@ -891,36 +891,31 @@
 0, l
+en
  = 
-mediator.channels%5Bchannel
+this._topics%5Btopic
 %5D.le
@@ -925,16 +925,18 @@
 h; i %3C l
+en
 ; i++) %7B
@@ -940,340 +940,407 @@
 ) %7B%0A
-      var subscription = mediator.channels%5Bchannel%5D%5Bi%5D;%0A      subscription.callback.apply(subscription.context, args);%0A    %7D%0A    return this;%0A  %7D;%0A%0A  return %7B%0A    channels: %7B%7D,%0A    publish: publish,%0A    subscribe: subscribe,%0A    installTo: function(obj) %7B%0A      obj.subscribe = subscribe;%0A      obj.publish = publish;%0A    %7D%0A  %7D;%0A%0A%7D());
+%09%09%09this._topics%5Btopic%5D%5Bi%5D.apply(undefined, args);%0A%09%09%7D%0A%09%09return true;%0A%09%7D;%0A %0A%09return Mediator;%0A %0A%7D )( window );%0A %0A// example subscriber function%0Avar Subscriber = function ExampleSubscriber(myVariable) %7B%0A  console.log(myVariable);%0A%7D;%0A %0A// example usages%0Avar myMediator = new Mediator();%0AmyMediator.subscribe('some event', Subscriber);%0AmyMediator.publish('some event', 'foo bar'); // console logs %22foo bar%22
 %0A

Update mediator pattern