UNPKG

pdd

Version:
57 lines (56 loc) 1.53 kB
export declare type Function = (...args: any[]) => any; export declare class EventBus { _events: Map<any, any>; static _instance: InstanceType<typeof EventBus>; /** * 获取EventBus实例 * @return {EventBus} */ static getInstance(): EventBus; /** * EventBus.getEvents * @return {Map<any, any>} */ static getEvents(): Map<any, any>; static getEventsSize(): number; static getEvent(name: string): any; static hasEvent(name: string): boolean; static deleteEvent(name: string): boolean; /** * Method EventBus.setEvent * @param name * @param callback * @return {Map<any, any>} */ static setEvent(name: string, callback: CallableFunction): Map<any, any>; /** * Method EventBus.on as EventBus.setEvent * 绑定事件 * @param name * @param callback * @return {Map<*, *>} */ static on(name: string, callback: CallableFunction): Map<any, any>; /** * Method EventBus.emit * 执行事件 * @param name * @param payload * @return {*} */ static emit(name: string, ...payload: any[]): any; /** * Method EventBus.once * 执行事件并关闭事件 * @param name * @param payload */ static once(name: string, ...payload: any[]): void; /** * EventBus.off * 关闭事件 * @param name * @return {boolean} */ static off(name: string): boolean; }