Dagger Hilt 'Assisted' and 'ViewModelInject' is deprecated. in Dagger Hilt View Model 1.0.0-alpha03
In alpha03, Use the new @HiltViewModel
and the normal @Inject
now as shown below.
@HiltViewModel
class MyViewModel @Inject constructor(
private val repository: Repository,
private val savedStateHandle: SavedStateHandle
) : ViewModel(), LifecycleObserver {
// Some code
}
In the last update of dagger hilt they made few changes , so in your case you can use @HiltViewModeland @Inject to use it with viewmodel
@HiltViewModel
class MyViewModel @Inject constructor(
private val repository: Repository,
private val savedStateHandle: SavedStateHandle
) : ViewModel(), LifecycleObserver {
// Some codes...
}
- and also keep in mind that if you were using applicationcomponent , in the latest update they changed it to SingletonComponentn , so in your module class this way
@Module
@InstallIn(SingletonComponent::class.java)
object hiltmodel....{}