reactiveList()
Create a reactive list (D54/D60). The DELTA + SNAPSHOT ports + pullId come from the shared {@link collectionCore}; this layer adds the typed list method surface + backend.
Import
Section titled “Import”import { reactiveList } from "@graphrefly/ts/data-structures";Signature
Section titled “Signature”function reactiveList( initial?: readonly T[], options: ReactiveListOptions = {},): ReactiveList<T>Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
initial | readonly T[] | Optional initial list contents. |
options | ReactiveListOptions | Optional graph binding, dispatcher, name, and capacity policy. |
Returns
Section titled “Returns”A reactive list with DELTA and lazy SNAPSHOT ports plus imperative mutation helpers.
Example
Section titled “Example”const list = reactiveList<number>([1]);// observe events:list.delta.subscribe((m) => { if (m[0] === "DATA") console.log("Δ", m[1]); });list.append(2); // delta: {kind:"append", value:2}// demand the snapshot (a downstream consumer, holding `list.snapshot` upstream, runs):// ctx.upNext([["PULL", { pullId: list.pullId }]]); → SNAPSHOT delivers [1, 2]list.toArray(); // [1, 2] (synchronous non-reactive read)Source
Section titled “Source”packages/ts/src/graph/data-structures/reactive-list.ts