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 AModay
06/25/2022, 11:55 AModay
06/25/2022, 11:56 AModay
06/25/2022, 12:03 PModay
06/25/2022, 12:46 PModay
06/25/2022, 12:57 PModay
06/25/2022, 1:20 PMby viewModels()
it works fine
but if I initialize it inside the composable using = viewModel()
it does the no zero-argument constructor erroroday
06/25/2022, 1:20 PMFunkyMuse
06/25/2022, 3:22 PModay
06/25/2022, 3:47 PModay
06/25/2022, 3:48 PMkapt {
correctErrorTypes true
}
?oday
06/25/2022, 3:49 PMhilt {
enableAggregatingTask = true
}
oday
06/25/2022, 3:49 PModay
06/25/2022, 3:49 PModay
06/25/2022, 7:34 PModay
06/25/2022, 7:34 PMReda AOUTEM
06/26/2022, 11:06 AMval viewModel : AuthenticationViewModel = viewModel()
instead of = hiltViewModel()
. Could it be the mistake ?oday
06/26/2022, 1:35 PModay
06/26/2022, 1:36 PModay
06/26/2022, 1:36 PM