Skip to content

@epikodelabs/streamix


@epikodelabs/streamix / firstValueFrom

Function: firstValueFrom()

firstValueFrom<T>(stream): Promise<T>

Defined in: projects/libraries/streamix/src/lib/converters/firstValueFrom.ts:17

Returns a promise that resolves with the first emitted value from a Stream.

Dropped results (internal backpressure signals from filter/skip/debounce etc.) are skipped transparently — the promise resolves with the first real emission.

  • If the stream emits a value, the promise resolves with that value.
  • If the stream emits an error, the promise rejects with that error.
  • If the stream completes without ever emitting a value, the promise rejects with an Error.

Type Parameters

T

T = any

The type of the value that the promise will resolve with.

Parameters

stream

Stream<T>

The source stream to listen to.

Returns

Promise<T>

A promise that resolves with the first value from the stream or rejects on error or completion without a value.

Released under the GNU AGPL v3 or later.