Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. apiClient.apiCall(arg)
  2.   .flatMap(x -> x.result != null
  3.              ? Observable.just(x.result)
  4.              : x.error.isCaptcha()
  5.                ? captchaDialog(x.error.captchaImgUrl)
  6.                    // send the captcha
  7.                    .flatMap(str -> apiClient.submitCaptcha(str))
  8.                    // call the api method again
  9.                    // this should be done recursively
  10.                    // simplicity for the sake of blog post
  11.                    .flatMap(success -> apiClient.apiCall(arg))
  12.                : Observable.error(x.error))
  13.   .subscribe(x -> // at this point we recovered from any captcha requests we encountered, and got our desired data,
  14.              e -> // failure);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement