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

问题描述

标题说明了一切.根据您的经验,这两个框架之间的主要区别是什么?什么时候应该使用另一个?

预期用途:跨平台开发(Windows 8,iOS,Android,WindowsRT,Mac).

解决方案

这是一个老问题,但我想分享我的2美分.

我在同一跨平台解决方案中同时使用MvvmCross和ReactiveUI,适用于iOS,Android和Windows.

我会说我的解决方案基于MvvmCross,因为App类,应用程序如何启动以及ViewModel导航遵循MvvmCross的方式.但是我还使用了ReactiveUI的一些关键功能:

  1. ReactiveCommand

    当绑定到按钮时,我真的很喜欢它的自动禁用功能(CanExecute,IsExecuting).

  2. ReactiveList及其派生列表

    这是我想向编程MVVM的任何人推荐的一类,它解决了我在ObservalbeCollection中几乎所有的痛点.单独使用CreateDerivedCollection本身可能是我在项目中包含ReactiveUI的全部原因.

  3. MessageBus

    恐怕它被自动编组到UI主线程而被宠坏了.我不必担心是否在任务池或UI线程中,只需调用SendMessage. (这与MvvmLight的实现有很大不同,这是我2年前离开MvvmLight的主要原因,对不起)

当我使用上述功能时,我不在乎它们是否具有反应性,我只是使用它们是因为它们非常适合我的需求. (实际上,ReactiveCommandReactiveListMessageBus都是反应性的)

我只能使用ReactiveUI吗?我也问了我自己一个问题.我想我会错过MvvmCross的一些东西:

  1. MvvmCross插件.

    我使用了MvvmCross的几个插件,我真的希望每个插件都与MvvmCross和ReactiveUI兼容. (也许它们已经存在,我只是没有检查,因为我已经在使用MvvmCross来处理插件了.)

  2. MvvmCross的教程

    关于MvvmCross和Youtube视频,有很多教程.我只是无法想象在这些事情上付出了多少努力.

    老实说,我是通过MvvmCross学习Xamarin的.

  3. MvvmCross与Xamarin的集成

    有时我无法分辨MvvmCross或Xamarin是否提供了Mvx前缀所提供的类.我检查了项目,几乎我的UI代码的所有基类都是MvxSomething(我不使用Xamarin.Forms).我不知道Mvx版本的基类到底提供了什么,我只是使用它们并且它们可以工作.

我仍在学习这两个框架,但我希望它们可以在一天之内合并.

Title says it all. Based on your experience, what's the key difference between both frameworks?.When we should use one over the other?.

Intended use: cross-platform development (Windows 8, iOS, Android, WindowsRT, Mac).

解决方案

This is an old question but I'd like to share my 2 cents.

I use both MvvmCross and ReactiveUI, in the same cross-platform solution, for iOS, Android, and Windows.

I would say my solution is based on MvvmCross because the App class, how the app starts up, and ViewModel navigation are following MvvmCross' way. But I also use several of ReactiveUI's key features:

  1. ReactiveCommand

    I really like its auto disabling feature (CanExecute, IsExecuting) when it's bound to a button.

  2. ReactiveList and it's derived list

    This is a class that I would like to recommend to anyone programming MVVM, it has solved almost all my pain points in ObservalbeCollection. The usage of CreateDerivedCollection itself alone can be the whole reason that I include ReactiveUI in my project.

  3. MessageBus

    I'm afraid that I was spoiled by its auto marshaling to UI main thread. I don't need to worry if I'm in a task pool or UI thread, I just call SendMessage. (This is very different from MvvmLight's implementation and it's the main reason I left MvvmLight 2 years ago, sorry)

When I use the features above, I don't care if they're reactive or not, I just use them because they fit my needs very well. (In fact, ReactiveCommand, ReactiveList, and MessageBus are all reactive)

Can I use ReactiveUI only? I also asked the question to myself. I guess I will miss something from MvvmCross:

  1. MvvmCross Plugins.

    I use several plugins from MvvmCross and I really want each plugin is compatible with both MvvmCross and ReactiveUI. ( Maybe they already are, I just didn't check because I'm already using MvvmCross to handle the plugins.)

  2. MvvmCross's tutorials

    There are a lot of tutorial on MvvmCross and Youtube videos. I just can't image how much effort is put on those kinds of things.

    I learn Xamarin by MvvmCross, to be honest.

  3. MvvmCross's integration with Xamarin

    Sometimes I can't tell if a class is provided by MvvmCross or Xamarin if not for the Mvx prefix. I checked my project, almost all the base classes of my UI code are MvxSomething (I don't use Xamarin.Forms). I don't know what exactly are provided by the Mvx version of the base classes, I just use them and they work.

I'm still learning both of the 2 frameworks, but I wish they can be merged one day.

这篇关于ReactiveUI与MvvmCross的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 03:02