Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / third_party / mock4js / examples / Publisher.js
blob901b6152dfcf0be25e12eb0cf7c6caacbdddc644
1 /**
2  * Subscriber
3  */
4 function Subscriber() {
7 Subscriber.prototype = {
8         receive: function(message) {
9         }
12 /**
13  * Publisher
14  */
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);
24                 }
25         },
26         add: function(subscriber) {
27                 this._subscribers.push(subscriber);
28         }