Event.js 606 B

12345678910111213141516171819
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var Event = /** @class */ (function () {
  4. function Event(name) {
  5. this.listeners = [];
  6. }
  7. Event.prototype.subscribe = function (fn) {
  8. this.listeners.push(fn);
  9. };
  10. Event.prototype.trigger = function (args) {
  11. this.listeners.map(function (fn) { return fn(args); });
  12. };
  13. Event.prototype.unsubscribe = function (fn) {
  14. this.listeners = this.listeners.filter(function (f) { return f != fn; });
  15. };
  16. return Event;
  17. }());
  18. exports.Event = Event;
  19. //# sourceMappingURL=Event.js.map