-
-
Save MarkyC/654c4fd376fcd77ed8c8da3ee087030d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
view.getCurrentLocation() | |
.map(locationToPlaceTransformer::apply) | |
// TODO: need to show an error with the location name in it if the location isn't supported | |
.flatMap(place -> Observable.zip( | |
userLocationRepository.isLocationSupported(place), // returns Observable<Boolean> | |
Observable.just(place), | |
(isLocationSupported, p) -> { | |
if (isLocationSupported) { | |
return p; | |
} | |
throw new UnsupportedLocationException(p.getName()); | |
})) | |
.map(place -> { | |
placesRepository.putRecentPlace(place); | |
userLocationRepository.putUserLocation(place); | |
return place; | |
}) | |
.subscribe( | |
place -> view.onPlaceSelected(place), | |
error -> { | |
if (MyException.is(error, UNSUPPORTED_LOCATION) { | |
view.showUnsupportedLocationError(((UnsupportedLocationException) error).getName()) | |
} else { | |
view.showError(error); | |
} | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment