UNPKG

@deepkit/core

Version:
29 lines (28 loc) 968 B
declare type AsyncSubscriber<T> = (event: T) => Promise<void> | void; export declare type AsyncEventSubscription = { unsubscribe: () => void; }; export declare class AsyncEmitterEvent { readonly id: number; stopped: boolean; propagationStopped: boolean; /** * Stop propagating the event to subsequent event listeners. */ stopPropagation(): void; /** * Signal the emitter that you want to abort. * Subsequent event listeners will still be called. */ stop(): void; } export declare class AsyncEventEmitter<T extends AsyncEmitterEvent> { protected parent?: AsyncEventEmitter<any> | undefined; protected subscribers: AsyncSubscriber<T>[]; constructor(parent?: AsyncEventEmitter<any> | undefined); subscribe(callback: AsyncSubscriber<T>): AsyncEventSubscription; emit(event: T): Promise<void>; hasSubscriptions(): boolean; } export {}; export declare type __ΩAsyncEventSubscription = any[];