import { Event, IListenerConfig } from './Event'; import { IOnCallback } from './index'; export interface IOnConfig { priority?: IListenerConfig['priority']; limit?: IListenerConfig['limit']; } export interface IOnceConfig { priority?: IListenerConfig['priority']; } export declare function emit(this: Emitter, key: string, ...payload: any[]): Promise; export declare function once(this: Emitter, key: string, callback: IOnCallback, options?: IOnceConfig): Event; export declare function on(this: Emitter, key: string, callback: IOnCallback, options?: IOnConfig): Event; /** * A component acts as both a subscriber and an event emitter. */ export declare class Emitter { debug: boolean; /** * If nothing has begun listening to an event after this * amount of (ms), the playback history is purged * * When set to `Infinity` this is never purged * When set to `false` no history is kept */ playback: false | number; /** * Emit an event, asynchronously. */ emit: typeof emit; on: typeof on; /** * Add listener to an event, but only fire the callback once. * * Also returns a promise which resolves only when the callback is executed. */ once: typeof once; /** The event listeners */ _events: Map; /** * A dict of event playback to ensure adding listeners can be done after * an event has been emit. This is useful for events like 'ready'. * * These payloads are pruned on a timeout */ _playback: Map; /** * Listen on any and all events */ all(): { on: (callback: any, options?: any) => Event; }; /** Applys priority to the next .on() */ prioritize(priority: number): { on: X["on"]; }; /** Allows execution of emitters on the next .on() without having to return anything */ tap(): { on: X["on"]; }; /** Remove a listener which matches `callback` */ off: (key: string, callback: any) => boolean; addPlayback(key: string, args: any[]): void; /** Purge playback after given timeout to prevent memory leaks */ private setPlaybackTimeout(key); }