Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class NewsRepositoryImpl(private val remote: NewsRemoteImpl,
- private val cache: NewsCacheImpl) : NewsRepository {
- override fun getLocalNews(): Flowable<NewsSourcesEntity> {
- return cache.getNews()
- }
- override fun getRemoteNews(): Flowable<NewsSourcesEntity> {
- return remote.getNews()
- }
- override fun getNews(): Flowable<NewsSourcesEntity> {
- val updateNewsFlowable = remote.getNews()
- return cache.getNews()
- .mergeWith(updateNewsFlowable.doOnNext{
- remoteNews -> cache.saveArticles(remoteNews)
- })
- }
- }
Add Comment
Please, Sign In to add comment