|
|
@ -1,6 +1,6 @@
|
|
|
|
export class DefaultEventEmitter {
|
|
|
|
export class DefaultEventEmitter {
|
|
|
|
// 参考: https://developer.mozilla.org/zh-CN/docs/Web/API/EventTarget
|
|
|
|
// 参考: https://developer.mozilla.org/zh-CN/docs/Web/API/EventTarget
|
|
|
|
listeners = {};
|
|
|
|
listeners: any = {};
|
|
|
|
|
|
|
|
|
|
|
|
emit(type: string, ...args: any[]) {
|
|
|
|
emit(type: string, ...args: any[]) {
|
|
|
|
if (!(type in this.listeners)) {
|
|
|
|
if (!(type in this.listeners)) {
|
|
|
@ -25,7 +25,7 @@ export class DefaultEventEmitter {
|
|
|
|
this.listeners[type].push(callback);
|
|
|
|
this.listeners[type].push(callback);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
removeListener(type: string, callback: (...args: any[]) => any) {
|
|
|
|
removeListener(type: string, callback: (...args: any[]) => any): any {
|
|
|
|
if (!(type in this.listeners)) {
|
|
|
|
if (!(type in this.listeners)) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|