Skip to content
Logo

broadcast

Composes handlers that observe the same request: every one of them is offered it, in order, whatever the others answered.

Use it when several concerns react to the same request independently. See Composing Handlers for how it compares to chain.

Usage

await .({
    // the indexer sees every input the application processes
    : (.handler, .handler),
});

Returns

A handler of the same request kind, ready to pass to run:

  • true if any handler accepted,
  • false if they all declined — run then rejects the input, since nobody claimed it. An empty broadcast() declines everything.

Exceptions are not caught: the first one aborts the remaining handlers and propagates to run, which rejects the input and emits the error as a report.

Parameters

handlers

  • Type: RequestHandler[]AdvanceRequestHandler or InspectRequestHandler
  • Variadic

The handlers, in the order they get offered the request. They may be synchronous or async, and always run one after another, never concurrently: they share one device and one application state, and the order in which they emit outputs is part of what the machine proves.

Each must return a real booleantrue accepts the request, false declines it. That is stricter than the handlers run takes directly, where returning nothing means accept; Handlers must answer explains why.

Errors

ConditionError
A handler answers with something other than a booleanTypeError

Ruled out by the types, so this only reaches JavaScript callers — as a rejected input with the error in a report, rather than a request silently counted as unclaimed.