Skip to content

Implement Clean Mvvm Architecture #32

@Goncharuk-Nikita

Description

@Goncharuk-Nikita

Hi, I’m looking for Mvvm plugins for Unity and your solution is currently the best I've found.

I worked with Mvvm for over a year on Xamarin technology and clearly understand its work. But what you have is different from pure Mvvm. I look at MvvmCross and this is a great example for me of cross-platform Mvvm.

I think this framework could be partially ported to Unity. MvvmCross Unity3d.
Now I am trying to implement something similar in Unity in a new project, but I have to write it on the go. The concept of what I am writing is very similar to the MvvmCross, excluding the View part.

Below I gave an example of running my program in Unity.

My ViewModels are pure C # classes, they are inherited from the ViewModel class, which implements the underlying logiс.
My Views- MonoBehaviour, are inherited from the base View class, which implements the basic logic and events.

I try to implement ViewModel-first navigation andcreate a basic asynchronius (UniRx with UniTask) NavigationService to navigate between ViewModels. In GameSettings, I defined Views (which are represented as an AssetReference using the AddressableSystem) and the name ViewModel. For some connection.
NavigationService has a Load method that loads the entire View asynchronously and attaches a ViewModel to them. Yea, thats ViewModel-first :)
image

On Start:

  1. I use Zenject to register services and my ViewModels.
  2. Then i run LoadingViewModel. And call NavigationService.Load
  3. Navigate to some MainViewModel

View class like a MyPage.xaml.cs it needs to bind texts, buttons and etc. to ViewModel:
image

For text binding i use ReactiveProperty from UniRx.

But my bindings are frankly shit. And I want to implement Fluet binding method from MvvmCross.

What is this post / question for. I'm looking for people who want to do something like this. Ideally, I want to migrate MvvmCross to Unity. If it will be interesting to you, then I can provide a more detailed implementation of my approach, but it is not perfect and mainly depends on external plug-ins.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions