src/main/java/io/reactivex/observables/ConnectableObservable.java
@NonNull
    public Observable<T> autoConnect(int numberOfSubscribers, @NonNull Consumer<? super Disposable> connection) {
        if (numberOfSubscribers <= 0) {
            this.connect(connection);
            return RxJavaPlugins.onAssembly(this);
        }
        return RxJavaPlugins.onAssembly(new ObservableAutoConnect<T>(this, numberOfSubscribers, connection));
    }
@NonNull
    public Observable<T> autoConnect(int numberOfSubscribers, @NonNull Consumer<? super Disposable> connection) {
        if (numberOfSubscribers <= 0) {
            this.connect(connection);
            return RxJavaPlugins.onAssembly(this);
        }
        return RxJavaPlugins.onAssembly(new ObservableAutoConnect<T>(this, numberOfSubscribers, connection));
    }
@ NonNull public Observable < T > autoConnect ( int numberOfSubscribers , @ NonNull Consumer < ? super Disposable > connection ) { if ( numberOfSubscribers <= 0 ) { this . connect ( connection ) ; return RxJavaPlugins . onAssembly ( this ) ; } return RxJavaPlugins . onAssembly ( new ObservableAutoConnect < T > ( this , numberOfSubscribers , connection ) ) ; }
Returns an Observable that automatically connects (at most once) to this ConnectableObservable
when the specified number of Subscribers subscribe to it and calls the
specified callback with the Subscription associated with the established connection.
<p>
<img width="640" height="348" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/autoConnect.o.png" alt="">
<p>
The connection happens after the given number of subscriptions and happens at most once
during the lifetime of the returned Observable. If this ConnectableObservable
terminates, the connection is never renewed, no matter how Observers come
and go. Use {@link #refCount()} to renew a connection or dispose an active
connection when all {@code Observer}s have disposed their {@code Disposable}s.

@param numberOfSubscribers the number of subscribers to await before calling connect
on the ConnectableObservable. A non-positive value indicates
an immediate connection.
@param connection the callback Consumer that will receive the Subscription representing the
established connection
@return an Observable that automatically connects to this ConnectableObservable
when the specified number of Subscribers subscribe to it and calls the
specified callback with the Subscription associated with the established connection
Returns an Observable that automatically connects ( at most once ) to this ConnectableObservable when the specified number of Subscribers subscribe to it and calls the specified callback with the Subscription associated with the established connection . <p > <img width = 640 height = 348 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / autoConnect . o . png alt = > <p > The connection happens after the given number of subscriptions and happens at most once during the lifetime of the returned Observable . If this ConnectableObservable terminates the connection is never renewed no matter how Observers come and go . Use { @link #refCount () } to renew a connection or dispose an active connection when all { @code Observer } s have disposed their { @code Disposable } s .