node()
Construct a node (R-node-iface / D5 / L1.9 deps-first). node([], null, { initial }) — state node (manual source; emit via .down) node([], fn) — producer (runs on activation) node([a, b], fn) — compute / derived node([dep]) — passthrough wire
Import
Section titled “Import”import { node } from "@graphrefly/ts/core";Signature
Section titled “Signature”function node( deps: Node<unknown>[] = [], handleOrFn: Handle | NodeFn | null = null, opts: NodeOptions<T> = {},): Node<T>Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
deps | Node<unknown>[] | Upstream nodes this node reads positionally from ctx. |
handleOrFn | Handle | NodeFn | null | Dispatcher handle, node function, or null for a manual source/state node. |
opts | NodeOptions<T> | Node runtime options such as initial, name, pool, dispatcher, and restore data. |
Returns
Section titled “Returns”A graph-agnostic Node.
Example
Section titled “Example”import { depLatest, node } from "@graphrefly/ts/core";
const source = node<number>([], null, { initial: 1 });const doubled = node<number>([source], (ctx) => { ctx.down([["DATA", Number(depLatest(ctx, 0)) * 2]]);});Source
Section titled “Source”packages/ts/src/node/node.ts