Let's say I have an application using Dagger Hilt and a view model that wants to inject an interface type that has multiple concrete implementations. How can I provide the correct concrete implementation without explicitly stating that I was trying to? (If there is an answer, I'd appreciate a base Dagger response too.)
In my eyes, an example of explicitly stating which concrete implementation to provide would be using the @Named annotation.
In my personal opinion, explicitly stating which implementation I need like this is a violation of the Dependency Inversion principle. In my case, the view model (and dev by extension) should only have knowledge of the interface type, not of its concrete implementations.
Perhaps using conditional statements in the provide function (in the module for supplying the interface) is the best solution, but I'm hesitant to believe that is true. For one, it looks like a hack, and, two, Dagger Hilt has been out for around 3 years so there must be a better way by now, right?