acelga-bus
Version:
An extensible typescript message bus with support for middlewares
10 lines (9 loc) • 542 B
TypeScript
import { Constructable, EventSubscriptionCallback, EventCallbacksSet } from './interfaces';
export declare class Dispatcher<T = {}> {
subscriptions: Map<Constructable<T>, EventCallbacksSet<T>>;
globalSubscriptions: EventCallbacksSet<T>;
on<T1 extends T>(eventType: Constructable<T1>, callback: EventSubscriptionCallback<T1>): void;
onAny(callback: EventSubscriptionCallback<T>): void;
trigger(event: T): Promise<void>;
off<T1 extends T>(eventType: Constructable<T1>, callback?: EventSubscriptionCallback<T1>): void;
}