[英]Dependence of one Observable on another RxJava2
有一個類,它具有可觀察的字段。 我想更新localData
當接收遠程數據remoteData
,由於某種原因我無法在localData
獲取數據,因此localData
調試getIdsInDatumsRemote ()
也不會轉到斷點。 identifyDatumsForUpdate ()
方法獲取一個空的Observable。
class DiskDatumDataStore {
var remoteData: Observable<Data>? = null
var localData: Observable<Data>? = null
override fun sync() {
remoteDatums = getChangedRemoteData(lastUpdated!!, 1000)!!
localDatums = remoteDatums!!.map {
getIdsInDatumsRemote(it)
}.map {
it.map {
it.toLong()
}
}.flatMap {
getOldLocalData(it)
}
identifyDatumsForUpdate(datumsForUpdateLocal, datumsForUpdateRemote)
}
override fun getOldLocalData(remoteDatumsIds: List<Long>): Observable<List<DataLayerTypesOfResponsibility>> {
return Observable.fromCallable { repository.getOldDatum(remoteDatumsIds) }
}
}
您沒有subscribing
Observable
。 您只是在創建它。
localDatums = remoteDatums!!.map {
getIdsInDatumsRemote(it)
}.map {
it.map {
it.toLong()
}
}.flatMap {
getOldLocalData(it)
}.subscribe { it->
//do something with the result `it`
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.