Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 :

  • Reactive programming (ReactiveUI)
  • Vertical slicing, if possible (blog 1, blog 2)

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 ?

like image 872
David Khuu Avatar asked May 12 '19 23:05

David Khuu


1 Answers

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.

like image 132
Rodney Littles Avatar answered Sep 28 '22 22:09

Rodney Littles