0
var x = Observable.Return(1)
    .Do(_ => Console.WriteLine("creating"))
    .Replay()
    .RefCount();
x.Subscribe(); //first subscription
x.Subscribe(); //second subscription

Result:

creating
creating

The "creating" is supported to be print only once here.

But the first subscription seems get disposed before the second subscription starting , the reference count go back to zero and the Replay disconnected.

So what's the correct way to use the RefCount in a situation that we don't know how soon our source will get completed and we want to subscribe it multiple times?

Junru Zhu
  • 76
  • 6

0 Answers0