toothpick
toothpick copied to clipboard
smoothie lifecycle extension does not provide example for combining ViewModel with SavedStateHandle using AbstractSavedStateViewModelFactory
In order to support onSaveInstanceState
and saved state persistence inside ViewModel classes, Jetpack provides the viewmodel-savedstate
module: with the AbstractSavedStateViewModelFactory
, that provides the correct SavedStateHandle
for the SavedStateRegistryOwner
, with the correct initial arguments (intent.extras
, fragment.arguments
, or navBackStackEntry.arguments
).
There seems to be no example for this basic scenario in this library, and that is a problem.
The viewmodel-savedstate
module was officially released as a stable release in January 2020, and should be supported.
Hi @Zhuinden ,
Thanks for the issue! I agree that it is something that we should support. Planning to add it to the next release.
Implementation notes:
- We just need to update
androidx.fragment:fragment
dependency to1.2.0
- The rest of the code is ready for this change