Rx operators do not themselves have side effects, but at times, using an Rx object will have a side effect. For example, if we create an
IObservable with a COM object, when we subscribe we may add a COM
addref, and when we unsubscribe we might end up releasing that COM object. Worse, the effect is different if we have two subscribers than if we have one.
This problem can be eliminated using the
Publish methods. These methods return a a Connectable
Observable that shares a subscription to the underlying source.
The following example demonstrates how side effects can sneak into even a simple program. It uses a Hot Observable (remember, that's a single event-stream), with explicit, ...