/** * Custom event emitter implementation for use */ declare class EventEmitter = DefaultListener> { private _listeners; private _eventEmitterLogger; /** * Constructs instance */ constructor(); /** * Subscribes a listener to event * @param event Event to subscribe to * @param callback Listener function to subscribe */ on>(event: U, callback: L[U]): void; /** * Unsubscribes a listener from event * @param event Event to unsubscribe from * @param callback Callback to unsubscribe */ off>(event: U, callback: L[U]): void; /** * Subscribes a listener to event once * @param event Event to subscribe to * @param callback Listener function to subscribe * @param options Additional options */ once>(event: U, callback: L[U], options?: EventEmitter.OnceOptions): void; /** * Emits an event * @param event Event to emit * @param data Event payload * @returns Promise resolving when all listeners calls completed. Usually async version is useful if listeners may * return promises and the call should wait for them. If one of listener rejects or throws an error, it will be * logged. Async listeners called all at once */ emit>(event: U, ...args: Parameters): Promise; /** * Returns subscribed events * @returns subscribed events */ getSubscriptions(): EventEmitter.Event[]; /** * Returns subscribed event listeners * @param event Event * @returns Listeners */ getListeners>(event: U): L[U][]; /** * Returns whether has listeners on specific event * @param event Event * @returns Whether has listeners */ hasListeners>(event: U): boolean; private _callListener; } declare namespace EventEmitter { /** Method options */ type OnceOptions any> = { /** * If specified, the listener will be called only if the callback returns true. Otherwise, the listener will wait * for the next matching call */ ifArgs?: (...args: Parameters) => boolean; }; /** Infers event type of a listener */ type Event> = Extract; } export default EventEmitter; /** * Event emitter listener type */ export type ListenerSignature = { [EventName in keyof Listeners]: (...args: any[]) => any; }; /** * Default event emitter listener type */ export type DefaultListener = { [k: string]: (...args: any[]) => any; };