toothpick icon indicating copy to clipboard operation
toothpick copied to clipboard

smoothie lifecycle extension does not provide example for combining ViewModel with SavedStateHandle using AbstractSavedStateViewModelFactory

Open Zhuinden opened this issue 4 years ago • 1 comments

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.

Zhuinden avatar May 30 '20 09:05 Zhuinden

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 to 1.2.0
  • The rest of the code is ready for this change

dlemures avatar Jun 13 '20 06:06 dlemures