Skip to content
PACKAGES

inputNode()

Wrap a direct value or state node into a writable node handle.

import { inputNode } from "@graphrefly/ts/solutions/reactive-layout";
function inputNode(
g: Graph,
input: T | Node<T> | undefined,
fallback: T,
name: string,
): { readonly node: Node<T>; readonly set: (value: T) => void }
ParameterTypeDescription
gGraphGraph that owns the writable state fallback.
inputT | Node<T> | undefinedExisting node or raw initial value.
fallbackTFallback value when input is absent.
namestringName used for the generated state node.

The node plus a setter that updates the backing state.

import { graph } from "@graphrefly/ts/graph";
import { inputNode } from "@graphrefly/ts/solutions/reactive-layout";
const g = graph();
inputNode(g, undefined, 0, "count");

packages/ts/src/solutions/reactive-layout/measurements.ts