dimanche 28 avril 2019

MVVMC iOS App with multiple ViewModels & how they can communicate each other

He i am developing an iOS App and its base architecture is MVVMC design pattern. Using coordinators for navigation logic.

I have situation, where I have a complex UI with different components. So obviously I have to modularise my design and create multiple ViewModels for different UI sub sections or Views. All these are attached a parent view.

My question is where should I keep those ViewModel references?

I have the following options. Please help me to choose the right approach among these.

1). Have a parent view lets this parent view hold this references to those child ViewModels and pass the updates among them.

2). Have a parent ViewModel. Lets have these child ViewModels attached to this parent ViewModel and Manage the child ViewModel updates with in the ParentViewModel and pass to the view.

3). Lets the coordinator have these references to the child ViewModels and manage the updates among them with in the coordinator and pass to the view.

Or is there any other standard practice other than this? Please help me to have a clear path here.

Any suggestions with some examples will be more helpful.

Aucun commentaire:

Enregistrer un commentaire