vapor-chamber API reference - v1.16.0
    Preparing search index...

    Type Alias ReactionOptions

    type ReactionOptions = {
        when?: (cmd: Command, result: CommandResult) => boolean;
        map?: (cmd: Command, result: CommandResult) => any;
        mapPayload?: (cmd: Command, result: CommandResult) => any;
        allowSelfMatch?: boolean;
        maxHops?: number;
    }
    Index
    when?: (cmd: Command, result: CommandResult) => boolean

    Only react when this predicate returns true.

    map?: (cmd: Command, result: CommandResult) => any

    Transform the source command into the target command's target.

    mapPayload?: (cmd: Command, result: CommandResult) => any

    Transform the source command into the target command's payload.

    allowSelfMatch?: boolean

    Allow sourcePattern to match targetAction — i.e. the reaction fires on its own dispatch. Refused by default, because the loop it creates is bounded only on a sync bus:

    • Sync bus: listeners fire nested inside dispatch, so MAX_DISPATCH_DEPTH halts each chain — 16 recursive dispatches and a logged VC_CORE_MAX_DEPTH per matching action. Degraded, bounded.
    • Async bus: listeners fire post-settle, so each cycle is a fresh top-level dispatch with the depth counter unwound. Nothing bounds it — a self-sustaining infinite loop running handlers, plugins and (with a bridge installed) HTTP requests forever.

    Opt in only alongside a when guard that can actually terminate it. The maxHops cap still applies.

    maxHops?: number

    How many reaction hops a single originating command may trigger before the chain is refused. Catches INDIRECT cycles (A→B, B→A), which no install-time check can see. Default: 8.