Skip to content

Conditional

Types

Node type

luau
type Node<T> = Graph.Node<T>

Properties

default Read Only

luau
Conditional.default: any

Sentinel key for Flux.switch maps: the factory stored under this key mounts whenever the source value matches no other key, the conditional's catch-all branch. Unmatched values share this stable key, so switching between two different unmatched values does not rebuild the branch.

Open Documentation

Functions

show

luau
Conditional.show<T, F>(condition: Node<any> | (() -> any) | any, component: (value: () -> any) -> T, fallback: ((value: () -> any) -> F)?): Node<any>

Mounts component while condition is truthy, swapping to fallback (if given) when it turns falsy. The chosen factory runs once per mount in its own branch scope (the effects and cleanups it registers are torn down automatically on the next swap) and receives a value accessor for the live condition value. Returns a node usable at a numeric index of Flux.new / Flux.edit.

Open Documentation

Parameters

  • condition: The reactive source; re-runs only when its truthiness flips, not on every change.
  • component: Branch factory mounted while condition is truthy; receives (value).
  • fallback: Optional branch factory mounted while condition is falsy; receives (value).

showKeyed

luau
Conditional.showKeyed<T, F>(condition: Node<any> | (() -> any) | any, component: (value: () -> any) -> T, fallback: ((value: () -> any) -> F)?): Node<any>

Identity-keyed variant of Flux.show: instead of rebuilding only when condition's truthiness flips, it rebuilds whenever the value's identity changes, so swapping one truthy value for another remounts the branch with fresh state. The chosen factory runs in its own branch scope and receives a value accessor; since the value is fixed for the branch's lifetime, reading value() in the factory body yields it directly. Mirrors SolidJS's <Show keyed>.

Open Documentation

Parameters

  • condition: The reactive source; re-runs whenever its value changes identity, not just truthiness.
  • component: Branch factory mounted while condition is truthy; receives (value).
  • fallback: Optional branch factory mounted while condition is falsy; receives (value).

switch

luau
Conditional.switch<K>(source: Node<K> | (() -> K) | K)

Mounts the branch keyed by source's current value. Curries: pass the reactive source, then a map of value → factory; the matching factory runs once in its own branch scope and receives a value accessor. For a keyed branch value() is the matched key (fixed for the branch's lifetime); under Flux.default (which mounts for any unmatched value), value() tracks the live unmatched value. Returns a node usable at a numeric index of Flux.new / Flux.edit.

Open Documentation