Rx framework – IObservable<T>.Concat

Yet another extension method to combine two observable collections, this time we have IObservable<T>.Concat which is very similar to IObservable<T>.Merge, but crucially, when you concatenate one observable collection to another, the subscription to the second observable collection happens after the first had completed! Here’s a quick illustration of how the two methods differ:

image

As you’ve probably guessed already, the Concat method requires the observable collections to be merged to be of the same type.

Again, you can either invoke it as an extension method:

var zs = xs.Concat(ys);

or you can invoke it as static method on more than two observable collections:

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


Yan Cui

I’m an AWS Serverless Hero and the author of Production-Ready Serverless. I have run production workload at scale in AWS for nearly 10 years and I have been an architect or principal engineer with a variety of industries ranging from banking, e-commerce, sports streaming to mobile gaming. I currently work as an independent consultant focused on AWS and serverless.

You can contact me via Email, Twitter and LinkedIn.

Hire me.