Table of Contents

Class Switch

Namespace
Bonsai.Reactive
Assembly
Bonsai.Core.dll

Represents an operator that transforms a sequence of observable sequences into a sequence of values produced only from the most recent observable sequence.

Marble diagram

Switch is a higher-order operator, so it takes as input a sequence of observable sequences. At any moment Switch is subscribed exclusively to the latest source sequence. As soon as a new sequence is emitted by the outer observable, it cancels subscription to the previous sequence and subscribes to the new sequence.

The resulting sequence will terminate successfully when the outer sequence has terminated successfully, and the currently active sequence (if any) also terminates successfully. It will terminate exceptionally if any of the sequences produces an error.

Switch is useful to model interruptible states, for example when transitioning between different modes of a state-machine, or switching between different video channels on demand.

[Combinator]
public class Switch
Inheritance
Switch
Inherited Members

Methods

Process<TSource>(IObservable<IObservable<TSource>>)

Transforms a sequence of observable sequences into a sequence of values produced only from the most recent observable sequence.

public IObservable<TSource> Process<TSource>(IObservable<IObservable<TSource>> source)

Parameters

source IObservable<IObservable<TSource>>

A sequence of observable sequences.

Returns

IObservable<TSource>

An observable sequence that at any point produces values only from the most recent observable sequence that has been received.

Type Parameters

TSource

The type of the elements in the source sequences.