ReactiveUI (RxUI) vs Reactive Extensions
Asked Answered
T

1

24

From 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.

Is RxUI somehow differs from Reactive Extensions?

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?

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

P.S. Is there API doc somewhere?

Tortuous answered 11/1, 2016 at 17:29 Comment(0)
K
40

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

Is RxUI somehow differs from Reactive Extensions?

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 is an MVVM framework, which means 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?

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.

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").

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.

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

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

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

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.

That being said, 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 :)

And, finally:

P.S. Is there API doc somewhere?

Yes there is! Take a look here: 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 :)

Kevenkeverian answered 11/1, 2016 at 19:56 Comment(6)
Is RxUI implemenetation of asynchronicity slower than async/await ? I plan to use it on Android devices, so this could matter...Tortuous
Well, it is really hard/impossible to answer a question stated like that (see ericlippert.com/2012/12/17/performance-rant to get to know why!). Also, did you mean Rx implementation of asynchronicity? Because RxUI does not implement anything like that. Moreover, RxUI interoperates with both Rx and TPL (aka async await) very nicely.Kevenkeverian
no, I rather meant async/await (which happens on the same thread) vs new Thread start. I actually don't know how this implemented in Rx. But I know that async/await is as fast as it can be... And synchronization between threads can take a lot of CPU time.Tortuous
Take a look at reactivex.io/documentation/scheduler.html to see how Rx handles multithreading. You may also want to ask a separate question, because this topic is somewhat complicated.Kevenkeverian
I read your link and introtorx.com/Content/v1.0.10621.0/… . So, by default, in RxUI, Subscribers will be executed on Renderer thread (for example button click, etc..)?Tortuous
This is really a good question, and you should ask it as a separate one, not as a comment :) I'll just hint you - Rx is single-threaded by default, so by default subscribe will execute on whichever thread you push data into a sequence. Note that from now on, I'll only answer the questions related to RxUI vs Rx difference, in order to follow SO guidelines regarding comment discussions (see stackoverflow.com/help/privileges/comment) :)Kevenkeverian

© 2022 - 2024 — McMap. All rights reserved.