Events dispatched by the commandbus event middleware.

The command bus dispatches events at key points in the command lifecycle, allowing you to observe command execution, access results, handle errors, or even prevent commands from executing.

Example

// Listen for command results
document.addEventListener(CommandEventName.Handled, (event: CommandEvent) => {
console.log('Command executed:', event.detail.command);
console.log('Result:', event.detail.result);
});

// Handle command errors
document.addEventListener(CommandEventName.Failed, (event: CommandEvent) => {
console.error('Command failed:', event.detail.error);
});

// Prevent a command from executing
document.addEventListener(CommandEventName.Received, (event: CommandEvent) => {
if (shouldBlockCommand(event.detail.command)) {
event.preventDefault();
}
});

Enumeration Members

Enumeration Members

Failed: "command.failed"

Dispatched if an error occurs while handling the command. The event detail includes the error that was thrown.

See

CommandEvent

Handled: "command.handled"

Dispatched when the command has been handled by the commandbus. The event detail includes the result returned by the command handler.

See

CommandEvent

Received: "command.received"

Dispatched when the command has been received by the commandbus. Calling preventDefault() on the event will stop the command from being handled

See

CommandEvent