      1 pockets.Subscribable = Class.create({
      2
      3   subscribe: function(subscriber) {
      4     this.subscribers = this.subscribers || [];
      5     this.subscribers.push(subscriber);
      6   },
      7
      8   unsubscribe: function(subscriber) {
      9     if (this.subscribers) {
     10       this.subscribers = this.subscribers.without(subscriber);
     11     }
     12   },
     13
     14   callSubscribers: function(arg) {
     15     if (this.subscribers) {
     16       for( var i=0; i < this.subscribers.length; i++) {
     17         this.subscribers[i](arg);
     18       }
     19     }
     20   }
     21 });
     22