Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- apiClient.apiCall(arg)
- .flatMap(x -> x.result != null
- ? Observable.just(x.result)
- : x.error.isCaptcha()
- ? captchaDialog(x.error.captchaImgUrl)
- // send the captcha
- .flatMap(str -> apiClient.submitCaptcha(str))
- // call the api method again
- // this should be done recursively
- // simplicity for the sake of blog post
- .flatMap(success -> apiClient.apiCall(arg))
- : Observable.error(x.error))
- .subscribe(x -> // at this point we recovered from any captcha requests we encountered, and got our desired data,
- e -> // failure);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement