Rx framework — IObservable<T>.Concat

Yet anoth­er exten­sion method to com­bine two observ­able col­lec­tions, this time we have IObservable<T>.Concat which is very sim­i­lar to IObservable<T>.Merge, but cru­cial­ly, when you con­cate­nate one observ­able col­lec­tion to anoth­er, the sub­scrip­tion to the sec­ond observ­able col­lec­tion hap­pens after the first had com­plet­ed! Here’s a quick illus­tra­tion of how the two meth­ods dif­fer:


As you’ve prob­a­bly guessed already, the Con­cat method requires the observ­able col­lec­tions to be merged to be of the same type.

Again, you can either invoke it as an exten­sion method:

var zs = xs.Concat(ys);

or you can invoke it as sta­t­ic method on more than two observ­able col­lec­tions:

var zs = Observable.Concat(xs, ys, us, vs);

Liked this post? Why not support me on Patreon and help me get rid of the ads!