MvxViewModel<TParameter> is instantiated twice and Prepare(TParameter) is not being invoked
See original GitHub issue🐛 Bug Report
I have an Activity which linked to an instance of MvxViewModel<TParameter>
.
While navigating to the ViewModel this happens:
- An instance of the ViewModel is created in
IMvxNavigationService.Navigate<ViewModel, TParameter>
MvxViewModel<TParameter>.Prepare(TParameter... )
is invoked to save the parameter- Second instance of the ViewModel is created in Activity.OnCreate(Bundle…)
MvxViewModel<TParameter>.Prepare(TParameter... )
is not invoked which breaks the ViewModel
Expected behavior
- Only single instance of a
MvxViewModel<TParameter>
is instantiated. MvxViewModel<TParameter>.Prepare(TParameter... )
is a must to invoke.
Reproduction steps
I’ll update here as I figure out
Configuration
Version: 9.1.0
Platform:
- 🤖 Android
Issue Analytics
- State:
- Created 2 months ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
How to prevent a ViewModel constructor from being called ...
This causes the constructor of the ViewModel to be called twice, once by the command and once by the constructor of the view....
Read more >Viewmodel instantiates twice using a ViewModelLocator
In our app we have a problem of viewmodels instantiated twice. The reason this is happening is that creating a new Page instantiates...
Read more >ViewModel is called twice when using ...
The key idea of this approach is to set the DisplayedMeasurements property in the setter of the ISupportParameter.Parameter property. I should ...
Read more >17. Web MVC framework
The Spring Web model-view-controller (MVC) framework is designed around a DispatcherServlet that dispatches requests to handlers, with configurable handler ...
Read more >AngularJS - Controllers: The Comprehensive How To
In this guide you will learn the basics of Angular controllers amd how to use them in the MVC architecture. Learn about nested...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yup! I confirm it’s been fixed
I’ve release 9.1.1 which reverts my changes for removing the caching. Can you perhaps give it a spin and check if it fixes it? In my little sample in the Playground it seemed to fix the issue.