ReactiveUI (RxUI) 与 Reactive 扩展 [英] ReactiveUI (RxUI) vs Reactive Extensions

查看:52
本文介绍了ReactiveUI (RxUI) 与 Reactive 扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

ReactiveUI 是一个 MVVM 框架,允许您使用 Reactive.NET 的扩展,用于创建优雅的、可测试的用户界面在任何移动或桌面平台上运行.

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 有什么不同吗?

Is RxUI somehow differs from Reactive Extensions?

为什么我应该更喜欢 RxUI 而不是 MVMCross/light+Rx?有什么特别的?RxUI 可以做一些 Rx 不能做的事情吗?是不是更简洁?是不是更舒服?

Why should I prefer RxUI over MVVMCross/light+Rx? What so special? Can RxUI do something that Rx can't? Is it more concise? Is it more cozy?

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

I saw example on github page https://github.com/reactiveui/ReactiveUI#a-compelling-example. But can't I do the same with just Rx?

附言某处有 API 文档吗?

P.S. Is there API doc somewhere?

推荐答案

你在这里提出了很多问题,所以我会一一回答.

You have included here lots of questions, so I'll answer them one by one.

RxUI 与 Reactive Extensions 有什么不同吗?

Is RxUI somehow differs from Reactive Extensions?

是的.Reactive Extensions一个使用可观察序列和 LINQ 编写异步和基于事件的程序的库-样式查询运算符." 它与 UI 没有任何关系.Rx 为您提供了对数据流的一般抽象.

Yes. Reactive Extensions is "a library for composing asynchronous and event-based programs by using observable sequences and LINQ-style query operators." It has nothing to do with UI specifically. Rx provides you a general abstraction over a stream of data.

RxUI 是一个 MVVM 框架,这意味着 它是一个类库,可帮助您在应用中实现 MVVM 模式.

RxUI is an MVVM framework, which means it is a library of classes helping you implement MVVM pattern in your app.

RxUI 能做一些 Rx 不能做的事吗?是不是更简洁?是不是更舒服?

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

它有不同的用途.Rx 提供了一组方法,它们通常可以帮助您移动应用程序中的数据.RxUI 用于创建用户界面.它在幕后使用 Rx,并公开 Rx 类型的 API(即 IObservable) 来自它的组件.

It serves a different purpose. Rx provides a set of methods, which are generally helping you move the data in your app around. RxUI is used to create User Interfaces. It uses Rx under the hood, and also exposes Rx-type API (namely, IObservable<T>) from it's components.

例如,ICommand 在 ReactiveUI 中的实现,称为 ReactiveCommand,公开了一个名为 ThrownException 的属性,其类型为 IObservable(您可以将其读作一系列错误").

For example, an ICommand implementation in ReactiveUI, called ReactiveCommand, exposes a property called ThrownException, which is of type IObservable<Exception> (you can read it as "a sequence of errors").

请注意,虽然 IObservable 接口类型是 .Net 基类库的一部分,但实际上所有使用此类型操作的有用函数都包含在 Reactive Extensions 库中.

Note that while the IObservable<T> interface type is part of the .Net Base Class Library, literally all the useful functions operating with this type are included in the Reactive Extensions library.

但是我不能只用 Rx 做同样的事情吗?

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

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

No, because - for instance - Rx does not provide you with an ICommand implementation, a vital part of every MVVM framework.

为什么我应该更喜欢 RxUI 而不是 MVMCross/light+Rx?有什么特别的?

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

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

If you want to use Reactive Extensions a lot in your app, you might prefer to use RxUI (rather than other MVVM framework) because they integrate really well with each other. Combined, they provide you with a lot of functionality out of the box (check out, for example, ReactiveCommand or WhenAny.

话虽如此,正如 RxUI 的创建者所说:

您可以将 ReactiveUI 与其他 MVVM 框架一起使用,您无需承诺其中之一.RxUI 中的许多方法(例如 WhenAny)适用于任何对象,并在运行时确定如何最好地连接到它们.

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 绝对是自助餐桌(吃你想要的!),而不是七道菜:)

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

最后:

附言某处有 API 文档吗?

P.S. Is there API doc somewhere?

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

附带说明,请随意浏览文档的反应式编程部分,这将向您解释框架背后的一些基本术语和概念:)

As a side note, feel free to browse Reactive Programming section of the docs, which will explain you some of the basic terminology and concepts standing behind the framework :)

这篇关于ReactiveUI (RxUI) 与 Reactive 扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆