Skip to content

For

Types

Node type

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

Functions

index

luau
For.index<T, U>(list: Node<{ T }> | { T }, mapFn: (index: any, item: Node<T>) -> U): Node<{ U }>

Maps an array by index (unkeyed): the result at each position is built once and reused, with the item passed as a reactive node that updates in place as the value at that index changes. Reach for this over Flux.forValue when the array holds primitives, has duplicates, or churns by position rather than identity.

Open Documentation

Parameters

  • list: The reactive array (a node or plain array) to map over.
  • mapFn: Called once per index; receives the index and a reactive item node.

value

luau
For.value<T, U>(list: Node<{ T }> | { T }, mapFn: (index: Node<number>, value: T) -> U): Node<{ U }>

Maps an array by value (keyed): each item's mapped result is cached against the value itself, so results stay stable across reorders and only the item's reactive index node updates when it moves. Values must be unique: the value is the cache key, so duplicates collapse onto one mapped instance; for primitives, duplicates, or position-based churn use Flux.forIndex instead.

Open Documentation

Parameters

  • list: The reactive array (a node or plain array) to map over.
  • mapFn: Called once per unique value; receives a reactive index node and the value.