I'm using IDisposable
along with CompositeDisposable
to clean up my Reactive Extension (Rx) Observers in my ViewModels.
What's the proper implementation for IDisposable
in my ViewModels in this scenario? Typically, I wouldn't implement a finalizer since there aren't unmanaged objects, but it seems that the finalizer might be useful to catch any missed calls to Dispose
and thus ensure that my Observers are always disposed. (My Observable is instantiated for the lifetime of the application, while the ViewModels are not.)
Thanks!
Update:
Some clarification: The need for the call to Dispose is a little different in this case. The Observer in Reactive Extensions uses Dispose to unsubscribe itself from the Observable. In my case, I have a long-lived Observer with many short-lived Observers and thus the Observers won't be GC unless explicitly Disposed due to the Observable->Observer reference. I'm completely new to Reactive Extensions, so I may be mistaken in my understanding.