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
Section titled “Import”import { fromPromise } from "@graphrefly/ts/sources";Signature
Section titled “Signature”function fromPromise( p: Promise<T> | PromiseLike<T>, opts?: AsyncSourceOpts,): Operator<never, T>Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
p | Promise<T> | PromiseLike<T> | Promise or thenable to lift into the graph. |
opts | AsyncSourceOpts | Optional abort signal and async source options. |
Returns
Section titled “Returns”A source operator that emits one DATA value and COMPLETE, or ERROR on rejection/abort.
Example
Section titled “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
Section titled “Source”packages/ts/src/graph/sources.ts