views:

143

answers:

1

hi all,

Well, MS introduced the IObservable interface as part of the .net FW 4 and i thought "great finally, i must use it !".

So i dug deep and read posts and documentation and even implemented the pattern.

After doing so i've realized that the basic implementation actually sends all the Observable events to all of its subscribers without any filtering on it (plain broadcast).

Now to the question,

1. now if i add such filtering mechanism what is the difference between using the Observable pattern and just using events ?

2. When should one use this pattern and when should he choose to use plain events ?

3. what are the main advantages of the Observable pattern ?

i read somewhere that the Observable is meant for plain broadcast, i feel it is not true and that im missing something.

thanks alot. adiel.

+4  A: 

Observable is the cornerstone of the Rx library. They provide pretty much all the implementations and operators you'll need. The idea behind IObservable<T> and Rx is not just the "handling" of events, but enabling "LINQ to Events." So you can easily compose "event streams," which gives you a lot of power compared to regular event handling.

Note that the sample MSDN implementation of IObservable<T> is incorrect; the doc team has been notified.

Stephen Cleary
hi thanks for your reply,could you please elaborate more about " enabling "LINQ to Events." So you can easily compose "event streams" or give an example ?adiel.
Adiel
The [Rx wiki page](http://rxwiki.wikidot.com/101samples#toc15) has several LINQ to Events kinds of examples. There's also the famous "drag and drop" [video](http://channel9.msdn.com/posts/J.Van.Gogh/Writing-your-first-Rx-Application/).
Stephen Cleary