Given a sequence, IObservable<int> source;
, is there a difference between:
var published = source.Publish(0);
var publishedConnection = published.Connect();
and
var replayed = source.StartWith(0).Replay(1);
var replayedConnection = replayed.Connect();
As far as I'm aware, they're very similar. They both have a default value of zero, on subscription, the observer will immediately receive the last value from source
, and all further values from source
are pushed out to the subscriber.
I have a vague inkling that I read somewhere (which I can't find now) that if source
were to complete, published
would not pass any value to new subscribers, but instead complete immediately, whereas replayed
would still replay the last value to new subscribers before completing.
Have I remembered this correctly (and can anyone find a source stating so), and are there any other differences between these two methods?