Xamarin Forms : can Prism and ReactiveUI be used in the same project ? If so, is it a good idea?
Asked Answered
C

2

6

I have been working on a mobile application for one week, for personal education and enhancement. I have some experience with WPF and MVVM, I have no experience with mobile development.

The idea is to make a cross platform application, while testing some coding philosophies :

I plan to use the following components :

  • Prism.Unity.Forms : seems to provide application structure, ioc, navigation, seems widely used, and done by top notch people
  • ReactiveUI, ReactiveUI.XamForms, ReactiveUI.Fody : WhenAnyValue, ObservableAsPropertyAttribute, ReactiveAttribute (tutorial), not using them looks like a huge missed opportunity to me

The current structure of my Visual Studio is the following :

  • Csproj
    • ViewModels
      • CreateExercisePageViewModel
      • HomePageViewModel
    • Views
      • CreateExercisePage
      • HomePage

I managed the following :

  • Set the HomePage as the initial Page, contained inside a NavigationPage, by using the navigation functionalities of Prism.
  • Declare a named button in XAML, set its Command property through a OneWay binding created in code behind, using ReactiveUI functionalities (like shown in the tutorial, using the WhenActivated method)
  • Navigate to the second page (CreateExercisePage), using Prism navigation

One issue is that there are a few articles on the web, that do comparisons between Prism and ReactiveUI (google Prism vs ReactiveUI).

So the question is : Am I doing something wrong by using both at the same time ?

I have no problem for now, but will I run into one ? And even if I don't, does it make sense to use them both at the same time ?

Cephalad answered 12/5, 2019 at 23:38 Comment(0)
E
8

So the question is : Am I doing something wrong by using both at the same time ?

There is no problem using Prism and ReactiveUI together. ReacitveUI is a set of extension methods, rather than an opinionated framework.

I have no problem for now, but will I run into one ?

You may run into issue with property changed events going back and forth between the two frameworks (probably less with Prism than other Mvvm frameworks), but that should be easily resolvable.

And even if I don't, does it make sense to use them both at the same time ?

I generally say that when choosing an Mvvm framework you choose the one you want base on it's feature set. If Prism has the majority of the features, and you just want to spice it up with some reactive programming, that is a good way to go.

Episcopate answered 13/5, 2019 at 0:14 Comment(0)
C
3

I found this wonderful video by @Dan Seigel and @Rodney Littles, which is a walkthrough on how to use RxUI for the VM bits and Prism for the bootstrapping and structural stuff.

Its structure is outlined in the sample project's ReadMe.md:

Using ReactiveUI + Prism

  • Use Prism Navigation Paradigms + DI
  • Use ReactiveCommands
  • Use ReactiveObject for the ViewModel's base class

Borrowed Instagram UI for Xamarin.Forms from Adam Pedley

Uses the following ReactiveUI concepts

Crowns answered 23/8, 2020 at 4:39 Comment(2)
Where is the video?Jolie
[link] (youtube.com/watch?v=sEfznU3lwVQ)Archibald

© 2022 - 2024 — McMap. All rights reserved.