HarryPulvirenti
06/05/2020, 8:50 AMkoin
implementation of the FragmentFactory
.
Basically, if you inject a ViewModel
in the constructor of the Fragment
, this one will be instantiated again if you rotate the screen.
This bug is reproducible only injecting the ViewModel
via the fragment constructor but is not possible to reproduce it injecting the ViewModel
via the lazy extension viewModel()
Let me know if you are already aware of this bug or I can open an issue on Github.tynn
06/05/2020, 7:35 PMget()
to obtain your view model within your fragment factory, it’s the expected behavior.ViewModelStoreOwner
to obtain the view model, you could use ViewModelStoreOwner.getViewModel<Model>()
instead.arnaud.giuliani
06/09/2020, 9:08 AMHarryPulvirenti
06/10/2020, 8:51 AMViewModelStoreOwner
in some way and then use it to inject the ViewModel
?arnaud.giuliani
06/10/2020, 9:18 AMViewModelStoreOwner