API Reference
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
import { reactiveList } from "@graphrefly/ts/data-structures";
Signature
function reactiveList(
initial?: readonly T[],
options: ReactiveListOptions = {},
): ReactiveList<T>
Parameters
| Parameter | Type | Description |
|---|---|---|
initial | readonly T[] | Optional initial list contents. |
options | ReactiveListOptions | Optional graph binding, dispatcher, name, and capacity policy. |
Returns
A reactive list with DELTA and lazy SNAPSHOT ports plus imperative mutation helpers.
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
packages/ts/src/graph/data-structures/reactive-list.ts