Stone.js API
    Preparing search index...

    Class representing a CommandRouterEventHandler. Responsible for finding and dispatching commands based on incoming events.

    Mr. Stone evensstone@gmail.com

    Type Parameters

    • W extends IncomingEvent = IncomingEvent
    • X = unknown

    Implements

    • IEventHandler<W, X>
    Index
    • Dispatches an event to the appropriate command.

      Parameters

      • event: W

        The incoming event to be dispatched.

      Returns Promise<X>

      The result of the command execution.

    • Finds a command that matches the given event.

      Parameters

      • event: W

        The incoming event to match against commands.

      Returns ICommandHandler<W, X>

      The matching command, or undefined if no match is found.

    • Handle an incoming event.

      Parameters

      • event: W

        The incoming event to process.

      Returns Promise<X>

      The outgoing response.

    • Runs the given command with the provided event.

      Parameters

      • event: W

        The event to handle.

      • Optionalcommand: ICommandHandler<W, X>

        The command to execute.

      Returns Promise<X>

      The result of the command execution, or void if no command is found.

    • Creates a new instance of CommandRouter.

      This static method initializes a CommandRouter with the specified options.

      Type Parameters

      • W extends IncomingEvent = IncomingEvent

        The type of the incoming event (default: IncomingEvent).

      • X extends OutgoingResponse = OutgoingResponse

        The type of the outgoing response (default: OutgoingResponse).

      Parameters

      Returns CommandRouterEventHandler<W, X>

      A new instance of CommandRouter configured with the provided options.