4 function Subscriber() {
7 Subscriber.prototype = {
8 receive: function(message) {
15 function Publisher() {
16 this._subscribers = [];
19 Publisher.prototype = {
20 publish: function(message) {
21 for(var i=0; i<this._subscribers.length; i++) {
22 var subscriber = this._subscribers[i];
23 subscriber.receive(message);
26 add: function(subscriber) {
27 this._subscribers.push(subscriber);