What is the value of doAfterTerminate
when we already have doOnTerminate
?
In the official docs here, only doOnTerminate
is listed.
Why?
doFinally() The doFinally() operator is executed when onComplete() , onError() , or disposal happens. It is executed under the same conditions as doAfterTerminate() , plus it is also executed after the disposal.
The doOnNext operator modifies the Observable source so that it invokes an action when the onNext is called. The doOnEach operator modifies the Observable source so that it notifies an Observer for each item and establishes a callback that will be called each time an item is emitted.
Single is an Observable that always emit only one value or throws an error. A typical use case of Single observable would be when we make a network call in Android and receive a response. Sample Implementation: The below code always emits a Single user object. We use a Single Observable and a Single Observer.
You have to go to the JavaDoc for v2 to find the distinction. In doOnTerminate
it says:
This differs from
doAfterTerminate
in that this happens before theonComplete
oronError
notification.
The doAfterTerminate
docs don't have a similar note, although the "after" in the method name is pretty suggestive.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With