hors
Version:
Node.js API framework
21 lines (20 loc) • 526 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
class SimpleEvent {
constructor() {
this.runningId = 0;
this.handlers = {};
}
fire(data) {
Object.keys(this.handlers).forEach(idKey => this.handlers[idKey](data));
}
bind(handler) {
const id = this.runningId++;
this.handlers[`${id}`] = handler;
return id;
}
unbind(id) {
delete this.handlers[`${id}`];
}
}
exports.SimpleEvent = SimpleEvent;