API Reference
inputNode()
Wrap a direct value or state node into a writable node handle.
Import
import { inputNode } from "@graphrefly/ts/solutions/reactive-layout";
Signature
function inputNode(
g: Graph,
input: T | Node<T> | undefined,
fallback: T,
name: string,
): { readonly node: Node<T>; readonly set: (value: T) => void }
Parameters
| Parameter | Type | Description |
|---|---|---|
g | Graph | Graph that owns the writable state fallback. |
input | T | Node<T> | undefined | Existing node or raw initial value. |
fallback | T | Fallback value when input is absent. |
name | string | Name used for the generated state node. |
Returns
The node plus a setter that updates the backing state.
Example
import { graph } from "@graphrefly/ts/graph";
import { inputNode } from "@graphrefly/ts/solutions/reactive-layout";
const g = graph();
inputNode(g, undefined, 0, "count");
Source
packages/ts/src/solutions/reactive-layout/measurements.ts