Lime Web Components API Documentation - v7.4.0
    Preparing search index...

    Enumeration CommandEventName

    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.

    import {
    CommandEvent,
    CommandEventName,
    PlatformServiceName,
    createLogger,
    getCommandId,
    } from '@limetech/lime-web-components';

    const logger = createLogger('my-component');
    const eventDispatcher = platform.get(PlatformServiceName.EventDispatcher);

    eventDispatcher.addListener(CommandEventName.Handled, (event: CommandEvent) => {
    const { command, result } = event.detail;

    logger.debug('Command executed', { command, result });
    });

    eventDispatcher.addListener(CommandEventName.Failed, (event: CommandEvent) => {
    const { error } = event.detail;

    logger.error('Command failed', error instanceof Error ? error : undefined);
    });

    eventDispatcher.addListener(
    CommandEventName.Received,
    (event: CommandEvent) => {
    // Preventing the default on the received event stops the command
    // before a handler sees it.
    if (getCommandId(event.detail.command) === 'delete-all-deals') {
    event.preventDefault();
    }
    }
    );
    Index

    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.

    Handled: "command.handled"

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

    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