rx.internal.operators.OperatorToObservableList Maven / Gradle / Ivy
/**
* Copyright 2014 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package rx.internal.operators;
import java.util.*;
import rx.Observable.Operator;
import rx.Subscriber;
import rx.exceptions.Exceptions;
import rx.internal.producers.SingleDelayedProducer;
/**
* Returns an {@code Observable} that emits a single item, a list composed of all the items emitted by the
* source {@code Observable}.
*
*
*
* Normally, an {@code Observable} that returns multiple items will do so by invoking its subscriber's
* {@link Subscriber#onNext onNext} method for each such item. You can change this behavior, instructing the
* {@code Observable} to compose a list of all of these multiple items and then to invoke the subscriber's
* {@code onNext} method once, passing it the entire list, by using this operator.
*
* Be careful not to use this operator on {@code Observable}s that emit infinite or very large numbers of items,
* as you do not have the option to unsubscribe.
* @param the value type of the input and the output list's items
*/
public final class OperatorToObservableList implements Operator, T> {
/** Lazy initialization via inner-class holder. */
static final class Holder {
/** A singleton instance. */
static final OperatorToObservableList