Skip to content

Read<T, Cancelling>

Class

The Read is the core class available in this library. It represents a reactive value that can also be calculated synchronously.

A Read is interoperable with Observables of RxJS. You can pass a Read to any RxJS method and it will act as if it is a Observable.

ts
import {combineLatest} from 'rxjs';

declare const read: Read<string>;
declare const observable: Observable<number>;

const combined: Observable<number, string> = combineLatest(observable, read);

Source: lib/read.ts:28

Type parameters

ParameterDefaultDescription
T-type of the value
Cancelling extends booleanfalserepresents if the Read is a cancelling Read or not

Implements

  • InteropObservable<T>
  • Subscribable<T>

Constructors

constructor()

new Read<T, Cancelling>(provider: MaybeCancellingReadProvider<T, Cancelling>): Read<T, Cancelling>

Normally you would not create a new Read directly using its constructor, but rather use the existing selector functions like readOf.

If that does not cover your needs you can create a new Read using this constructor. The passed provider will be used as source of the reactive and synchronous values.

Source: lib/read.ts:46

Type parameters

ParameterDefaultDescription
T-type of the value
Cancelling extends booleanfalserepresents if the Read is a cancelling Read or not

Parameters

ParameterTypeDescription
providerMaybeCancellingReadProvider<T, Cancelling>provider to use for reactive and synchronous values

Returns

Read<T, Cancelling>

Properties

provider

readonly provider: MaybeCancellingReadProvider<T, Cancelling>

The provider is the unit which actually provides the reactive and synchronous implementation of a Read. It is normally only used in PipeOperators to directly modify the pipped value.

Source: lib/read.ts:33

Accessors

value

get value(): MaybeUndefined<T, Cancelling>

Source: lib/read.ts:77

Methods

subscribe()

subscribe(observer: Partial<Observer<T>>): Unsubscribable

Subscribe to the reactive value of the Read.

Source: lib/read.ts:65

Parameters

ParameterTypeDescription
observerPartial<Observer<T>>Observer handling the emitted values

Returns

Unsubscribable

Returns a Unsubscribable to cancel the subscription

Implementation of

Subscribable.subscribe

pipe()

pipe<Operators>(...operators: OperatorPipeline<T, Operators>): Read<AnyToUnknown<ReturnTypeOfTailOperator<Operators>>, And<Cancelling | ContainsCancellingPipeOperator<Operators>>>

Create a new Read based on this one by creating a pipeline from the passed PipeOperators and using it to mutated the emitted or synchronously computed value.

⚠️ If any of the PipeOperators in the pipeline is a CancellingPipeOperator, then the new Read will be a cancelling Read. ⚠️

Source: lib/read.ts:93

Type parameters

Parameter
Operators extends PipeOperator<any, any>[]

Parameters

ParameterTypeDescription
...operatorsOperatorPipeline<T, Operators>PipeOperators to use for the pipeline

Returns

Read<AnyToUnknown<ReturnTypeOfTailOperator<Operators>>, And<Cancelling | ContainsCancellingPipeOperator<Operators>>>

Returns a new Read containing the passed pipeline