Last active
September 4, 2019 08:34
-
-
Save LukaKordic/8faa3d499b51a2ef4274b4af40a450cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class WeatherRepositoryImpl(private val weatherApi: WeatherApi, | |
private val weatherDao: WeatherDao) : BaseRepository<WeatherInfo, WeatherEntity>(), WeatherRepository { | |
override suspend fun getWeatherForLocation(location: String): Result<WeatherInfo> { | |
return fetchData( | |
apiDataProvider = { | |
weatherApi.getWeatherForLocation(location).getData( | |
fetchFromCacheAction = { weatherDao.getWeatherInfoForCity(location) }, | |
cacheAction = { weatherDao.saveWeatherInfo(it) }) | |
}, | |
dbDataProvider = { weatherDao.getWeatherInfoForCity(location) } | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment