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
Post a Comment