zz-chart
Version:
Alauda Chart components by Alauda Frontend Team
33 lines (32 loc) • 829 B
TypeScript
export interface EventType {
readonly callback: (...args: unknown[]) => void;
readonly once: boolean;
}
export declare type EventsType = Record<string, EventType[]>;
export default class EventEmitter {
private _events;
/**
* 监听一个事件
* @param evt
* @param callback
* @param once
*/
on(evt: string, callback: (args: any) => void, once?: boolean): this;
/**
* 监听一个事件一次
* @param evt
* @param callback
*/
once(evt: string, callback: () => void): this;
/**
* 触发一个事件
* @param evt
* @param args
*/
emit(evt: string, ...args: unknown[]): void;
/**
* 取消监听一个事件,或者一个 channel
*/
off(evt?: string, callback?: () => void): this;
getEvents(): EventsType;
}