Table of Contents

Class ObservableCombinators

Namespace
Bonsai
Assembly
Bonsai.Core.dll

Provides a set of static methods to aid in writing queries over observable sequences.

public static class ObservableCombinators
Inheritance
ObservableCombinators
Inherited Members

Methods

Gate<TSource>(IObservable<TSource>, TimeSpan)

Allows a single element from an observable sequence to pass through every time the specified time interval elapses.

public static IObservable<TSource> Gate<TSource>(this IObservable<TSource> source, TimeSpan interval)

Parameters

source IObservable<TSource>

The observable sequence to filter.

interval TimeSpan

The time interval after which a new element of the sequence is allowed to pass through the gate.

Returns

IObservable<TSource>

The filtered observable sequence. Every time the specified time interval elapses, the next element from the source sequence will be allowed through.

Type Parameters

TSource

The type of the elements in the source sequence.

Gate<TSource>(IObservable<TSource>, TimeSpan, IScheduler)

Allows a single element from an observable sequence to pass through every time the specified time interval elapses, using the specified scheduler to run gate timers.

public static IObservable<TSource> Gate<TSource>(this IObservable<TSource> source, TimeSpan interval, IScheduler scheduler)

Parameters

source IObservable<TSource>

The observable sequence to filter.

interval TimeSpan

The time interval after which a new element of the sequence is allowed to pass through the gate.

scheduler IScheduler

The scheduler to run the gate timer on.

Returns

IObservable<TSource>

The filtered observable sequence. Every time the specified time interval elapses, the next element from the source sequence will be allowed through.

Type Parameters

TSource

The type of the elements in the source sequence.

Gate<TSource, TGateOpening>(IObservable<TSource>, IObservable<TGateOpening>)

Allows a single element from an observable sequence to pass through every time a second sequence emits a notification.

public static IObservable<TSource> Gate<TSource, TGateOpening>(this IObservable<TSource> source, IObservable<TGateOpening> gateOpenings)

Parameters

source IObservable<TSource>

The observable sequence to filter.

gateOpenings IObservable<TGateOpening>

The sequence of gate opening events.

Returns

IObservable<TSource>

The filtered observable sequence. Every time the gateOpenings sequence produces a notification, the next element from the source sequence will be allowed through.

Type Parameters

TSource

The type of the elements in the source sequence.

TGateOpening

The type of the elements in the gateOpenings sequence.

Gate<TSource, TGateOpening>(IObservable<TSource>, IObservable<TGateOpening>, TimeSpan)

Allows an element from an observable sequence to pass through if this element is produced after a gate opening event and before the specified due time elapses.

public static IObservable<TSource> Gate<TSource, TGateOpening>(this IObservable<TSource> source, IObservable<TGateOpening> gateOpenings, TimeSpan dueTime)

Parameters

source IObservable<TSource>

The observable sequence to filter.

gateOpenings IObservable<TGateOpening>

The sequence of gate opening events.

dueTime TimeSpan

After receiving a gate event, the maximum time that can elapse before an element from the source sequence is produced. If the element arrives after the due time elapses, that element is dropped from the result sequence.

Returns

IObservable<TSource>

The filtered observable sequence. Every time the gateOpenings sequence produces a notification, the next element from the source sequence will be allowed through if it is emitted before the specified due time elapses.

Type Parameters

TSource

The type of the elements in the source sequence.

TGateOpening

The type of the elements in the gateOpenings sequence.

Gate<TSource, TGateOpening>(IObservable<TSource>, IObservable<TGateOpening>, TimeSpan, IScheduler)

Allows an element from an observable sequence to pass through if this element is produced after a gate opening event and before the specified due time elapses, using the specified scheduler to run gate closing timers.

public static IObservable<TSource> Gate<TSource, TGateOpening>(this IObservable<TSource> source, IObservable<TGateOpening> gateOpenings, TimeSpan dueTime, IScheduler scheduler)

Parameters

source IObservable<TSource>

The observable sequence to filter.

gateOpenings IObservable<TGateOpening>

The sequence of gate opening events.

dueTime TimeSpan

After receiving a gate event, the maximum time that can elapse before an element from the source sequence is produced. If the element arrives after the due time elapses, that element is dropped from the result sequence.

scheduler IScheduler

The scheduler to run the gate closing timer on.

Returns

IObservable<TSource>

The filtered observable sequence. Every time the gateOpenings sequence produces a notification, the next element from the source sequence will be allowed through if it is emitted before the specified due time elapses.

Type Parameters

TSource

The type of the elements in the source sequence.

TGateOpening

The type of the elements in the gateOpenings sequence.

Gate<TSource, TGateOpening, TGateClosing>(IObservable<TSource>, IObservable<TGateOpening>, IObservable<TGateClosing>)

Allows an element from an observable sequence to pass through if this element is produced between a gate opening and gate closing event.

public static IObservable<TSource> Gate<TSource, TGateOpening, TGateClosing>(this IObservable<TSource> source, IObservable<TGateOpening> gateOpenings, IObservable<TGateClosing> gateClosings)

Parameters

source IObservable<TSource>

The observable sequence to filter.

gateOpenings IObservable<TGateOpening>

The sequence of gate opening events.

gateClosings IObservable<TGateClosing>

The sequence of gate closing events.

Returns

IObservable<TSource>

The filtered observable sequence. Every time the gateOpenings sequence produces a notification, the next element from the source sequence will be allowed through if it is emitted before the next notification from the gateClosings sequence.

Type Parameters

TSource

The type of the elements in the source sequence.

TGateOpening

The type of the elements in the gateOpenings sequence.

TGateClosing

The type of the elements in the gateClosings sequence.

MulticastReconnectable<TSource, TResult>(IObservable<TSource>, Func<ISubject<TSource, TResult>>)

Returns a connectable observable sequence that upon connection causes the source to push results into a new fresh subject, which is created by invoking the specified subjectFactory.

public static IConnectableObservable<TResult> MulticastReconnectable<TSource, TResult>(this IObservable<TSource> source, Func<ISubject<TSource, TResult>> subjectFactory)

Parameters

source IObservable<TSource>

The source sequence whose elements will be pushed into the specified subject.

subjectFactory Func<ISubject<TSource, TResult>>

The factory function used to create the subject that notifications will be pushed into.

Returns

IConnectableObservable<TResult>

The reconnectable sequence.

Type Parameters

TSource

The type of the elements in the source sequence.

TResult

The type of the elements in the result sequence.

PublishReconnectable<TSource>(IObservable<TSource>)

Returns a connectable observable sequence that upon connection causes the source to push results into a new fresh Subject<T>.

public static IConnectableObservable<TSource> PublishReconnectable<TSource>(this IObservable<TSource> source)

Parameters

source IObservable<TSource>

The source sequence whose elements will be pushed into the specified subject.

Returns

IConnectableObservable<TSource>

The reconnectable sequence.

Type Parameters

TSource

The type of the elements in the source sequence.

Zip<TSource1, TSource2, TResult>(IObservable<TSource1>, IEnumerable<TSource2>, Func<TSource1, TSource2, TResult>)

Merges an observable sequence and an enumerable sequence into one observable sequence by using the selector function.

public static IObservable<TResult> Zip<TSource1, TSource2, TResult>(this IObservable<TSource1> first, IEnumerable<TSource2> second, Func<TSource1, TSource2, TResult> resultSelector)

Parameters

first IObservable<TSource1>

The first observable source.

second IEnumerable<TSource2>

The second enumerable source.

resultSelector Func<TSource1, TSource2, TResult>

The function to invoke for each consecutive pair of elements from the first and second source.

Returns

IObservable<TResult>

An observable sequence containing the result of pairwise combining the elements of the first and second source using the specified result selector function.

Type Parameters

TSource1

The type of the elements in the first observable source sequence.

TSource2

The type of the elements in the second observable source sequence.

TResult

The type of the elements in the result sequence, returned by the selector function.