Skip to main content

ComputedObservable<T>

Defined in: src/lib/observable/observable.ts:346

Computed observable that derives its value from other observables. Read-only - value is computed from sources.

Type Parameters​

Type ParameterDescription
TThe type of computed value

Implements​

Constructors​

Constructor​

new ComputedObservable\<T\>(
   id: string, 
   compute: () => T, 
sources: ReadonlyObservable<unknown>[]): ComputedObservable\<T\>;

Defined in: src/lib/observable/observable.ts:358

Create a computed observable.

Parameters​

ParameterTypeDescription
idstringUnique identifier
compute() => TFunction that computes the value from sources
sourcesReadonlyObservable<unknown>[]Source observables to watch

Returns​

ComputedObservable<T>

Accessors​

id​

Get Signature​

get id(): string;

Defined in: src/lib/observable/observable.ts:377

The unique identifier of this observable.

Returns​

string

The unique identifier of this observable.

Implementation of​

ReadonlyObservable.id


isDisposed​

Get Signature​

get isDisposed(): boolean;

Defined in: src/lib/observable/observable.ts:385

Returns​

boolean

Implementation of​

IDisposable.isDisposed


value​

Get Signature​

get value(): T;

Defined in: src/lib/observable/observable.ts:381

The current value.

Returns​

T

The current value.

Implementation of​

ReadonlyObservable.value

Methods​

[dispose]()​

dispose: void;

Defined in: src/lib/observable/observable.ts:418

Returns​

void

Implementation of​

IDisposable.[dispose]

dispose()​

dispose(): void;

Defined in: src/lib/observable/observable.ts:408

Dispose of the computed observable and unsubscribe from sources.

Returns​

void

Implementation of​

IDisposable.dispose


pipe()​

pipe\<U\>(source: ReadonlyObservable\<U\>, transform?: (value: U) => T): Subscription;

Defined in: src/lib/observable/observable.ts:393

Subscribe to another observable, updating this one when it changes. Creates a one-way binding from source to this observable.

Type Parameters​

Type Parameter
U

Parameters​

ParameterTypeDescription
sourceReadonlyObservable<U>The source observable to subscribe to
transform?(value: U) => TOptional transform function

Returns​

Subscription

Subscription that can be disposed to unsubscribe

Implementation of​

ReadonlyObservable.pipe


subscribe()​

subscribe(callback: SubscriptionCallback\<T\>): Subscription;

Defined in: src/lib/observable/observable.ts:389

Subscribe to value changes.

Parameters​

ParameterTypeDescription
callbackSubscriptionCallback<T>Function called when value changes

Returns​

Subscription

Subscription that can be disposed to unsubscribe

Implementation of​

ReadonlyObservable.subscribe