I have checked all the documentation and knows well that @Binds used for providing interface dependency.But I am bit confused in current example, lets say I have dependency injection for my interface using @Binds in blow code:
interface MyRepository{
}
@Module
abstract class RepositoryModule{
@Binds
abstract fun bindMyRepository(myRepo:MyRepositoryImpl):MyRepository
}
class RegisterUseCase @Inject constructor(private val myRepo:MyRepository)
But the same thing I can also acheive using @Provides
@Module
class RepositoryModule{
@Provides
fun provideMyRepository():MyRepository{
return MyRespositoryImpl()
}
}
We can acheive same goal by using both binds and provides this thing confusing me. Please explain in details so that I can be more clear with my concept about @Binds and @Provides?