android - RxJava. Call onError after onNext -


i want call onnext , call onerror method. can not it. can me? example:

observable.create(new observableonsubscribe<string>() {     @override     public void subscribe(observableemitter<string> e) throws exception {         e.onnext("value");         e.onerror(new exception("exc"));     } })         .subscribeon(schedulers.io())         .observeon(androidschedulers.mainthread())         .subscribe(new consumer<string>() {             @override             public void accept(@nonnull string s) throws exception {                 log.v("tag", s);             }         }, new consumer<throwable>() {             @override             public void accept(@nonnull throwable throwable) throws exception {                 log.v("tag", throwable.getlocalizedmessage());             }         }); 

output: exc

thrad.sleep(500) helps me, think wrong way

if don't specify delayerror = true in observeon operator end checking if terminated (onerror called) before ends emitting onnext called beforehand.

see documentation:

delayerror - indicates if onerror notification may not cut ahead of onnext notification on other side of scheduling boundary. if true sequence ending in onerror replayed in same order received upstream


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -