Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IObservable<T> and INotifyPropertyChanged - is there a connection

I understand the IObservable<T> & IObserver<T> are implementations of the observer pattern and can be used in similar circumstances to .Net events.

I was wondering if there is any relationship to INotifyPropertyChanged?

I currently use INotifyPropertyChanged for data binding in winforms & WPF applications and was wondering if I'll be able to use IObservable in UI data binding scenarios?

Cheers

AWC

like image 579
AwkwardCoder Avatar asked Jan 29 '10 15:01

AwkwardCoder


1 Answers

From what I can gather, there is no relationship. Observers/.NET eventing are two ways of achieving the Observer/Notification style behavior.

Microsoft's answer has been to build on top of the .NET eventing pattern, not deprecate it in favor of manually registered Observer objects.

One of my biggest peeves with events is the inability to clear the delegate chain on demand, which leads to quite a few managed-memory leak scenarios. To this end, Microsoft introduced the concept of weak events, that is, to address the issue of mismatched timelines for Observables/Observers.

You can read more about the WeakEvent pattern here.

Josh Smith has released an implmentation of the WeakEventManager for INotifyPropertyChanged here. This provides a safer (from a memory-standpoint) way of hooking up objects which change properties, and their Observers.

like image 144
micahtan Avatar answered Sep 29 '22 15:09

micahtan