Silverlight ObservableCollection v. .NET 反应式扩展 (Rx)
我想我在这里遗漏了一些东西,但我刚刚阅读了 杰西·自由 关于 .Net 的反应式扩展。他的示例是使用 Silverlight 的 Window Phone 7,但 Silverlight 也有 ObservableCollection 数据类型。所以我想弄清楚有什么区别......也许 Rx 更强大?
谁能比较和对比这些?我什么时候会使用其中一种而不是另一种?
谢谢
I figure I'm missing something here but I was just reading this article by jesse liberty regarding Reactive Extensions for .Net. His example is for Window Phone 7 using Silverlight, but Silverlight also has an ObservableCollection data type. So I'm trying to figure out what the difference ... perhaps the Rx is more powerful?
Can anyone compare and contrast these? When would I use one over the other?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
ObservableCollection 和 RX 只有一个共同点 - 单词 Observable。
就是这样。
ObservableCollection 是一个面向 UI 的类,它实现了 INotifyCollectionChanged。
Reactive Extensions 是一个围绕 IObservable 和 IObserver 接口构建的库,这些接口与 UI 没有直接关系(以为可以在 UI 场景中成功使用)。
ObservableCollection and RX have only one thing in common - the word Observable.
That's it.
ObservableCollection is an UI-oriented class that implements INotifyCollectionChanged.
Reactive Extensions is a library built around the IObservable and IObserver interfaces, which are not directly related to the UI (thought it can be used successfully in UI scenarios).
这是一个不幸的名字,但这是一个在 Silverlight 意义上和 Rx.NET 意义上都是 Observable 的集合:
https://github.com/xpaulbettsx/ReactiveUI/blob/master/ReactiveUI/ReactiveCollection.cs
例如:
此类是 ReactiveUI,这是一个与 Rx.NET 集成的 MV-VM 框架(全面披露:我写的)
It's an unfortunate name, but here's a collection that is both Observable in the Silverlight sense, as well as the Rx.NET sense:
https://github.com/xpaulbettsx/ReactiveUI/blob/master/ReactiveUI/ReactiveCollection.cs
For example:
This class is part of ReactiveUI, which is an M-V-VM framework that integrates with Rx.NET (full disclosure: I wrote it)