Skip to content

@camera.ui/sdk / observable / Observable

Class: Observable<T>

Defined in: observable/index.ts:61

Cold producer of a push-based value stream.

The producer function passed to the constructor is executed once per subscribe() call, so each subscriber gets its own independent run. subscribe() returns a Disposable that stops the stream and triggers any teardown registered by the producer.

Type Parameters

T

T

Constructors

Constructor

new Observable<T>(subscribe): Observable<T>

Defined in: observable/index.ts:65

Parameters

subscribe

(callback) => Disposable

Returns

Observable<T>

Methods

pipe()

Call Signature

pipe(): Observable<T>

Defined in: observable/index.ts:101

Chain operators into a new Observable, each one fed by the previous.

Returns

Observable<T>

Observable emitting the transformed values.

Example
ts
sensor.onPropertyChanged
  .pipe(filter((c) => c.property === 'detected'), map((c) => c.value))
  .subscribe((detected) => console.log(detected));

Call Signature

pipe<A>(op1): Observable<A>

Defined in: observable/index.ts:102

Chain operators into a new Observable, each one fed by the previous.

Type Parameters
A

A

Parameters
op1

OperatorFn<T, A>

Returns

Observable<A>

Observable emitting the transformed values.

Example
ts
sensor.onPropertyChanged
  .pipe(filter((c) => c.property === 'detected'), map((c) => c.value))
  .subscribe((detected) => console.log(detected));

Call Signature

pipe<A, B>(op1, op2): Observable<B>

Defined in: observable/index.ts:103

Chain operators into a new Observable, each one fed by the previous.

Type Parameters
A

A

B

B

Parameters
op1

OperatorFn<T, A>

op2

OperatorFn<A, B>

Returns

Observable<B>

Observable emitting the transformed values.

Example
ts
sensor.onPropertyChanged
  .pipe(filter((c) => c.property === 'detected'), map((c) => c.value))
  .subscribe((detected) => console.log(detected));

Call Signature

pipe<A, B, C>(op1, op2, op3): Observable<C>

Defined in: observable/index.ts:104

Chain operators into a new Observable, each one fed by the previous.

Type Parameters
A

A

B

B

C

C

Parameters
op1

OperatorFn<T, A>

op2

OperatorFn<A, B>

op3

OperatorFn<B, C>

Returns

Observable<C>

Observable emitting the transformed values.

Example
ts
sensor.onPropertyChanged
  .pipe(filter((c) => c.property === 'detected'), map((c) => c.value))
  .subscribe((detected) => console.log(detected));

Call Signature

pipe<A, B, C, D>(op1, op2, op3, op4): Observable<D>

Defined in: observable/index.ts:105

Chain operators into a new Observable, each one fed by the previous.

Type Parameters
A

A

B

B

C

C

D

D

Parameters
op1

OperatorFn<T, A>

op2

OperatorFn<A, B>

op3

OperatorFn<B, C>

op4

OperatorFn<C, D>

Returns

Observable<D>

Observable emitting the transformed values.

Example
ts
sensor.onPropertyChanged
  .pipe(filter((c) => c.property === 'detected'), map((c) => c.value))
  .subscribe((detected) => console.log(detected));

Call Signature

pipe<A, B, C, D, E>(op1, op2, op3, op4, op5): Observable<E>

Defined in: observable/index.ts:106

Chain operators into a new Observable, each one fed by the previous.

Type Parameters
A

A

B

B

C

C

D

D

E

E

Parameters
op1

OperatorFn<T, A>

op2

OperatorFn<A, B>

op3

OperatorFn<B, C>

op4

OperatorFn<C, D>

op5

OperatorFn<D, E>

Returns

Observable<E>

Observable emitting the transformed values.

Example
ts
sensor.onPropertyChanged
  .pipe(filter((c) => c.property === 'detected'), map((c) => c.value))
  .subscribe((detected) => console.log(detected));

subscribe()

subscribe(callback): Disposable

Defined in: observable/index.ts:85

Start the producer for this subscriber and route emitted values to callback.

Parameters

callback

(value) => void

Receiver invoked once per emitted value.

Returns

Disposable

Disposable that stops the stream and runs producer teardown.

Example

ts
const sub = sensor.onPropertyChanged.subscribe((change) => {
  console.log(change.property, change.value);
});
// later
sub.dispose();