Skip to content

@camera.ui/sdk / observable / firstValueFrom

Function: firstValueFrom() ​

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

Defined in: observable/index.ts:582

Subscribe to the source and return a Promise that resolves with its first emitted value, then disposes the subscription. Rejects if the source completes before emitting (Subject, BehaviorSubject, ReplaySubject). A bare Observable has no completion signal, so the Promise stays pending until it emits.

Type Parameters ​

T ​

T

Parameters ​

observable ​

Observable<T> | Subject<T> | ReplaySubject<T> | BehaviorSubject<T>

Source stream to await.

Returns ​

Promise<T>

Promise that resolves with the first emitted value.

Example ​

ts
import { firstValueFrom } from '@camera.ui/sdk';

const change = await firstValueFrom(sensor.onPropertyChanged);
console.log('first change:', change.property);