aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/stores/base.js
blob: 55808debaec223b216215dfde62ebd518524ce5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function EventEmitter() {"use strict";
        this.listeners = {};
    }
    EventEmitter.prototype.emit=function(event) {"use strict";
        if (!(event in this.listeners)) {
            return;
        }
        this.listeners[event].forEach(function(listener) {
            listener.apply(this, arguments);
        }.bind(this));
    };
    EventEmitter.prototype.addListener=function(event, f) {"use strict";
        this.listeners[event] = this.listeners[event] || [];
        this.listeners[event].push(f);
    };
    EventEmitter.prototype.removeListener=function(event, f) {"use strict";
        if (!(event in this.listeners)) {
            return false;
        }
        var index = this.listeners[event].indexOf(f);
        if (index >= 0) {
            this.listeners[event].splice(index, 1);
        }
    };