oday
06/25/2022, 9:03 AM@HiltViewModel
class AuthenticationViewModel @Inject constructor(
private val determineAuthStatus: DetermineAuthStatus,
private val populateUserPrefs: PopulateUserPrefs
) : ViewModel() {
and I want to use the viewmodel in a composable like so
val viewModel : AuthenticationViewModel = hiltViewModel()
but I get that the viewmodel does not have any zero-argument constructors, I’ve already created the module for these 2 deps to be provided
this composable that i’m using the viewmodel in, is started inside an Activity which I’ve set @AndroidEntryPoint on, what am I missing ?Chris Fillmore
06/25/2022, 11:15 AMBerkeli Alashov
06/25/2022, 11:31 AMFunkyMuse
06/25/2022, 11:52 AModay
06/25/2022, 11:55 AMby viewModels()
it works fine
but if I initialize it inside the composable using = viewModel()
it does the no zero-argument constructor errorFunkyMuse
06/25/2022, 3:22 PModay
06/25/2022, 3:47 PMkapt {
correctErrorTypes true
}
?hilt {
enableAggregatingTask = true
}
Reda AOUTEM
06/26/2022, 11:06 AMval viewModel : AuthenticationViewModel = viewModel()
instead of = hiltViewModel()
. Could it be the mistake ?oday
06/26/2022, 1:35 PM