@epikodelabs/streamix / fromPromise
Function: fromPromise()
fromPromise<
T>(input):Stream<any,T>
Defined in: projects/libraries/streamix/src/lib/streams/fromPromise.ts:19
Creates a stream from a value, promise, or a cancelable asynchronous factory.
The input can be:
- A value
- A promise
- A function that returns a value or promise, and optionally reacts to cancellation via an AbortSignal.
The factory function (if provided) is invoked on subscription and receives an AbortSignal that is aborted when the stream is unsubscribed. If the factory throws or returns a rejected promise, the stream will emit an error.
Type Parameters
T
T
The type of the emitted value.
Parameters
input
A value, promise, or a function producing a value or promise, optionally using the provided abort signal for cancellation.
Promise<T> | (signal) => Promise<T>
Returns
Stream<any, T>
A stream that emits the produced value and then completes.