@likg/bus
Version:
28 lines (27 loc) • 701 B
TypeScript
type FunctionType = (...args: any[]) => void;
declare class EventBus {
private bus;
private static instance;
private constructor();
static defaultUtils(): EventBus;
/**
* 监听事件
* @param event 事件名称
* @param handler 事件处理函数
*/
$on(event: string, handler: FunctionType): void;
/**
* 触发事件
* @param event 事件名称
* @param args 参数
*/
$emit(event: string, ...args: any): void;
/**
* 移除事件
* @param event 事件名称
* @param handler 事件处理函数
*/
$off(event: string, handler?: FunctionType): void;
}
declare const Bus: EventBus;
export default Bus;