https://kotlinlang.org logo
#rx
Title
u

ubu

08/30/2018, 3:49 PM
Copy code
private fun getExternalPlaces(query: String): Single<List<SearchPlacesResult>> {
        return locationRepository
                .getPredictionsForQuery(query)
                .onErrorReturn { emptyList() }
                .flattenAsObservable { results -> results }
                .flatMapSingle { result -> locationRepository.getPlaceForPrediction(result) }
                .onErrorReturn { Optional.empty() }
                .filter { optional -> optional.hasValue() }
                .map { place -> wrapIntoExternalResult(place.value!!, query) }
                .toList()
    }