src/main/java/io/reactivex/Observable.java
@CheckReturnValue
    @SchedulerSupport(SchedulerSupport.NONE)
    public final <R> Observable<R> publish(Function<? super Observable<T>, ? extends ObservableSource<R>> selector) {
        ObjectHelper.requireNonNull(selector, "selector is null");
        return RxJavaPlugins.onAssembly(new ObservablePublishSelector<T, R>(this, selector));
    }
@CheckReturnValue
    @SchedulerSupport(SchedulerSupport.NONE)
    public final <R> Observable<R> publish(Function<? super Observable<T>, ? extends ObservableSource<R>> selector) {
        ObjectHelper.requireNonNull(selector, "selector is null");
        return RxJavaPlugins.onAssembly(new ObservablePublishSelector<T, R>(this, selector));
    }
Returns an Observable that emits the results of invoking a specified selector on items emitted by a
{@link ConnectableObservable} that shares a single subscription to the underlying sequence.
<p>
<img width="640" height="647" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/publishFunction.o.png" alt="">
<dl>
<dt><b>Scheduler:</b></dt>
<dd>{@code publish} does not operate by default on a particular {@link Scheduler}.</dd>
</dl>

@param <R>
the type of items emitted by the resulting ObservableSource
@param selector
a function that can use the multicasted source sequence as many times as needed, without
causing multiple subscriptions to the source sequence. Observers to the given source will
receive all notifications of the source from the time of the subscription forward.
@return an Observable that emits the results of invoking the selector on the items emitted by a {@link ConnectableObservable} that shares a single subscription to the underlying sequence
@see <a href="http://reactivex.io/documentation/operators/publish.html">ReactiveX operators documentation: Publish</a>