UNPKG

@ekidpro/ekp-conference

Version:

32 lines (31 loc) 940 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Events = void 0; var Events = /** @class */ (function () { function Events() { this.events = {}; } Events.prototype.addEvent = function (key, fnc) { if (!this.events[key]) { this.events[key] = []; } this.events[key].push(fnc); }; Events.prototype.removeEvent = function (key, fnc) { var fncClone = this.events[key]; this.events[key] = fncClone.filter(function (i) { return i !== fnc; }); }; Events.prototype.removeEventAll = function () { this.events = {}; }; Events.prototype.emit = function (key, args) { var fncClone = this.events[key]; if (fncClone && fncClone.length > 0) { fncClone.forEach(function (fnc) { fnc(args); }); } }; return Events; }()); exports.Events = Events;