ICommandBus

Represents a command bus.


interface ICommandBus<CommandBase extends ICommand = ICommand> {
  execute<R = void>(command: Command<R>): Promise<R>
}

Methods

execute()

Executes a command.


execute<R = void>(command: Command<R>, context?: AsyncContext): Promise<R>

Parameters

Option Type Description
command Command

The command to execute.

context AsyncContext

The context to use. Optional.


Optional. Default is `undefined`.

Returns

Promise<R> A promise that, when resolved, will contain the result returned by the command's handler.


execute<T extends CommandBase, R = any>(command: T, context?: AsyncContext): Promise<R>

Parameters

Option Type Description
command T

The command to execute.

context AsyncContext

The context to use. Optional.


Optional. Default is `undefined`.

Returns

Promise<R> A promise that, when resolved, will contain the result returned by the command's handler.