export declare type EventName = string; export declare type Callback

= (...payload: P) => void; /** * 事件发射器接口,参考nodejs api `EventEmitter`. * * @see https://nodejs.org/dist/latest-v14.x/docs/api/events.html#events_class_eventemitter */ interface EventEmitter { /** * 注册事件. * * @template N Type of 事件类型. * @template P Type of callback参数类型. * @param name 事件名称. * @param callback 事件处理函数. */ addEventListener: (name: N, callback?: Callback

) => void; /** * 移除事件处理函数. * * @template N Type of 事件类型. * @template P Type of callback参数类型. * @param name 事件名称. * @param callback 事件处理函数. */ removeEventListener: (name: N, callback?: Callback

) => void; /** * 触发事件. * * @template N Type of 事件类型. * @template P Type of callback参数类型. * @param name 事件名称. * @param payload 事件执行参数. */ dispatchEvent: (name: N, payload?: P) => void; } export default EventEmitter;