top-block-game-cocos-demo/temp/programming/packer-driver/targets/editor/chunks/98/98849503b8faa84306cd4f2613f...

48 lines
1.1 KiB
JavaScript

System.register(["cc"], function (_export, _context) {
"use strict";
var _cclegacy, EventBus, _crd;
_export("EventBus", void 0);
return {
setters: [function (_cc) {
_cclegacy = _cc.cclegacy;
}],
execute: function () {
_crd = true;
_cclegacy._RF.push({}, "c8a86xBewJDqY1y753RSQuf", "eventBus", undefined);
//声明类
_export("EventBus", EventBus = class EventBus {
constructor() {
this.eventList = void 0;
//定义事件总线对象
this.eventList = {};
} //监听,或者说是发布
on(eventName, fn) {
let eventItem = this.eventList[eventName];
eventItem ? eventItem.push(fn) : this.eventList[eventName] = [fn];
} //触发,订阅
emit(eventName, ...arg) {
this.eventList[eventName] && this.eventList[eventName].forEach(fn => {
fn(...arg);
});
}
});
_export("default", EventBus);
_cclegacy._RF.pop();
_crd = false;
}
};
});
//# sourceMappingURL=98849503b8faa84306cd4f2613feaa7a4f5cd523.js.map