src/main/java/io/reactivex/Observable.java
@CheckReturnValue
    @SchedulerSupport(SchedulerSupport.NONE)
    public final Observable<T> doOnLifecycle(final Consumer<? super Disposable> onSubscribe, final Action onDispose) {
        ObjectHelper.requireNonNull(onSubscribe, "onSubscribe is null");
        ObjectHelper.requireNonNull(onDispose, "onDispose is null");
        return RxJavaPlugins.onAssembly(new ObservableDoOnLifecycle<T>(this, onSubscribe, onDispose));
    }
@CheckReturnValue
    @SchedulerSupport(SchedulerSupport.NONE)
    public final Observable<T> doOnLifecycle(final Consumer<? super Disposable> onSubscribe, final Action onDispose) {
        ObjectHelper.requireNonNull(onSubscribe, "onSubscribe is null");
        ObjectHelper.requireNonNull(onDispose, "onDispose is null");
        return RxJavaPlugins.onAssembly(new ObservableDoOnLifecycle<T>(this, onSubscribe, onDispose));
    }
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Observable < T > doOnLifecycle ( final Consumer < ? super Disposable > onSubscribe , final Action onDispose ) { ObjectHelper . requireNonNull ( onSubscribe , "onSubscribe is null" ) ; ObjectHelper . requireNonNull ( onDispose , "onDispose is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableDoOnLifecycle < T > ( this , onSubscribe , onDispose ) ) ; }
Calls the appropriate onXXX method (shared between all Observer) for the lifecycle events of
the sequence (subscription, disposal).
<p>
<img width="640" height="310" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/doOnLifecycle.o.png" alt="">
<dl>
<dt><b>Scheduler:</b></dt>
<dd>{@code doOnLifecycle} does not operate by default on a particular {@link Scheduler}.</dd>
</dl>

@param onSubscribe
a Consumer called with the Disposable sent via Observer.onSubscribe()
@param onDispose
called when the downstream disposes the Disposable via dispose()
@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>
Calls the appropriate onXXX method ( shared between all Observer ) for the lifecycle events of the sequence ( subscription disposal ) . <p > <img width = 640 height = 310 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / doOnLifecycle . o . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code doOnLifecycle } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl >