I've been out of the dagger/hilt game for a little...
# dagger
c
I've been out of the dagger/hilt game for a little bit so just want a sanity check. I have a class that is annotated with @Inject, and it seems like I can use it in my android HiltViewModels just fine. That class is not in any @Module though. I now want to make that @Inject a
@Singleton
but, does that mean I have to add it to a module that it @InstallIn(SingletonComponent:class)?
n
No you do not need to add it to a module with
@InstallIn(SingletonComponent:class)
@Singleton class MyClass @Inject constructor()
is enough to get it on the DI graph as a singleton
c
thank you 🙏
So kinda funny. im on a new project. the code has been using hilt for years. It makes use of a @SingletonComponent... but none of the @Provides in that SingletonComponent are actually marked as
@Singleton
... so we had like 10 http clients being created like everytime you open the app. lmaooooo
kodee sad 2