Skip to content
PACKAGES

firstValueFrom()

Resolve the first DATA from a Node as a Promise.

import { firstValueFrom } from "@graphrefly/ts/sources";
function firstValueFrom(source: Node<T>): Promise<T>
ParameterTypeDescription
sourceNode<T>Node to subscribe to.

A Promise for the first DATA value, or a rejection on ERROR/early completion.

import { graph } from "@graphrefly/ts/graph";
import { firstValueFrom } from "@graphrefly/ts/sources";
const g = graph();
await firstValueFrom(g.state(1));
  • Host-boundary escape hatch only. Do not call it from reactive node bodies; use graph deps/messages there so the topology remains declarative and inspectable.

packages/ts/src/graph/sources.ts