inputNode()
Wrap a direct value or state node into a writable node handle.
Import
Section titled “Import”import { inputNode } from "@graphrefly/ts/solutions/reactive-layout";Signature
Section titled “Signature”function inputNode( g: Graph, input: T | Node<T> | undefined, fallback: T, name: string,): { readonly node: Node<T>; readonly set: (value: T) => void }Parameters
Section titled “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
Section titled “Returns”The node plus a setter that updates the backing state.
Example
Section titled “Example”import { graph } from "@graphrefly/ts/graph";import { inputNode } from "@graphrefly/ts/solutions/reactive-layout";
const g = graph();inputNode(g, undefined, 0, "count");Source
Section titled “Source”packages/ts/src/solutions/reactive-layout/measurements.ts