简体   繁体   English

的IObservable <T> .NET Framework 4.0 Beta2中

[英]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. IObservable<T>IObserver<T>接口直接放置在.NET Framework 4.0 Beta2的System名称空间中。 Why not in System.Collections.Generic , like IEnumerable<T> ? 为什么不在System.Collections.Generic ,例如IEnumerable<T>

ps Reactive Framework preview from Silverlight Toolkit contains IObserver<T> in the System.Collections.Generic namespace. 来自Silverlight Toolkit的ps Reactive Framework预览在System.Collections.Generic命名空间中包含IObserver<T>

IObservable is an interface that identifies a class that implements the Observer pattern. IObservable是一个接口,用于标识实现观察者模式的类。 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). 新的IObservable / IObserver接口描述的是比集合高得多的抽象,集合可以看作是计算的特例(这就是Haskell中的列表为monad的原因)。 So it's obvious that such generalization is placed to System namespace. 因此,很明显,这种概括是放置在System名称空间中的。

Take a look at this brilliant cast from Erik Meijer where he describes the ideas behind the interfaces. 看看Erik Meijer的精彩作品 ,他描述了界面背后的想法。

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. 尽管这是我偶然发现的一个老问题,但我只想支持@ControlFlow对IObservable和IEnumerable之间的“二元论”的评估,将其作为“基于推送”与“基于拉”的集合,并链接到Erik Meijer的“ 15分钟内的Rx” ”,可以引用他的话。 http://channel9.msdn.com/posts/Charles/Erik-Meijer-Rx-in-15-Minutes/ 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. 那些属于核心BCL名称空间的东西,或者应该属于它自己的东西,但是远远超出了Yet-Another-Collection,无法共享其名称空间。 Mind you, that's just my opinion. 提醒您,那只是我的意见。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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