/** * Expose ability to emit and subscribe to a single type of event. * @template TArg type of the event payload. */ export declare class EventEmitter { private _handlers; /** * Subscribes to the event. * @param handler a function to call when the event has been fired. * @returns a token used to cancel the event subscription. * @remarks * * Subscribing the same handler multiple times is allowed; they will be invoked multiple times. * * If `handler` returns a {@link PromiseLike} value, depending on how the {@link EventEmitter.invokeAsync} is called, * your event handler might be called concurrently (the 2nd invocation starts before the 1st invocation ends). * @todo Set up convention on what should happen if a handler is added/removed while * the event is being fired. */ subscribe(handler: EventHandler): Disposable; /** * Fires the event. * @param arg event payload. * @remarks * * This function will asynchronously wait for all its event handlers to return (or throw) * before returning, but _will not_ await any asynchronous portions. * * Were any of the event handler to throw any error, this function * _would not_ throw. Instead, errors are thrown to the current {@link SynchronizationContext}. */ invoke(arg: TArg): void; /** * Fires the event asynchronously. * @param arg event payload. * @remarks * * This function will wait for all its event handlers to return (or throw) * before returning, and will await any asynchronous portions. * * Were any of the event handler to throw any error, this function * _would not_ throw. Instead, errors are thrown to the current {@link SynchronizationContext}. */ invokeAsync(arg: TArg): Promise; } export type SyncEventHandler = (this: void, arg: TArg) => void; export type AsyncEventHandler = (this: void, arg: TArg) => void | PromiseLike; export type EventHandler = SyncEventHandler | AsyncEventHandler; //# sourceMappingURL=eventEmitter.d.ts.map