Rafs
12/08/2024, 11:24 AMDusan Stefanovic
12/09/2024, 12:39 AMAddDiaryUseCase
, so something like this:
fun useCaseModule() = module {
singleOf(::LocalDataSource) {
bind<DataSource>()
named<LocalDataSourceQualifier>()
}
singleOf(::RemoteDataSource) {
bind<DataSource>()
named<RemoteDataSourceQualifier>()
}
single {
AddDiaryUseCase(get(named<LocalDataSourceQualifier>()), get(), get())
}
}
but if you need different AddDiaryUseCase
instance based on DataSource
type, probably it’s better like this:
fun useCaseModule() = module {
singleOf(::LocalDataSource) {
bind<DataSource>()
}
singleOf(::RemoteDataSource) {
bind<DataSource>()
}
single(named<LocalDataSource>()) {
AddDiaryUseCase(get<LocalDataSource>(), get(), get())
}
single(named<RemoteDataSource>()) {
AddDiaryUseCase(get<RemoteDataSource>(), get(), get())
}
}
and you can later get/inject it with get(named<LocalDataSource>())
or inject(named<RemoteDataSource>())
, so you wont need LocalDataSourceQualifier
and RemoteDataSourceQualifier