Skip to content

waygraph / branch

Function: branch() ​

branch<In, Out>(block, routes): DefinedBlock<In, Checkpoint<string>>

Defined in: src/engine/block/branch.ts:22

Attaches routing to block without touching its act/observe/resolve/verify - routes must cover every tag of block's output (a missing route is a compile error), and the returned Block runs exactly as block always did, just followed by whichever next Block the resolved tag routes to. null for a tag means that tag is terminal - the run stops there, same as a Block with no routing at all. A route pointing back at block itself is a self-loop; see runGraph's maxSteps for its safety net. The result ends on any Checkpoint (Checkpoint<string>): a route can lead anywhere, including back through itself, so there is no fixed Out type to express; state the expected outcomes to runGraph via terminals instead. Each route's Block must start from the tag it routes on.

Type Parameters ​

In ​

In extends Checkpoint<string>

Out ​

Out extends Checkpoint<string>

Parameters ​

block ​

Block<In, Out>

routes ​

{ [K in string]: BlockFrom<Extract<Out, Checkpoint<K>>> | null }

Returns ​

DefinedBlock<In, Checkpoint<string>>

waygraph 0.18.3 (alpha) · Node 24+ · peer @playwright/test ^1.40.0 · syntax may change before 1.0: see what was removed