src/main/java/io/reactivex/flowables/ConnectableFlowable.java
@NonNull
    public Flowable<T> autoConnect(int numberOfSubscribers, @NonNull Consumer<? super Disposable> connection) {
        if (numberOfSubscribers <= 0) {
            this.connect(connection);
            return RxJavaPlugins.onAssembly(this);
        }
        return RxJavaPlugins.onAssembly(new FlowableAutoConnect<T>(this, numberOfSubscribers, connection));
    }
@NonNull
    public Flowable<T> autoConnect(int numberOfSubscribers, @NonNull Consumer<? super Disposable> connection) {
        if (numberOfSubscribers <= 0) {
            this.connect(connection);
            return RxJavaPlugins.onAssembly(this);
        }
        return RxJavaPlugins.onAssembly(new FlowableAutoConnect<T>(this, numberOfSubscribers, connection));
    }
@ NonNull public Flowable < T > autoConnect ( int numberOfSubscribers , @ NonNull Consumer < ? super Disposable > connection ) { if ( numberOfSubscribers <= 0 ) { this . connect ( connection ) ; return RxJavaPlugins . onAssembly ( this ) ; } return RxJavaPlugins . onAssembly ( new FlowableAutoConnect < T > ( this , numberOfSubscribers , connection ) ) ; }
Returns a Flowable that automatically connects (at most once) to this ConnectableFlowable
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="392" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/autoConnect.f.png" alt="">
<p>
The connection happens after the given number of subscriptions and happens at most once
during the lifetime of the returned Flowable. If this ConnectableFlowable
terminates, the connection is never renewed, no matter how Subscribers come
and go. Use {@link #refCount()} to renew a connection or dispose an active
connection when all {@code Subscriber}s have cancelled their {@code Subscription}s.

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