GraphReFlyTS

API Reference

fromPromise()

Lift a Promise (or thenable) to a single-value stream: one DATA then COMPLETE, or ERROR on rejection. async pool (default pausable → a paused source buffers its late emit). Optional signal aborts to ERROR.

Import

import { fromPromise } from "@graphrefly/ts/sources";

Signature

function fromPromise(
	p: Promise<T> | PromiseLike<T>,
	opts?: AsyncSourceOpts,
): Operator<never, T>

Parameters

ParameterTypeDescription
pPromise<T> | PromiseLike<T>Promise or thenable to lift into the graph.
optsAsyncSourceOptsOptional abort signal and async source options.

Returns

A source operator that emits one DATA value and COMPLETE, or ERROR on rejection/abort.

Example

import { graph } from "@graphrefly/ts/graph";
import { fromPromise } from "@graphrefly/ts/sources";

const user = graph().initNode(fromPromise(fetch("/user").then((res) => res.json())), []);

Source

packages/ts/src/graph/sources.ts