Lokik Soni
06/25/2022, 1:34 PMVivek
06/26/2022, 2:20 PMLokik Soni
06/26/2022, 3:40 PMVishnu Haridas
06/28/2022, 7:57 PMinterface ChargeInfoProvider{
fun start(onData: (Int) -> Unit)
fun stop()
}
/data/chargeinfo/impl/AndroidBRProvider.kt
class AndroidBRProvider(
val context: Context // Inject this
): ChargeInfoProvider {
fun start(onData: (Int) -> Unit){
// setup BR
BR.onRecieve {
onData(value)
}
}
fun stop() = // stop BR
}
/data/chargeinfo/ChargeInfoRepository.kt
class ChargeInfoRepository(
val provider: ChargeInfoProvider // Inject this
){
val flow // to expose data
fun start(){
provider.start() { data ->
// update flow
}
}
fun stop() = provider.stop()
}
curioustechizen
06/29/2022, 7:11 AMLokik Soni
06/29/2022, 7:25 AMLokik Soni
06/29/2022, 7:26 AMVishnu Haridas
06/29/2022, 8:29 AM...if the interface is declared in the domain layer and the implementation is in the data layer.That will make the data layer depend upon the domain layer for that interface. So I suggest keeping the interface in the data layer itself so that the dependency is always in only one direction: Data ⬆️ Domain ⬆️ UI
Lokik Soni
06/29/2022, 8:34 AMcurioustechizen
06/29/2022, 8:48 AMcurioustechizen
06/29/2022, 8:50 AMcurioustechizen
06/29/2022, 8:51 AMVishnu Haridas
06/29/2022, 8:52 AMcurioustechizen
06/29/2022, 8:54 AMVishnu Haridas
06/29/2022, 8:54 AMVivek
06/29/2022, 9:00 AMcurioustechizen
06/29/2022, 9:06 AMVishnu Haridas
06/29/2022, 12:03 PMVivek
06/29/2022, 2:02 PM