Pablo
12/03/2024, 9:43 PMinterface BusDataRepository {
suspend fun getBusStops(): ComplexBusStopGroup
}
class NetworkBusDataRepository(
private val retrofitService: BusDataApiService
) : BusDataRepository {
override suspend fun getBusStops(): ComplexBusStopGroup = retrofitService.getBusStops()
}
Then I added a offline repository for caching and retrieving the data from offline database, but then I noticed that the database table is not a ComplexBusStopGroup
but a simple list of BusStop instances, which is different. Then, my next code doesn't work, because the return type Flow<ListBusStop> is not the same as the original interface return type:
class OfflineBusDataRepository(
private val BusStopsDao: BusStopsDao
) : BusDataRepository {
override suspend fun getBusStops(): Flow<List<BusStop>> = BusStopsDao.getAllBusStops()
How is this issue managed in pattern repository with offline and online datasources?Ahmed
12/05/2024, 5:49 AM