Create hot observable in Rx from array

c#, reactive-programming, system.reactive

Solution

You would need to do something like this:

new int[] { 1, 2, 3, }
    .ToObservable()
    .Concat(Observable.Never<int>())
    .Subscribe(myObserver); 

new int[] { 4, 5, 6, }
    .ToObservable()
    .Concat(Observable.Never<int>())
    .Subscribe(myObserver);

The key is to do a `.Concat(Observable.Never<int>())` on the observable to prevent it ever ending.

Problem

How can I do this? I have a code that does: ``` new int[]{1,2,3}.ToObservable().Subscribe(myObserver); ``` The problem is this first call is a cold observable so that on another call like this: ``` new int[]{4,5,6}.ToObservable().Subscribe(myObserver); ``` myObserver does not trigger onNext at all. Apparently because the first call publishes `1,2,3, END`. I don't want the observable to call "END", because I want to continue subscribing later on. Is there a function that easily does this for me?

Original source