Skip to content

Instantly share code, notes, and snippets.

@SergejIsbrecht
Created December 14, 2020 22:42
Show Gist options
  • Save SergejIsbrecht/07ff3e008a2afb5cdd479b25ada80e77 to your computer and use it in GitHub Desktop.
Save SergejIsbrecht/07ff3e008a2afb5cdd479b25ada80e77 to your computer and use it in GitHub Desktop.
myLocationService.getLocation()
.flatMapSingle(new Function<Location, Single<DistanceResponseModel>>() {
@Override
public Single<DistanceResponseModel> apply(@NonNull Location location) throws Exception {
return distanceRepository.distanceResponseAPI(location.getLatitude() + "," + location.getLongitude(), getDestinations(), "my_google_api_key")
.subscribeOn(Schedulers.io());
}
})
.subscribe(new Subscriber<DistanceResponseModel>() {
or
myLocationService.getLocation()
.observeOn(Schedulers.io());
.flatMapSingle(new Function<Location, Single<DistanceResponseModel>>() {
@Override
public Single<DistanceResponseModel> apply(@NonNull Location location) throws Exception {
return distanceRepository.distanceResponseAPI(location.getLatitude() + "," + location.getLongitude(), getDestinations(), "my_google_api_key")
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment