question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:

  1. An instance of the ViewModel is created in IMvxNavigationService.Navigate<ViewModel, TParameter>
  2. MvxViewModel<TParameter>.Prepare(TParameter... ) is invoked to save the parameter
  3. Second instance of the ViewModel is created in Activity.OnCreate(Bundle…)
  4. MvxViewModel<TParameter>.Prepare(TParameter... ) is not invoked which breaks the ViewModel

Expected behavior

  1. Only single instance of a MvxViewModel<TParameter> is instantiated.
  2. 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:closed
  • Created 2 months ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
evgenyvalavincommented, Aug 2, 2023

Yup! I confirm it’s been fixed

0reactions
Cheesebaroncommented, Aug 1, 2023

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found