tonnyl
01/27/2022, 6:07 AMdefaultViewModelCreationExtras
in compose, did I miss something?Ian Lake
01/27/2022, 6:25 AMNavBackStackEntry
(just like how you don't control the default factory either). While it didn't make it into this alpha01 release, expect two approaches going forward:
1. viewModel()
that takes CreationExtras
, in addition to the factory (thus allowing you to provide your own CreationExtras
to your custom factory)
2. A new viewModel()
overload that takes a lambda method to construct the ViewModel:
val viewModel: HomeViewModel = viewModel {
// Directly reference any value without having
// to worry about a Factory or CreationExtras
HomeViewModel(valueFromComposition, repository)
}
You can technically write those both yourself right now (as the underlying APIs that you need are already there)tonnyl
01/27/2022, 6:34 AMColton Idle
01/29/2022, 2:23 AMIan Lake
01/29/2022, 3:33 AM