事件中心
1function getDetaultEmitter(): EventEmitter;
无
EventEmitter
实例
1interface EventEmitter {
2 // 监听事件
3 on(eventName: string, callback: TCallback): EventEmitter;
4 // 取消监听
5 off(eventName: string, callback: TCallback): EventEmitter;
6 // 触发事件
7 emit(eventName: string, data: any): EventEmitter;
8 // 监听一次
9 once(eventName: string, callback: TCallback): EventEmitter;
10 // 清除监听
11 clear(eventName: string): EventEmitter;
12 // 清除所有监听
13 clearAll(): EventEmitter;
14 // 获取可解构方法
15 getFuncMap(): {
16 on(eventName: string, callback: TCallback): EventEmitter;
17 off(eventName: string, callback: TCallback): EventEmitter;
18 emit(eventName: string, event: CustomEvent): EventEmitter;
19 once(eventName: string, callback: TCallback): EventEmitter;
20 clear(eventName: string): EventEmitter;
21 clearAll(): EventEmitter;
22 };
23}