Skip to content

@epikodelabs/streamix


@epikodelabs/streamix / src/public-api / firstValueFrom

Function: firstValueFrom()

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

Defined in: projects/libraries/streamix/src/lib/factories/firstValueFrom.ts:15

Returns a promise that resolves with the first emitted value from an AtomBase or atom.

  • If the source emits a value, the promise resolves with that value.
  • If the source emits an error, the promise rejects with that error.
  • If the source 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

source

The source stream or atom to listen to.

Atom<T> | AsyncIterable<T, any, any>

Returns

Promise<T>

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

Released under the GNU AGPL v3 or later.