CombineLatest隐藏错误

时间:2018-06-25 14:15:30

标签: android rx-java2

我想检索具有一定距离的地点列表,并仅在有最后一个可用位置时才追加此距离。

我的最后一个位置提供者是一个Observable,如果有位置,则发出onNext,否则返回val combineLatest = Flowable .combineLatest<List<Place>, Location, List<Place>>( req, getLastLocation().lastOrError().toFlowable() , BiFunction { places, loc -> places.forEach { var placeLocation = Location(it.placeName) placeLocation.latitude = it.latitude placeLocation.longitude = it.longitude it.distance = location?.distanceTo(placeLocation) } places.sortedBy { it.distance } }) combineLatest.onErrorResumeNext { t: Throwable -> req }

所以我尝试了这个:

lastOrError

我要尝试的是尝试根据最近的已知位置计算距离,如果没有,则返回原始请求。

但是,当位置不存在时,getLastLocation会完成而不会发出,因此NoSuchElementException会因'use strict'; var mf = new Array(); mf.init = function () { this.oldIh = window.innerHeight; //Not allowed: //var this.oldIh = window.innerHeight; // //Creates a var for this method only //var oldIh = 123; // //Creates a window-variable (not allowed in strict mode) //oldIh = 123; } mf.getInnerHeight = function () { return this.oldIh; } mf.init(); alert(mf.getInnerHeight()); 而失败。但是,此错误不会被我的onErrorResumeNext语句拦截,因此我无法放回备用。

我在这里想念什么?

0 个答案:

没有答案
相关问题