evant
04/21/2022, 8:55 PM@Binds(in = AppComponent::class)
@Inject
class MyImpl : Impl
but it just feels like shuffling things around? It's also nice to have them all in one place so you can override them all for tests (a common usecase for having multiple impls for an interface).muthuraj
06/25/2022, 2:58 PMIf you are binding an impl to an interface the it's probably because you want to be using different impls in different placesAlmost all classes in my project are single implementation interfaces. I'm using this pattern to create fakes easily in unit tests. In my current Android project, I use Anvil to solve this issue.
evant
06/29/2022, 7:17 PMI'm using this pattern to create fakes easily in unit testsSo you do have multiple implementations, the real one and the fake 😉 You can totally use kotlin-inject in your tests to set things up passing in the fake as I describe here. Though it's understandable if you want to do manual di in tests instead.