2

I encountered an RX method that I have not seen before and went to MSDN to take a look at any documentation that there may be.

The method was

public static IObservable<IList<TSource>> CombineLatest<TSource> (this IEnumerable<Iobservable<TSource>> sources)

I am familiar with a CombineLatest that takes an Observable as a parameter and a transform function and returns an Observable.

Unfortunately MSDN only has a page for "Observable.CombineLatest<TFirst, TSecond, TResult> Method".

Am I looking in the wrong place or am I missing a better place to see RX API documentation, other than MSDN?

Flack
  • 5,727
  • 14
  • 69
  • 104

1 Answers1

4

The MDSN documentation is awful. The two best sites I have found are http://introtorx.com and http://reactivex.io. Neither site though has info on that overload. :)

Basically once each observable has emitted a value, then combine latest emits a new list every time one of the streams emits one. The list contents are a list of the latest values from each of the child streams. If a stream completes, that value is propagated forever. If a stream errors, the combined stream errors.

You can run the following in LinqPad to demonstrate what it does:

var letters = new Subject<string>();
var numbers = new Subject<string>();

var observables = new IObservable<string>[] { letters, numbers };
var combineLatest = observables.CombineLatest();
combineLatest.Dump("CombineLatest");

numbers.OnNext("0");
numbers.OnNext("1");
letters.OnNext("A");
letters.OnNext("B");
numbers.OnNext("2");
letters.OnNext("C");
letters.OnNext("D");
numbers.OnCompleted();
letters.OnNext("E");
letters.OnError(new Exception());

Marble diagram:

Letters: ------A--B-----C--D-----E--x
Numbers: 0--1--------2--------|
--------
Combine: ------A1-B1-B2-C2-D2----E2-x
Shlomo
  • 14,102
  • 3
  • 28
  • 43