Assisted Injection With Dagger and Hilt | raywenderlich.com

Learn what assisted injection is used for, how it works, and how you can add it to your app with Dagger’s new built-in support for the feature.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/21395558-assisted-injection-with-dagger-and-hilt

Why not just using @HiltViewModel, @ViewModelScoped?

Hi @mmathieum
Thank you for your message.

@HiltViewModel allows you to make a ViewModel available for injection in the dependency graph.
@ViewModelScoped allows you to give that instance a scope typical of a ViewModel which can “resist” a configuration change like a rotation.

Unfortunately, when I wrote the tutorial, those annotations didn’t work with assisted injection and so with @AssistedInject.

Best
Max