ReactiveUI (RxUI) 与响应式扩展

ReactiveUI (RxUI) vs Reactive Extensions

来自 http://docs.reactiveui.net/en/index.html :

ReactiveUI is a MVVM framework that allows you to use the Reactive Extensions for .NET to create elegant, testable User Interfaces that run on any mobile or desktop platform.

RxUI 与 Reactive Extensions 有什么不同吗?

为什么我更喜欢 RxUI 而不是 MVVMCross/light+Rx?有什么特别的? RxUI 可以做 Rx 做不到的事情吗? 是不是更简洁? 是不是更惬意了?

我在 github 页 https://github.com/reactiveui/ReactiveUI#a-compelling-example 上看到示例。但是我不能只用 Rx 做同样的事情吗?

P.S。某处有 API 文档吗?

你提的问题很多,我一一解答。

Is RxUI somehow differs from Reactive Extensions?

是的。 Reactive Extensions“一个使用可观察序列和 LINQ-style 查询运算符组合异步和 event-based 程序的库。” 它与 UI 具体来说。 Rx 为您提供了对数据流的一般抽象。

RxUI是一个MVVM框架,也就是说it is a library of classes helping you implement MVVM pattern in your app.

Can RxUI do something that Rx can't? Is it more concise? Is it more cozy?

它有不同的用途。 Rx 提供了一组方法,通常可以帮助您移动应用程序中的数据。 RxUI 用于创建用户界面。它在引擎盖下使用 Rx,并且还从它的组件中公开 Rx-type API(即 IObservable<T>)。

例如,ICommand implementation in ReactiveUI, called ReactiveCommand, exposes a property called ThrownException,类型为IObservable<Exception>(您可以将其理解为“错误序列”)。

请注意,虽然 IObservable<T> 接口类型是 .Net Base Class 库的一部分,但实际上所有使用此类型运行的有用函数都包含在 Reactive Extensions 库中。

But can't I do the same with just Rx?

不,因为 - 例如 - Rx 不为您提供 ICommand 实现,这是每个 MVVM 框架的重要组成部分。

Why should I prefer RxUI over MVVMCross/light+Rx? What so special?

如果您想在您的应用程序中大量使用 Reactive Extensions,您可能更喜欢使用 RxUI(而不是其他 MVVM 框架),因为它们彼此集成得非常好。结合起来,它们为您提供了许多开箱即用的功能(例如,查看 ReactiveCommand or WhenAny.

也就是说,as the creator of RxUI stated it:

you can use ReactiveUI alongside other MVVM frameworks, you don't need to commit to one or the other. Many methods in RxUI such as WhenAny work on any object and determine at runtime how to best connect to them.

RxUI is definitely a Buffet Table (take what you want!), not a seven-course meal :)

最后:

P.S. Is there API doc somewhere?

是的!看这里:https://reactiveui.net/api/

作为旁注,请随意浏览 Reactive Programming section of the docs,它将向您解释框架背后的一些基本术语和概念:)