Skip to content

Advanced Anatomy

Disposing

Reactives can be disposed. When disposed, they are rendered inoperable, meaning they can’t emit data nor can they be subscribed to etc. A reactive might do ‘clean up’ operations when disposed. For example, if a reactive is based on an DOM event, it will unsubscribe from the source. This can be useful when resource-intensive sources are being used.

The definiteness of disposal is also useful for catching bugs in your code - using an object which ought not to be.

Variations

There are several variations of the base type Type Rx.Reactive type.

Type Rx.ReactiveStream
type ReactiveStream<T> = Reactive<T> & ReactiveWritable<T> & {
removeAllSubscribers(): void;
signal(signal: SignalKinds, context?: string): void;
}

ReactiveStream is a controllable reactive, allowing you to nuke all subscribers or to inject a signal.

Type Rx.ReactiveInitial has an initial value:

type ReactiveStream<T> = Reactive<T> {
last():T
}

Use Rx.hasLast to check if a reactive has a last value.