Μετάβαση στο περιεχόμενο

CommandBus

Αυτό το περιεχόμενο δεν είναι ακόμη διαθέσιμο στη γλώσσα σου.

Defined in: packages/cqrs/src/command.bus.ts:18

Sends a command to its one handler, through the handler’s pipeline. createCqrs() builds it.

const { commandBus } = createCqrs();
const id = await commandBus.execute<CreateUserCommand, string>(new CreateUserCommand('ann'));

C extends ICommand = ICommand

new CommandBus<C>(handlers): CommandBus<C>

Defined in: packages/cqrs/src/command.bus.ts:24

ReadonlyMap<AnyClass, Dispatch>

Maps each command class to the function that runs its handler. The bus reads it at every call, so it can be filled after the bus is created, as handlers that inject the bus require.

CommandBus<C>

execute<T, R>(command): Promise<R>

Defined in: packages/cqrs/src/command.bus.ts:37

Runs the handler of the command’s class, or of its nearest parent class that has one, and resolves with what the handler returns, typed as R.

T extends ICommand

R = unknown

T

Promise<R>

CommandHandlerNotFoundException (as a rejection) when no class in the command’s chain has a handler.

await commandBus.execute(new CreateUserCommand('ann'));