escodro
03/02/2021, 5:21 PMHome
screen that contains 4 tabs, each one with its own ViewModel
.
Today it is declared this way:
composable(Destinations.Home) {
Home(
onTaskClicked = actions.openTaskDetail,
onAboutClicked = actions.openAbout
)
}
But since calling viewModel()
to get the ViewModels for each Composable does not work, how should I proceed? Get the 4 ViewModels inside my NavGraph
and pass then all to my Home
? Should I create a HomeViewModelProvider
containing the 4 ViewModels? Is there a better approach?
Thanks a lot in advance! ❤️Ian Lake
03/02/2021, 5:32 PMViewModelProvider.Factory
you get from HiltViewModelFactory(AmbientContext.current, it)
- as long as you use that Factory with viewModel()
, it will work just fineescodro
03/02/2021, 5:46 PMViewModelProvider.Factory
around or we will get some alternative in the future?Ian Lake
03/02/2021, 5:56 PMhiltNavGraphViewModel()
Colton Idle
03/02/2021, 10:13 PM