A Hilt module is a class that is annotated with @Module. Like a Dagger module, it informs Hilt how to provide instances of certain types. Unlike Dagger modules, you must annotate Hilt modules with @InstallIn to tell Hilt which Android class each module will be used or installed in.
Source: Hilt Modules
Modules are not new. Dagger used modules. Modules are the solution to the problem I outlined in Basics #5.
The purpose of a Module is to tell dagger how to instantiate an implementation of an interface or a class that you do not own.
Like saying: "Hey Dagger, here's how you build that thing I want."
Hilt gives you two ways to do this. And as far as I know there is no performance difference between the two. But one is significantly more complex (IN MY OPINION). And this is the kicker:
- The SIMPLE one can be used for ALL scenarios
- The COMPLEX one can be used for MOST scenarios
Anyway, I will explain this to you with examples and I'm sure (like me) you will choose the simpler way that can be used for all scenarios.