java - RxJava: what is difference between callbacks in doOnError('callback') and subscribe(*, 'callback') -


in last project, use rxjava , realize observable.doonerror('onerrorcallback').subscribe(action) , observable.subscribe(action, 'onerrorcallback') behave in different ways. docs it's not obvious me what's difference between them , when should use first , second variant.

the doonerror operator allows inject side-effect error propagation of sequence, not stop error propagation itself. subscriber final destination of events , 'exit' sequence.

you can see usefulness of doonerror following example:

api.getdata() .doonerror(e -> log.error(e)) .retry(2) .subscribe(...) 

it allows peek error lets retry in case of error. end subscriber:

api.getdata() .subscribe(v -> {}, e -> log.error(e) ); 

you have arrange handling of error (besides logging) on own way.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -