GraphReFlyTS

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

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.

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