简体   繁体   中英

IObservable<T> in .NET Framework 4.0 Beta2

IObservable<T> and IObserver<T> interfaces are placed directly in the System namespace in .NET Framework 4.0 Beta2. Why not in System.Collections.Generic , like IEnumerable<T> ?

ps Reactive Framework preview from Silverlight Toolkit contains IObserver<T> in the System.Collections.Generic namespace.

IObservable is an interface that identifies a class that implements the Observer pattern. Its not related to Collections. Its more related to providing an alternative to Events.

The thing that new IObservable/IObserver interfaces describe is an abstraction much higher than just collections which can be seen as a special case of computations (that's why lists in Haskell are monads). So it's obvious that such generalization is placed to System namespace.

Take a look at this brilliant cast from Erik Meijer where he describes the ideas behind the interfaces.

Although this is an old question I stumbled upon, I just wanted to back @ControlFlow's assessment of the 'dualism' between IObservable and IEnumerable as a 'Pushed based' vs 'Pull based' collection with a link to Erik Meijer's 'Rx in 15 Minutes', where he can be quoted as saying exactly that. http://channel9.msdn.com/posts/Charles/Erik-Meijer-Rx-in-15-Minutes/

Consequently, this pushed-based collection can fundamentally shift the basic paradigm of 'a mundane series of called events' into an asynchronous, selectable, query-able, passable and subscribe-able first-class collection of declarative actionable. Something that does that belongs in the core BCL namespace or perhaps deserves it's own, but is too far beyond Yet-Another-Collection to share its namespace. Mind you, that's just my opinion.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM