1.0.4 • Published 2 years ago
EventManger 事件订阅派发
Author lionzyp
使用说明
添加派发事件
add(key: string, func: Function, caller: any = null): void
@param key - 键值
@param func - 回调函数
@param caller - 默认参数
@example e.add('test', (a: any, b: any) => { console.log(a, b) }, 'sss' or undefined);
移除派发事件
remove(key: string, func: Function, caller: any = null): void;
@param key - 键值
@param func - 回调函数
@param caller - 默认参数
派发事件
fire(key: string, ...data: any[]): void;
@param key - 键值
@param data - 数据
@example e.fire('test', 1, 2) or e.fire('test', 1)
清除事件
clear(): void;
Example
const EM = new EventManger();
EM.add('test', (a: any) => { console.log(a) });
EM.fire('test', 1);