Vivek Modi
01/22/2022, 4:50 PMinject()
and viewModel()
? I used both in when injecting in viewmodel and both works fine. I didn't figure out what the d/w in both. Which one need to use for viewModel. Any suggestions? Thankstynn
01/23/2022, 8:46 AMinject
will only resolve a (new) instance from Koin directly. viewModel
will resolve the instance from the enclosed ViewModelProvider
. So if you use inject
, you don’t need to use the Android ViewModel
at all. Everything special to it won’t have an effect.Vivek Modi
01/25/2022, 2:24 PMEverything special to it won't have an effect
tynn
01/25/2022, 2:24 PMVivek Modi
01/25/2022, 2:29 PMprivate val viewModel: ActivityViewModel by viewModels {
SavedStateViewModelFactory(application, this)
}
Vivek Modi
01/25/2022, 2:30 PMviewModel()
?Vivek Modi
01/25/2022, 2:30 PMinject()
Vivek Modi
01/25/2022, 2:30 PMprivate val viewModel: ActivityViewModel by viewModel()
tynn
01/25/2022, 2:31 PM