mars885/hilt-binder

Docs: Binding multiple types to the same interface

tschuchortdev opened this issue · 1 comments

It would be nice to have documentation in the readme about what happens when you bind two types to the same interface without the multibinding annotation (@BindType(contributesTo = BindType.Collection.SET)) and without qualifiers:

interface ImageLoader

@BindType
class PicassoImageLoader @Inject constructor(): ImageLoader

@BindType
class GlideImageLoader @Inject constructor(): ImageLoader

It's been a while since I've used dagger, but I would expect that not to work since the instance resolution becomes ambiguous.

You are correct in your assumption, since in that case Dagger graph would contain two versions of the same type.

Using HiltBinder assumes that a user has some experience working with Dagger, including the fact that two or more identical types cannot be present in the graph at the same time.