Generalidades
Una descripción general para principiantes de las palabras clave de Hilt | Por Gvpraveen Ravi | Abril de 2022
You know how to add but for what to add?1. @HiltAndroidApp: starting point to let the app know that Hilt is there for me(your Android App).
2. @AndroidEntryPoint: Ready to inject the dependencies.
Note: need to add to Activity If you want to add in Fragment.
3. @Inject constructor: Inject dependencies in constructor
4. @Inject: Get dependency
5. @Named: Scoped annotation if App has multiple instances of same Type. For suppose, we wanted to inject one String if multiple instances are present in Hilt memory.
6. by viewmodels(): used to inject viewmodels
7. Module: To get any instance by Hilt, Hilt need to know how to create an instance. We have to write the logic on how to create an instance in modules. Modules will have general functions which provides instances.
8. Provides: will provides required instance. Hilt is somehow conscious that when dependent instance is required, hilt will get it or create it on its own. I know, this statement doesn't summarize clearly. You will get to know when your hands gets dirty with Hilt.
9. @InstallIn(ClassName::class): will restrict the scope of the instances to the class given.Thank you for your time. We have other keyword also. Stay tuned for the next level of keywords