Nikola Drljaca
03/05/2021, 7:46 PMviewModel
when using navigation-compose
?Ian Lake
03/05/2021, 8:00 PMSavedStateHandle
of a ViewModel will automatically be populated with the arguments of the destinationNikola Drljaca
03/05/2021, 8:04 PMNikola Drljaca
03/05/2021, 8:05 PMGabriel
03/05/2021, 8:36 PMzoha131
03/05/2021, 8:47 PMIan Lake
03/05/2021, 8:49 PMSavedStateViewModelFactory
(which is what gives you SavedStateHandle
): https://developer.android.com/jetpack/androidx/releases/navigation#2.2.0Ian Lake
03/05/2021, 8:49 PMIan Lake
03/05/2021, 8:50 PMSavedStateHandle
there)zoha131
03/05/2021, 8:56 PMSavedStateHandle
even if I use compose.Ian Lake
03/05/2021, 9:00 PMzoha131
03/05/2021, 9:01 PMGabriel
03/05/2021, 9:14 PMcomposable(Screen.LaunchScreen.route) {
val playersViewModel = viewModel<PlayersViewModel>(
factory = PlayersViewModelFactory(
this,<--- what should this be?
PlayersRepository()
)
)
LaunchScreen(playersViewModel)
}
Gabriel
03/05/2021, 9:15 PMIan Lake
03/05/2021, 9:15 PMit
- the NavBackStackEntry
is a SavedStateRegistryOwner
Gabriel
03/05/2021, 9:16 PMGabriel
03/05/2021, 9:16 PM