UNPKG

@ng1005/chrome-extension-common

Version:

chrome扩展通用库--消息与storage

35 lines (34 loc) 786 B
/** * 事件总线demo */ export declare class EventBusDemo { _events: Map<string, Function | Array<Function>>; constructor(); /** * on 监听 * @param type 消息类型 * @param fn 处理函数返回Promise<any> */ $on(type: string, fn: Function): this; /** * 提交事件 * @param type 消息类型 * @param args 参数 * @returns */ $emit(type: string, ...args: any): Promise<any>; /** * 移除监听 * @param type 类型 * @param fn 处理函数 */ $off(type: string, fn: Function): this; /** * 单次执行 * @param type 类型 * @param fn 处理函数 */ $once(type: string, fn: Function): this; } declare const $bus: EventBusDemo; export default $bus;