@hyext/utils
Version:
A tools lib for huya miniapp business development
15 lines (14 loc) • 546 B
TypeScript
export declare class Emitter {
private listenerMap;
private logger;
constructor(logger: (message: string) => void);
log(message: string): void;
on(event: string, callback: any): () => void;
off(event: string, callback: any): void;
/**
* 因为 setMode 会在 onShow 之前执行,所以需要缓存 onShow 事件
* 否则当 onShow 开始监听时, 事件可能已经触发过了, 导致无法监听到事件
*/
emit(event: string, ...payload: any[]): void;
cleanup(): void;
}