src/main/java/io/reactivex/Observable.java
@CheckReturnValue
    @SchedulerSupport(SchedulerSupport.NONE)
    public final <U extends Collection<? super T>> Single<U> toList(Callable<U> collectionSupplier) {
        ObjectHelper.requireNonNull(collectionSupplier, "collectionSupplier is null");
        return RxJavaPlugins.onAssembly(new ObservableToListSingle<T, U>(this, collectionSupplier));
    }
@CheckReturnValue
    @SchedulerSupport(SchedulerSupport.NONE)
    public final <U extends Collection<? super T>> Single<U> toList(Callable<U> collectionSupplier) {
        ObjectHelper.requireNonNull(collectionSupplier, "collectionSupplier is null");
        return RxJavaPlugins.onAssembly(new ObservableToListSingle<T, U>(this, collectionSupplier));
    }
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < U extends Collection < ? super T > > Single < U > toList ( Callable < U > collectionSupplier ) { ObjectHelper . requireNonNull ( collectionSupplier , "collectionSupplier is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableToListSingle < T , U > ( this , collectionSupplier ) ) ; }
Returns a Single that emits a single item, a list composed of all the items emitted by the
finite source ObservableSource.
<p>
<img width="640" height="365" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/toList.o.c.png" alt="">
<p>
Normally, an ObservableSource that returns multiple items will do so by invoking its {@link Observer}'s
{@link Observer#onNext onNext} method for each such item. You can change this behavior, instructing the
ObservableSource to compose a list of all of these items and then to invoke the Observer's {@code onNext}
function once, passing it the entire list, by calling the ObservableSource's {@code toList} method prior to
calling its {@link #subscribe} method.
<p>
Note that this operator requires the upstream to signal {@code onComplete} for the accumulated collection to
be emitted. Sources that are infinite and never complete will never emit anything through this
operator and an infinite source may lead to a fatal {@code OutOfMemoryError}.
<dl>
<dt><b>Scheduler:</b></dt>
<dd>{@code toList} does not operate by default on a particular {@link Scheduler}.</dd>
</dl>

@param <U> the subclass of a collection of Ts
@param collectionSupplier
the Callable returning the collection (for each individual Observer) to be filled in
@return a Single that emits a single item: a List containing all of the items emitted by the source
ObservableSource
@see <a href="http://reactivex.io/documentation/operators/to.html">ReactiveX operators documentation: To</a>
Returns a Single that emits a single item a list composed of all the items emitted by the finite source ObservableSource . <p > <img width = 640 height = 365 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / toList . o . c . png alt = > <p > Normally an ObservableSource that returns multiple items will do so by invoking its { @link Observer } s { @link Observer#onNext onNext } method for each such item . You can change this behavior instructing the ObservableSource to compose a list of all of these items and then to invoke the Observer s { @code onNext } function once passing it the entire list by calling the ObservableSource s { @code toList } method prior to calling its { @link #subscribe } method . <p > Note that this operator requires the upstream to signal { @code onComplete } for the accumulated collection to be emitted . Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatal { @code OutOfMemoryError } . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code toList } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl >