3
0

EventSystem.js 965 B

1
  1. "use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports["default"]=void 0;var _classCallCheck2=_interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));var _createClass2=_interopRequireDefault(require("@babel/runtime/helpers/createClass"));var EventSystem=function(){function EventSystem(){(0,_classCallCheck2["default"])(this,EventSystem);this.listeners={test:function test(){return console.log('This is default listener!');}};this.addEventListener=this.on;this.removeEventListener=this.off;}(0,_createClass2["default"])(EventSystem,[{key:"on",value:function on(eventId,fn){this.listeners[eventId]=fn;return this;}},{key:"off",value:function off(eventId){delete this.listeners[eventId];return this;}},{key:"emit",value:function emit(eventId,data){return this.listeners[eventId](data);}}]);return EventSystem;}();exports["default"]=EventSystem;