At the end of the day, all of the IObservable objects are being held via the list of subscribers on Events.GetStream
(depending on your implementation of Events.GetStream
, of course). Whether this goes out of scope depends on your implementation.
However, holding the IDisposable
almost certainly keeps the subscription in scope as well, so even if your implementation was return Observable.Never<OutgoingByteMessage>
, it would still exist because of the IDisposable
.
You usually don't have to worry about active subscriptions going out of scope - the thing you should worry instead about is, subscription leaks. These occur when you subscribe to a global object (like something returned from an IoC container) and don't disconnect the subscription (and if the Observable never terminates).
This sounds like it'd not happen often, but it comes up more than you'd expect. For example:
MessageBus.Current.Listen<FooMessage>()
.Where(x => x.Bar == "Baz")
.Subscribe(x => Console.WriteLine(x));
If I put that in a constructor of some object that gets created all the time, I create dozens of subscriptions that never get cleaned up.