UNPKG

@tmorin/ceb-messaging-simple

Version:

The package is part of the `<ceb/>` library. It provides an implementation of the messaging model leveraging on a vanilla TypeScript/JavaScript environment.

19 lines (18 loc) 1.11 kB
import { Command, CommandBus, CommandHandler, Disposable, EmittableCommandBus, Event, EventBus, ExecuteActionOptions, ObservableCommandBus, Removable, Result } from "@tmorin/ceb-messaging-core"; /** * The symbol used to register {@link SimpleCommandBus}. */ export declare const SimpleCommandBusSymbol: unique symbol; export declare class SimpleCommandBus implements CommandBus, Disposable { private readonly eventBus; private readonly emitter; private readonly handlers; constructor(eventBus: EventBus, emitter: EmittableCommandBus, handlers?: Map<string, CommandHandler<any, any, any>>); get observer(): ObservableCommandBus; execute<R extends Result = Result, C extends Command = Command>(command: C, options?: Partial<ExecuteActionOptions>): Promise<R>; executeAndForget<C extends Command = Command>(command: C): void; handle<C extends Command = Command, R extends Result = Result, Es extends Array<Event> = []>(commandType: string, handler: CommandHandler<C, R, Es>): Removable; dispose(): Promise<void>; private resolveHandler; private processHandlerOutput; }