Fill the blank
Bind the interface to its implementation without writing a factory.
@Module
@InstallIn(SingletonComponent::class)
abstract class DataModule {
@____
abstract fun bindArticles(impl: OfflineArticles): Articles
}Hint 1 of 1
The function is abstract.
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A Binds
Correct. @Binds maps the interface to the implementation Hilt already knows how to build.
Why not the others?
- B Provides. @Provides needs a function body that builds the instance.
- C Inject. @Inject goes on constructors or fields.
- D Singleton. That's a scope, not a binding.