UNPKG

@auto-engineer/message-bus

Version:

Message bus for handling commands, events, and queries

20 lines 1.07 kB
import { Command, Event, CommandHandler, EventHandler, EventSubscription } from './types'; export declare function createMessageBus(): { registerCommandHandler: <TCommand extends Command>(commandHandler: CommandHandler<TCommand>) => void; registerEventHandler: <TEvent extends Event>(eventHandler: EventHandler<TEvent>) => EventSubscription; sendCommand: <TCommand extends Command>(command: TCommand) => Promise<void>; publishEvent: <TEvent extends Event>(event: TEvent) => Promise<void>; subscribeToEvent: <TEvent extends Event>(eventType: string, handler: EventHandler<TEvent>) => EventSubscription; subscribeAll: <TEvent extends Event = Readonly<{ type: string; data: { [x: string]: any; }; timestamp?: Date; requestId?: string; correlationId?: string; }>>(handler: EventHandler<TEvent>) => EventSubscription; getCommandHandlers: () => Record<string, CommandHandler>; }; export type MessageBus = ReturnType<typeof createMessageBus>; //# sourceMappingURL=message-bus.d.ts.map