Table of Contents

Class CombineLatest

Namespace
Bonsai.Reactive
Assembly
Bonsai.Core.dll

Represents an operator that combines values from the source sequences whenever any of the sequences produces an element.

Marble diagram

CombineLatest combines the values from each sequence which are closest in time. Whenever any of the source sequences emits a value (as long as all source sequences have emitted at least one value), CombineLatest takes the most recently emitted values from all other sequences and creates the combined result. CombineLatest will continue to emit values as long as at least one source sequence remains active (i.e. without terminating).

CombineLatest can be useful to temporally correlate separate sources (e.g. frames from different cameras, or the closest frame to a key press). It can also be useful when combining a sequence containing a single reference value with a possibly infinite sequence of values to be associated with the reference (e.g. subtracting a background from every frame).

Warning

Because CombineLatest emits a combined value whenever any of the source sequences emits a new value, the number of values emitted by CombineLatest is approximately the sum of the number of values in each sequence. If you need to discard redundant values you can filter the output, e.g. using Sample to use one of the source sequences as a master driver.

Higher-order operator

CombineLatest also works as a higher-order operator, so it can take as input a sequence of observable sequences. In this case, it will subscribe to each of the source sequences and start collecting all the latest values from each sequence. As soon as the outer sequence terminates, it will start reactively combining the latest values whenever any sequence changes, just as in the case of using CombineLatest with a fixed number of inputs.

Higher order

[Combinator]
public class CombineLatest
Inheritance
CombineLatest
Inherited Members

Methods

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

Merges elements from all inner observable sequences into one observable sequence by emitting a list with the elements of each sequence whenever any of the sequences produces a notification.

public IObservable<IList<TSource>> Process<TSource>(IObservable<IObservable<TSource>> sources)

Parameters

sources IObservable<IObservable<TSource>>

The observable sequence of inner observable sequences.

Returns

IObservable<IList<TSource>>

An observable sequence containing the result of combining the latest elements of the inner sequences into lists.

Type Parameters

TSource

The type of the elements in the source sequences.

Process<TSource>(IObservable<TSource>, IObservable<TSource>, params IObservable<TSource>[])

Merges the specified sources into one observable sequence by emitting a list with the latest source elements whenever any of the observable sequences produces a notification.

public IObservable<IList<TSource>> Process<TSource>(IObservable<TSource> first, IObservable<TSource> second, params IObservable<TSource>[] remainder)

Parameters

first IObservable<TSource>

The first observable sequence.

second IObservable<TSource>

The second observable sequence.

remainder IObservable<TSource>[]

The remaining observable sequences to combine.

Returns

IObservable<IList<TSource>>

An observable sequence containing the result of combining the latest elements of the sources into lists.

Type Parameters

TSource

The type of the elements in the source sequences.

Process<TSource1, TSource2>(IObservable<TSource1>, IObservable<TSource2>)

Merges the specified sources into one observable sequence by emitting a pair with the latest source elements whenever any of the observable sequences produces a notification.

public IObservable<Tuple<TSource1, TSource2>> Process<TSource1, TSource2>(IObservable<TSource1> source1, IObservable<TSource2> source2)

Parameters

source1 IObservable<TSource1>

The first observable source.

source2 IObservable<TSource2>

The second observable source.

Returns

IObservable<Tuple<TSource1, TSource2>>

An observable sequence containing the result of combining the latest elements of the sources into pairs.

Type Parameters

TSource1

The type of the elements in the first source sequence.

TSource2

The type of the elements in the second source sequence.

Process<TSource1, TSource2, TSource3>(IObservable<TSource1>, IObservable<TSource2>, IObservable<TSource3>)

Merges the specified sources into one observable sequence by emitting a triple with the latest source elements whenever any of the observable sequences produces a notification.

public IObservable<Tuple<TSource1, TSource2, TSource3>> Process<TSource1, TSource2, TSource3>(IObservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3)

Parameters

source1 IObservable<TSource1>

The first observable source.

source2 IObservable<TSource2>

The second observable source.

source3 IObservable<TSource3>

The third observable source.

Returns

IObservable<Tuple<TSource1, TSource2, TSource3>>

An observable sequence containing the result of combining the latest elements of the sources into triples.

Type Parameters

TSource1

The type of the elements in the first source sequence.

TSource2

The type of the elements in the second source sequence.

TSource3

The type of the elements in the third source sequence.

Process<TSource1, TSource2, TSource3, TSource4>(IObservable<TSource1>, IObservable<TSource2>, IObservable<TSource3>, IObservable<TSource4>)

Merges the specified sources into one observable sequence by emitting a quadruple with the latest source elements whenever any of the observable sequences produces a notification.

public IObservable<Tuple<TSource1, TSource2, TSource3, TSource4>> Process<TSource1, TSource2, TSource3, TSource4>(IObservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4)

Parameters

source1 IObservable<TSource1>

The first observable source.

source2 IObservable<TSource2>

The second observable source.

source3 IObservable<TSource3>

The third observable source.

source4 IObservable<TSource4>

The fourth observable source.

Returns

IObservable<Tuple<TSource1, TSource2, TSource3, TSource4>>

An observable sequence containing the result of combining the latest elements of the sources into quadruples.

Type Parameters

TSource1

The type of the elements in the first source sequence.

TSource2

The type of the elements in the second source sequence.

TSource3

The type of the elements in the third source sequence.

TSource4

The type of the elements in the fourth source sequence.

Process<TSource1, TSource2, TSource3, TSource4, TSource5>(IObservable<TSource1>, IObservable<TSource2>, IObservable<TSource3>, IObservable<TSource4>, IObservable<TSource5>)

Merges the specified sources into one observable sequence by emitting a quintuple with the latest source elements whenever any of the observable sequences produces a notification.

public IObservable<Tuple<TSource1, TSource2, TSource3, TSource4, TSource5>> Process<TSource1, TSource2, TSource3, TSource4, TSource5>(IObservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5)

Parameters

source1 IObservable<TSource1>

The first observable source.

source2 IObservable<TSource2>

The second observable source.

source3 IObservable<TSource3>

The third observable source.

source4 IObservable<TSource4>

The fourth observable source.

source5 IObservable<TSource5>

The fifth observable source.

Returns

IObservable<Tuple<TSource1, TSource2, TSource3, TSource4, TSource5>>

An observable sequence containing the result of combining the latest elements of the sources into quintuples.

Type Parameters

TSource1

The type of the elements in the first source sequence.

TSource2

The type of the elements in the second source sequence.

TSource3

The type of the elements in the third source sequence.

TSource4

The type of the elements in the fourth source sequence.

TSource5

The type of the elements in the fifth source sequence.

Process<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6>(IObservable<TSource1>, IObservable<TSource2>, IObservable<TSource3>, IObservable<TSource4>, IObservable<TSource5>, IObservable<TSource6>)

Merges the specified sources into one observable sequence by emitting a sextuple with the latest source elements whenever any of the observable sequences produces a notification.

public IObservable<Tuple<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6>> Process<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6>(IObservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6)

Parameters

source1 IObservable<TSource1>

The first observable source.

source2 IObservable<TSource2>

The second observable source.

source3 IObservable<TSource3>

The third observable source.

source4 IObservable<TSource4>

The fourth observable source.

source5 IObservable<TSource5>

The fifth observable source.

source6 IObservable<TSource6>

The sixth observable source.

Returns

IObservable<Tuple<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6>>

An observable sequence containing the result of combining the latest elements of the sources into sextuples.

Type Parameters

TSource1

The type of the elements in the first source sequence.

TSource2

The type of the elements in the second source sequence.

TSource3

The type of the elements in the third source sequence.

TSource4

The type of the elements in the fourth source sequence.

TSource5

The type of the elements in the fifth source sequence.

TSource6

The type of the elements in the sixth source sequence.

Process<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7>(IObservable<TSource1>, IObservable<TSource2>, IObservable<TSource3>, IObservable<TSource4>, IObservable<TSource5>, IObservable<TSource6>, IObservable<TSource7>)

Merges the specified sources into one observable sequence by emitting a septuple with the latest source elements whenever any of the observable sequences produces a notification.

public IObservable<Tuple<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7>> Process<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7>(IObservable<TSource1> source1, IObservable<TSource2> source2, IObservable<TSource3> source3, IObservable<TSource4> source4, IObservable<TSource5> source5, IObservable<TSource6> source6, IObservable<TSource7> source7)

Parameters

source1 IObservable<TSource1>

The first observable source.

source2 IObservable<TSource2>

The second observable source.

source3 IObservable<TSource3>

The third observable source.

source4 IObservable<TSource4>

The fourth observable source.

source5 IObservable<TSource5>

The fifth observable source.

source6 IObservable<TSource6>

The sixth observable source.

source7 IObservable<TSource7>

The seventh observable source.

Returns

IObservable<Tuple<TSource1, TSource2, TSource3, TSource4, TSource5, TSource6, TSource7>>

An observable sequence containing the result of combining the latest elements of the sources into septuples.

Type Parameters

TSource1

The type of the elements in the first source sequence.

TSource2

The type of the elements in the second source sequence.

TSource3

The type of the elements in the third source sequence.

TSource4

The type of the elements in the fourth source sequence.

TSource5

The type of the elements in the fifth source sequence.

TSource6

The type of the elements in the sixth source sequence.

TSource7

The type of the elements in the seventh source sequence.