Skip to content

@epikodelabs/streamix


@epikodelabs/streamix / lastValueFrom

Function: lastValueFrom()

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

Defined in: projects/libraries/streamix/src/lib/converters/lastValueFrom.ts:19

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

Dropped results (internal backpressure signals from filter/skip/debounce etc.) are skipped transparently — only real emissions are considered.

  • Successful resolution: The promise resolves with the last real value emitted by the stream, after the stream has completed.
  • Rejection on error: If the stream emits an error, the promise is rejected.
  • Rejection on no value: If the stream completes without emitting any real values, the promise is rejected with a specific error message.

Type Parameters

T

T = any

The type of the value expected from the stream.

Parameters

stream

Stream<T>

The source stream to listen to for the final value.

Returns

Promise<T>

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

Released under the GNU AGPL v3 or later.