https://kotlinlang.org logo
#compose
Title
# compose
v

Vsevolod Kaganovych

09/23/2021, 2:15 PM
Do we have a way to inject parameters from arguments inside viewmodel from compose navigation with hilt? For example, I have parameter, that I pass and I have
Copy code
val viewmodel: ViewModel = hiltViewModel()
How do I pass a parameter from arguments to constructor?
j

JulianK

09/23/2021, 2:50 PM
You don't pass arguments to the hiltViewModel() function, instead, inject an instance of SavedStateHandle into your viewModel: https://developer.android.com/jetpack/compose/libraries#hilt You can than get your navigation arguments from there.
v

Vsevolod Kaganovych

09/23/2021, 3:03 PM
thank you!
55 Views