-
Notifications
You must be signed in to change notification settings - Fork 868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ViewModel is not retained #49
Comments
I had the same problem and I am very interested to know the reason why After screen rotation a new ViewModel is always provided for fragment when we create ViewModel in onAttach. I tried to dig in my side, but I could not find the answer what I noticed is that: But in our case onDestroy is called and the ViewModelStore is cleared . as you can see in HolderFragment#onDestory method
If my analysis is good the real question is why HolderFragment#onDestroy is called after the configuration change even if he is marked as retain ? Thank you in advance. |
After screen rotation a new ViewModel is always provided for fragments. Moving the creation of the model from onAttach to onCreate solves the problem.
The text was updated successfully, but these errors were encountered: