Lets say I have this hot observable that publishes consecutive numbers every second for 5 minutes:
1, 2, ... n, OnCompleted
At a certain point in time, after the hot observable has started, but before it has completed, I subscribe to it until it completes.
I get numbers: x, x+1, x+2, ... n.
I want to convert the values I received to a cold observable. Is there a special operator for this?
I know I could just use
Observable.Create(observer => hotObservable.Subscribe(onNext, onCompleted, onError);
But I'm sure there's an Rx extension method I'm missing, that does just that
Just use Replay Subject.
ReplaySubject<int> sub = new ReplaySubject<int>();
hotObservable.Subscribe(sub);
//Now any one can subscribe to sub and it will get all items that hot observable sent to replay subject
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With