Commit 4c5a7cc6 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

mapping function refactorign

parent 5809bb86
...@@ -4,7 +4,10 @@ import com.biganto.visual.roompark.data.repository.api.IRoomParkApi ...@@ -4,7 +4,10 @@ import com.biganto.visual.roompark.data.repository.api.IRoomParkApi
import com.biganto.visual.roompark.data.repository.db.IDb import com.biganto.visual.roompark.data.repository.db.IDb
import com.biganto.visual.roompark.data.repository.mapper.fromRaw import com.biganto.visual.roompark.data.repository.mapper.fromRaw
import com.biganto.visual.roompark.domain.contract.FeedsContract import com.biganto.visual.roompark.domain.contract.FeedsContract
import com.biganto.visual.roompark.domain.model.* import com.biganto.visual.roompark.domain.model.ArticlesPreviewModel
import com.biganto.visual.roompark.domain.model.FeedModel
import com.biganto.visual.roompark.domain.model.FeedsHeaderModel
import com.biganto.visual.roompark.domain.model.fromEntity
import io.reactivex.Observable import io.reactivex.Observable
import io.reactivex.Single import io.reactivex.Single
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
...@@ -51,9 +54,9 @@ class FeedsContractModule @Inject constructor( ...@@ -51,9 +54,9 @@ class FeedsContractModule @Inject constructor(
.toObservable() .toObservable()
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
fun getZones(userToken:String): Observable<List<FeedModel>> = fun fetchAllFeeds(userToken:String): Observable<List<FeedModel>> =
Observable.mergeDelayError( Observable.mergeDelayError(
arrayListOf(fetchFeedsApi(userToken),fetchFeedsDb) arrayListOf(fetchFeedsApi(userToken),fetchFeedsDb)
).map { fromEntity(it) {ent ->fromEntity2(ent)}} ).map { fromEntity(it,::fromEntity) }
} }
...@@ -33,7 +33,7 @@ data class ArticleModel( ...@@ -33,7 +33,7 @@ data class ArticleModel(
val isRead:Boolean val isRead:Boolean
) )
fun fromEntity2(entity: FeedEntity):FeedModel = FeedModel( fun fromEntity(entity: FeedEntity):FeedModel = FeedModel(
feedId = entity.id, feedId = entity.id,
title = entity.title, title = entity.title,
alias = entity.alias alias = entity.alias
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment