src/main/java/io/reactivex/Observable.java
@CheckReturnValue
    @SchedulerSupport(SchedulerSupport.NONE)
    public final Observable<T> doOnTerminate(final Action onTerminate) {
        ObjectHelper.requireNonNull(onTerminate, "onTerminate is null");
        return doOnEach(Functions.emptyConsumer(),
                Functions.actionConsumer(onTerminate), onTerminate,
                Functions.EMPTY_ACTION);
    }
@CheckReturnValue
    @SchedulerSupport(SchedulerSupport.NONE)
    public final Observable<T> doOnTerminate(final Action onTerminate) {
        ObjectHelper.requireNonNull(onTerminate, "onTerminate is null");
        return doOnEach(Functions.emptyConsumer(),
                Functions.actionConsumer(onTerminate), onTerminate,
                Functions.EMPTY_ACTION);
    }
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Observable < T > doOnTerminate ( final Action onTerminate ) { ObjectHelper . requireNonNull ( onTerminate , "onTerminate is null" ) ; return doOnEach ( Functions . emptyConsumer ( ) , Functions . actionConsumer ( onTerminate ) , onTerminate , Functions . EMPTY_ACTION ) ; }
Modifies the source ObservableSource so that it invokes an action when it calls {@code onComplete} or
{@code onError}.
<p>
<img width="640" height="327" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/doOnTerminate.o.png" alt="">
<p>
This differs from {@code doAfterTerminate} in that this happens <em>before</em> the {@code onComplete} or
{@code onError} notification.
<dl>
<dt><b>Scheduler:</b></dt>
<dd>{@code doOnTerminate} does not operate by default on a particular {@link Scheduler}.</dd>
</dl>

@param onTerminate
the action to invoke when the source ObservableSource calls {@code onComplete} or {@code onError}
@return the source ObservableSource with the side-effecting behavior applied
@see <a href="http://reactivex.io/documentation/operators/do.html">ReactiveX operators documentation: Do</a>
@see #doAfterTerminate(Action)
Modifies the source ObservableSource so that it invokes an action when it calls { @code onComplete } or { @code onError } . <p > <img width = 640 height = 327 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / doOnTerminate . o . png alt = > <p > This differs from { @code doAfterTerminate } in that this happens <em > before< / em > the { @code onComplete } or { @code onError } notification . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code doOnTerminate } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl >