UNPKG

event-emitters

Version:
17 lines (16 loc) 645 B
import { EventEmitter } from './EventEmitter'; import { Listener } from './EventSource'; /** * Acts the same as EventEmitter but queues messages when there are no subscribers, delivering them * as soon as the first subscriber subscribes. */ export declare class QueueingEventEmitter<T> extends EventEmitter<T> { private messageQueue; emit(newMessage: T): void; /** * The queue will still be drained if the subscriber throws error, in the case that the * there are multiple messages with multiple exceptions thrown, only the last one will * be re-thrown. */ subscribe(listener: Listener<T>): Listener<T>; }