1st, I tried
// used retrofit public interface ApiService { @GET(/get_some_data) Observable<SomeData> getSomeData(); } // clickStream created by onClick event // No.1 clickStream .flatMap(e -> apiService.getSomeData()) .subscribe( success -> Log.d("tag", "success"), error -> Log.d("tag", "error"), () -> Log.d("tag", "complete"))
this is normal if getSomeData () is successful. I can get some data every click.
but if an error occurs, unsubscribe. (therefore after an error it does not work)
2nd, I tried below (with onErrorResumeNext), but unsubscribe .
(did not raise onError, but raise onComplete, therefore unsubscribed)
// No.2 clickStream .flatMap(e -> apiService.getSomeData()) .onErrorResumeNext(throwable -> Observable.empty()) // add this line .subscribe( success -> Log.d("tag", "success"), error -> Log.d("tag", "error"), () -> Log.d("tag", "complete"))
3rd, I tried below (with repetition)
// No.3 clickStream .flatMap(e -> apiService.getSomeData()) .retry(5) // add this line .subscribe( success -> Log.d("tag", "success"), error -> Log.d("tag", "error"), () -> Log.d("tag", "complete"))
it is better than No.1. but not recorded.
I want to create an update button that works after an error.
I want to know
- Can I save or redirect a subscriber?
- Is this correct in Rxjava?
Sorry for the bad english.