mvvm - Deciding whether to pass a Model or a Repository/Service to my View Model? -
I will come repeatedly against this decision and I will constantly stagger on what kind of approach.
Many MVM example models are being seen as models of the model. Therefore each VM is connected with a model. To make a logic and VM to get the model back, "elsewhere" is outside of VM, the model should know how to change it.
The second option is to pass some kind of reference, service or store through VM and VM decides which model is needed, the implication is that VM is a long life and many different models It can be reused to display.
Did any rule come with any rule to work best for any scenario?
Generally a view model is defined as a scene on a model, i.e. It exists in mediation between model and scene. Although a visual model is completely possible, which is sufficient for mediation for many model types, reverse is true in practice and multiple visual models may exist for a model model, especially in such cases Where a model is needed to be sung in various parts of the application in different ways
Besides, I generally consider the model as a simple data object And implements the recovery and strongly argued for a different service that can be passed using dependency injection. Once said, the model is not wrong to mess with building directly firmly argument, that it would like to fits better your situation although I split the layer, so that through the fun Get easy test permission
Comments
Post a Comment