rx.Observable Maven / Gradle / Ivy
Show all versions of rxjava-core Show documentation
/**
* 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;
import static rx.functions.Functions.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import rx.exceptions.Exceptions;
import rx.exceptions.OnErrorNotImplementedException;
import rx.exceptions.OnErrorThrowable;
import rx.functions.Action0;
import rx.functions.Action1;
import rx.functions.Action2;
import rx.functions.Func0;
import rx.functions.Func1;
import rx.functions.Func2;
import rx.functions.Func3;
import rx.functions.Func4;
import rx.functions.Func5;
import rx.functions.Func6;
import rx.functions.Func7;
import rx.functions.Func8;
import rx.functions.Func9;
import rx.functions.FuncN;
import rx.functions.Function;
import rx.functions.Functions;
import rx.joins.Pattern2;
import rx.joins.Plan0;
import rx.observables.BlockingObservable;
import rx.observables.ConnectableObservable;
import rx.observables.GroupedObservable;
import rx.observers.SafeSubscriber;
import rx.operators.OnSubscribeFromIterable;
import rx.operators.OnSubscribeRange;
import rx.operators.OperationAll;
import rx.operators.OperationAny;
import rx.operators.OperationAsObservable;
import rx.operators.OperationAverage;
import rx.operators.OperationBuffer;
import rx.operators.OperationCache;
import rx.operators.OperationCombineLatest;
import rx.operators.OperationConcat;
import rx.operators.OperationDebounce;
import rx.operators.OperationDefaultIfEmpty;
import rx.operators.OperationDefer;
import rx.operators.OperationDelay;
import rx.operators.OperationDematerialize;
import rx.operators.OperationDistinct;
import rx.operators.OperationDistinctUntilChanged;
import rx.operators.OperationElementAt;
import rx.operators.OperationFinally;
import rx.operators.OperationFlatMap;
import rx.operators.OperationGroupByUntil;
import rx.operators.OperationGroupJoin;
import rx.operators.OperationInterval;
import rx.operators.OperationJoin;
import rx.operators.OperationJoinPatterns;
import rx.operators.OperationMaterialize;
import rx.operators.OperationMergeDelayError;
import rx.operators.OperationMergeMaxConcurrent;
import rx.operators.OperationMinMax;
import rx.operators.OperationMulticast;
import rx.operators.OperationOnErrorResumeNextViaObservable;
import rx.operators.OperationOnErrorReturn;
import rx.operators.OperationOnExceptionResumeNextViaObservable;
import rx.operators.OperationParallelMerge;
import rx.operators.OperationReplay;
import rx.operators.OperationSample;
import rx.operators.OperationSequenceEqual;
import rx.operators.OperationSingle;
import rx.operators.OperationSkip;
import rx.operators.OperationSkipLast;
import rx.operators.OperationSkipUntil;
import rx.operators.OperationSum;
import rx.operators.OperationSwitch;
import rx.operators.OperationTakeLast;
import rx.operators.OperationTakeTimed;
import rx.operators.OperationTakeUntil;
import rx.operators.OperationTakeWhile;
import rx.operators.OperationThrottleFirst;
import rx.operators.OperationTimeInterval;
import rx.operators.OperationTimer;
import rx.operators.OperationToMap;
import rx.operators.OperationToMultimap;
import rx.operators.OperationToObservableFuture;
import rx.operators.OperationUsing;
import rx.operators.OperationWindow;
import rx.operators.OperatorAmb;
import rx.operators.OperatorCast;
import rx.operators.OperatorDoOnEach;
import rx.operators.OperatorFilter;
import rx.operators.OperatorGroupBy;
import rx.operators.OperatorMap;
import rx.operators.OperatorMerge;
import rx.operators.OperatorObserveOn;
import rx.operators.OperatorOnErrorFlatMap;
import rx.operators.OperatorOnErrorResumeNextViaFunction;
import rx.operators.OperatorParallel;
import rx.operators.OperatorRepeat;
import rx.operators.OperatorRetry;
import rx.operators.OperatorScan;
import rx.operators.OperatorSerialize;
import rx.operators.OperatorSkip;
import rx.operators.OperatorSkipWhile;
import rx.operators.OperatorSubscribeOn;
import rx.operators.OperatorSynchronize;
import rx.operators.OperatorTake;
import rx.operators.OperatorTimeout;
import rx.operators.OperatorTimeoutWithSelector;
import rx.operators.OperatorTimestamp;
import rx.operators.OperatorToObservableList;
import rx.operators.OperatorToObservableSortedList;
import rx.operators.OperatorUnsubscribeOn;
import rx.operators.OperatorZip;
import rx.operators.OperatorZipIterable;
import rx.plugins.RxJavaObservableExecutionHook;
import rx.plugins.RxJavaPlugins;
import rx.schedulers.Schedulers;
import rx.schedulers.TimeInterval;
import rx.schedulers.Timestamped;
import rx.subjects.AsyncSubject;
import rx.subjects.BehaviorSubject;
import rx.subjects.PublishSubject;
import rx.subjects.ReplaySubject;
import rx.subjects.Subject;
import rx.subscriptions.Subscriptions;
/**
* The Observable class that implements the Reactive Pattern.
*
* This class provides methods for subscribing to the Observable as well as delegate methods to the various
* Observers.
*
* The documentation for this class makes use of marble diagrams. The following legend explains these diagrams:
*
*
*
* For more information see the RxJava Wiki
*
* @param
* the type of the items emitted by the Observable
*/
public class Observable {
final OnSubscribe onSubscribe;
/**
* Observable with Function to execute when subscribed to.
*
* Note: Use {@link #create(OnSubscribe)} to create an Observable, instead of this constructor,
* unless you specifically have a need for inheritance.
*
* @param f
* {@link OnSubscribe} to be executed when {@link #subscribe(Subscriber)} is called
*/
protected Observable(OnSubscribe f) {
this.onSubscribe = f;
}
private final RxJavaObservableExecutionHook hook = RxJavaPlugins.getInstance().getObservableExecutionHook();
/**
* Returns an Observable that will execute the specified function when a {@link Subscriber} subscribes to
* it.
*
*
*
* Write the function you pass to {@code create} so that it behaves as an Observable: It should invoke the
* Subscriber's {@link Subscriber#onNext onNext}, {@link Subscriber#onError onError}, and
* {@link Subscriber#onCompleted onCompleted} methods appropriately.
*
* A well-formed Observable must invoke either the Subscriber's {@code onCompleted} method exactly once or
* its {@code onError} method exactly once.
*
* See Rx Design Guidelines (PDF) for detailed
* information.
*
* @param
* the type of the items that this Observable emits
* @param f
* a function that accepts an {@code Subscriber}, and invokes its {@code onNext},
* {@code onError}, and {@code onCompleted} methods as appropriate
* @return an Observable that, when a {@link Subscriber} subscribes to it, will execute the specified
* function
* @see RxJava Wiki: create()
* @see MSDN: Observable.Create
*/
public final static Observable create(OnSubscribe f) {
return new Observable(f);
}
/**
* Invoked when Obserable.subscribe is called.
*/
public static interface OnSubscribe extends Action1> {
// cover for generics insanity
}
/**
* Operator function for lifting into an Observable.
*/
public interface Operator extends Func1, Subscriber super T>> {
// cover for generics insanity
}
/**
* @deprecated use {@link #create(OnSubscribe)}
*/
@Deprecated
public final static Observable create(final OnSubscribeFunc f) {
return new Observable(new OnSubscribe() {
@Override
public void call(Subscriber super T> observer) {
Subscription s = f.onSubscribe(observer);
if (s != null && s != observer) {
observer.add(s);
}
}
});
}
/**
*
*/
public static interface OnSubscribeFunc extends Function {
public Subscription onSubscribe(Observer super T> op);
}
/**
* Lift a function to the current Observable and return a new Observable that when subscribed to will pass
* the values of the current Observable through the function.
*
* In other words, this allows chaining Observers together on an Observable for acting on the values within
* the Observable.
*
{@code
* observable.map(...).filter(...).take(5).lift(new ObserverA()).lift(new ObserverB(...)).subscribe()
* }
*
* @param lift
* @return an Observable that emits values that are the result of applying the bind function to the values
* of the current Observable
*/
public Observable lift(final Operator extends R, ? super T> lift) {
return new Observable(new OnSubscribe() {
@Override
public void call(Subscriber super R> o) {
try {
onSubscribe.call(hook.onLift(lift).call(o));
} catch (Throwable e) {
// localized capture of errors rather than it skipping all operators
// and ending up in the try/catch of the subscribe method which then
// prevents onErrorResumeNext and other similar approaches to error handling
if (e instanceof OnErrorNotImplementedException) {
throw (OnErrorNotImplementedException) e;
}
o.onError(e);
}
}
});
}
/* *********************************************************************************************************
* Observers Below Here
* *********************************************************************************************************
*/
/**
* Mirror the one Observable in an Iterable of several Observables that first emits an item.
*
*
*
* @param sources
* an Iterable of Observable sources competing to react first
* @return an Observable that emits the same sequence of items as whichever of the source Observables first
* emitted an item
* @see RxJava Wiki: amb()
* @see MSDN: Observable.Amb
*/
public final static Observable amb(Iterable extends Observable extends T>> sources) {
return create(OperatorAmb.amb(sources));
}
/**
* Given two Observables, mirror the one that first emits an item.
*
*
*
* @param o1
* an Observable competing to react first
* @param o2
* an Observable competing to react first
* @return an Observable that emits the same sequence of items as whichever of the source Observables first
* emitted an item
* @see RxJava Wiki: amb()
* @see MSDN: Observable.Amb
*/
public final static Observable amb(Observable extends T> o1, Observable extends T> o2) {
return create(OperatorAmb.amb(o1, o2));
}
/**
* Given three Observables, mirror the one that first emits an item.
*
*
*
* @param o1
* an Observable competing to react first
* @param o2
* an Observable competing to react first
* @param o3
* an Observable competing to react first
* @return an Observable that emits the same sequence of items as whichever of the source Observables first
* emitted an item
* @see RxJava Wiki: amb()
* @see MSDN: Observable.Amb
*/
public final static Observable amb(Observable extends T> o1, Observable extends T> o2, Observable extends T> o3) {
return create(OperatorAmb.amb(o1, o2, o3));
}
/**
* Given four Observables, mirror the one that first emits an item.
*
*
*
* @param o1
* an Observable competing to react first
* @param o2
* an Observable competing to react first
* @param o3
* an Observable competing to react first
* @param o4
* an Observable competing to react first
* @return an Observable that emits the same sequence of items as whichever of the source Observables first
* emitted an item
* @see RxJava Wiki: amb()
* @see MSDN: Observable.Amb
*/
public final static Observable amb(Observable extends T> o1, Observable extends T> o2, Observable extends T> o3, Observable extends T> o4) {
return create(OperatorAmb.amb(o1, o2, o3, o4));
}
/**
* Given five Observables, mirror the one that first emits an item.
*
*
*
* @param o1
* an Observable competing to react first
* @param o2
* an Observable competing to react first
* @param o3
* an Observable competing to react first
* @param o4
* an Observable competing to react first
* @param o5
* an Observable competing to react first
* @return an Observable that emits the same sequence of items as whichever of the source Observables first
* emitted an item
* @see RxJava Wiki: amb()
* @see MSDN: Observable.Amb
*/
public final static Observable amb(Observable extends T> o1, Observable extends T> o2, Observable extends T> o3, Observable extends T> o4, Observable extends T> o5) {
return create(OperatorAmb.amb(o1, o2, o3, o4, o5));
}
/**
* Given six Observables, mirror the one that first emits an item.
*
*
*
* @param o1
* an Observable competing to react first
* @param o2
* an Observable competing to react first
* @param o3
* an Observable competing to react first
* @param o4
* an Observable competing to react first
* @param o5
* an Observable competing to react first
* @param o6
* an Observable competing to react first
* @return an Observable that emits the same sequence of items as whichever of the source Observables first
* emitted an item
* @see RxJava Wiki: amb()
* @see MSDN: Observable.Amb
*/
public final static Observable amb(Observable extends T> o1, Observable extends T> o2, Observable extends T> o3, Observable extends T> o4, Observable extends T> o5, Observable extends T> o6) {
return create(OperatorAmb.amb(o1, o2, o3, o4, o5, o6));
}
/**
* Given seven Observables, mirror the one that first emits an item.
*
*
*
* @param o1
* an Observable competing to react first
* @param o2
* an Observable competing to react first
* @param o3
* an Observable competing to react first
* @param o4
* an Observable competing to react first
* @param o5
* an Observable competing to react first
* @param o6
* an Observable competing to react first
* @param o7
* an Observable competing to react first
* @return an Observable that emits the same sequence of items as whichever of the source Observables first
* emitted an item
* @see RxJava Wiki: amb()
* @see MSDN: Observable.Amb
*/
public final static Observable amb(Observable extends T> o1, Observable extends T> o2, Observable extends T> o3, Observable extends T> o4, Observable extends T> o5, Observable extends T> o6, Observable extends T> o7) {
return create(OperatorAmb.amb(o1, o2, o3, o4, o5, o6, o7));
}
/**
* Given eight Observables, mirror the one that first emits an item.
*
*
*
* @param o1
* an Observable competing to react first
* @param o2
* an Observable competing to react first
* @param o3
* an Observable competing to react first
* @param o4
* an Observable competing to react first
* @param o5
* an Observable competing to react first
* @param o6
* an Observable competing to react first
* @param o7
* an Observable competing to react first
* @param o8
* an observable competing to react first
* @return an Observable that emits the same sequence of items as whichever of the source Observables first
* emitted an item
* @see RxJava Wiki: amb()
* @see MSDN: Observable.Amb
*/
public final static Observable amb(Observable extends T> o1, Observable extends T> o2, Observable extends T> o3, Observable extends T> o4, Observable extends T> o5, Observable extends T> o6, Observable extends T> o7, Observable extends T> o8) {
return create(OperatorAmb.amb(o1, o2, o3, o4, o5, o6, o7, o8));
}
/**
* Given nine Observables, mirror the one that first emits an item.
*
*
*
* @param o1
* an Observable competing to react first
* @param o2
* an Observable competing to react first
* @param o3
* an Observable competing to react first
* @param o4
* an Observable competing to react first
* @param o5
* an Observable competing to react first
* @param o6
* an Observable competing to react first
* @param o7
* an Observable competing to react first
* @param o8
* an Observable competing to react first
* @param o9
* an Observable competing to react first
* @return an Observable that emits the same sequence of items as whichever of the source Observables first
* emitted an item
* @see RxJava Wiki: amb()
* @see MSDN: Observable.Amb
*/
public final static Observable amb(Observable extends T> o1, Observable extends T> o2, Observable extends T> o3, Observable extends T> o4, Observable extends T> o5, Observable extends T> o6, Observable extends T> o7, Observable extends T> o8, Observable extends T> o9) {
return create(OperatorAmb.amb(o1, o2, o3, o4, o5, o6, o7, o8, o9));
}
/**
* @deprecated use {@link #averageInteger}
*/
@Deprecated
public final static Observable average(Observable source) {
return OperationAverage.average(source);
}
/**
* Returns an Observable that emits the average of the Doubles emitted by the source Observable.
*
*
*
* @param source
* source Observable to compute the average of
* @return an Observable that emits a single item: the average of all the Doubles emitted by the source
* Observable
* @see RxJava Wiki: averageDouble()
* @see MSDN: Observable.Average
* @deprecated Use rxjava-math module instead
*/
public final static Observable averageDouble(Observable source) {
return OperationAverage.averageDoubles(source);
}
/**
* Returns an Observable that emits the average of the Floats emitted by the source Observable.
*
*
*
* @param source
* source Observable to compute the average of
* @return an Observable that emits a single item: the average of all the Floats emitted by the source
* Observable
* @see RxJava Wiki: averageFloat()
* @see MSDN: Observable.Average
* @deprecated Use rxjava-math module instead
*/
public final static Observable averageFloat(Observable source) {
return OperationAverage.averageFloats(source);
}
/**
* Returns an Observable that emits the average of the Integers emitted by the source Observable.
*
*
*
* @param source
* source Observable to compute the average of
* @return an Observable that emits a single item: the average of all the Integers emitted by the source
* Observable
* @throws IllegalArgumentException
* if the source Observable emits no items
* @see RxJava Wiki: averageInteger()
* @see MSDN: Observable.Average
* @deprecated Use rxjava-math module instead
*/
public final static Observable averageInteger(Observable source) {
return OperationAverage.average(source);
}
/**
* Returns an Observable that emits the average of the Longs emitted by the source Observable.
*
*
*
* @param source
* source Observable to compute the average of
* @return an Observable that emits a single item: the average of all the Longs emitted by the source
* Observable
* @see RxJava Wiki: averageLong()
* @see MSDN: Observable.Average
* @deprecated Use rxjava-math module instead
*/
public final static Observable averageLong(Observable source) {
return OperationAverage.averageLongs(source);
}
/**
* Combines two source Observables by emitting an item that aggregates the latest values of each of the
* source Observables each time an item is received from either of the source Observables, where this
* aggregation is defined by a specified function.
*
*
*
* @param o1
* the first source Observable
* @param o2
* the second source Observable
* @param combineFunction
* the aggregation function used to combine the items emitted by the source Observables
* @return an Observable that emits items that are the result of combining the items emitted by the source
* Observables by means of the given aggregation function
* @see RxJava Wiki: combineLatest()
*/
public final static Observable combineLatest(Observable extends T1> o1, Observable extends T2> o2, Func2 super T1, ? super T2, ? extends R> combineFunction) {
return create(OperationCombineLatest.combineLatest(o1, o2, combineFunction));
}
/**
* Combines three source Observables by emitting an item that aggregates the latest values of each of the
* source Observables each time an item is received from any of the source Observables, where this
* aggregation is defined by a specified function.
*
*
*
* @param o1
* the first source Observable
* @param o2
* the second source Observable
* @param o3
* the third source Observable
* @param combineFunction
* the aggregation function used to combine the items emitted by the source Observables
* @return an Observable that emits items that are the result of combining the items emitted by the source
* Observables by means of the given aggregation function
* @see RxJava Wiki: combineLatest()
*/
public final static Observable combineLatest(Observable extends T1> o1, Observable extends T2> o2, Observable extends T3> o3, Func3 super T1, ? super T2, ? super T3, ? extends R> combineFunction) {
return create(OperationCombineLatest.combineLatest(o1, o2, o3, combineFunction));
}
/**
* Combines four source Observables by emitting an item that aggregates the latest values of each of the
* source Observables each time an item is received from any of the source Observables, where this
* aggregation is defined by a specified function.
*
*
*
* @param o1
* the first source Observable
* @param o2
* the second source Observable
* @param o3
* the third source Observable
* @param o4
* the fourth source Observable
* @param combineFunction
* the aggregation function used to combine the items emitted by the source Observables
* @return an Observable that emits items that are the result of combining the items emitted by the source
* Observables by means of the given aggregation function
* @see RxJava Wiki: combineLatest()
*/
public final static Observable combineLatest(Observable extends T1> o1, Observable extends T2> o2, Observable extends T3> o3, Observable extends T4> o4,
Func4 super T1, ? super T2, ? super T3, ? super T4, ? extends R> combineFunction) {
return create(OperationCombineLatest.combineLatest(o1, o2, o3, o4, combineFunction));
}
/**
* Combines five source Observables by emitting an item that aggregates the latest values of each of the
* source Observables each time an item is received from any of the source Observables, where this
* aggregation is defined by a specified function.
*
*
*
* @param o1
* the first source Observable
* @param o2
* the second source Observable
* @param o3
* the third source Observable
* @param o4
* the fourth source Observable
* @param o5
* the fifth source Observable
* @param combineFunction
* the aggregation function used to combine the items emitted by the source Observables
* @return an Observable that emits items that are the result of combining the items emitted by the source
* Observables by means of the given aggregation function
* @see RxJava Wiki: combineLatest()
*/
public final static Observable combineLatest(Observable extends T1> o1, Observable extends T2> o2, Observable extends T3> o3, Observable extends T4> o4, Observable extends T5> o5,
Func5 super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? extends R> combineFunction) {
return create(OperationCombineLatest.combineLatest(o1, o2, o3, o4, o5, combineFunction));
}
/**
* Combines six source Observables by emitting an item that aggregates the latest values of each of the
* source Observables each time an item is received from any of the source Observables, where this
* aggregation is defined by a specified function.
*
*
*
* @param o1
* the first source Observable
* @param o2
* the second source Observable
* @param o3
* the third source Observable
* @param o4
* the fourth source Observable
* @param o5
* the fifth source Observable
* @param o6
* the sixth source Observable
* @param combineFunction
* the aggregation function used to combine the items emitted by the source Observables
* @return an Observable that emits items that are the result of combining the items emitted by the source
* Observables by means of the given aggregation function
* @see RxJava Wiki: combineLatest()
*/
public final static Observable combineLatest(Observable extends T1> o1, Observable extends T2> o2, Observable extends T3> o3, Observable extends T4> o4, Observable extends T5> o5, Observable extends T6> o6,
Func6 super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? extends R> combineFunction) {
return create(OperationCombineLatest.combineLatest(o1, o2, o3, o4, o5, o6, combineFunction));
}
/**
* Combines seven source Observables by emitting an item that aggregates the latest values of each of the
* source Observables each time an item is received from any of the source Observables, where this
* aggregation is defined by a specified function.
*
*
*
* @param o1
* the first source Observable
* @param o2
* the second source Observable
* @param o3
* the third source Observable
* @param o4
* the fourth source Observable
* @param o5
* the fifth source Observable
* @param o6
* the sixth source Observable
* @param o7
* the seventh source Observable
* @param combineFunction
* the aggregation function used to combine the items emitted by the source Observables
* @return an Observable that emits items that are the result of combining the items emitted by the source
* Observables by means of the given aggregation function
* @see RxJava Wiki: combineLatest()
*/
public final static Observable combineLatest(Observable extends T1> o1, Observable extends T2> o2, Observable extends T3> o3, Observable extends T4> o4, Observable extends T5> o5, Observable extends T6> o6, Observable extends T7> o7,
Func7 super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? extends R> combineFunction) {
return create(OperationCombineLatest.combineLatest(o1, o2, o3, o4, o5, o6, o7, combineFunction));
}
/**
* Combines eight source Observables by emitting an item that aggregates the latest values of each of the
* source Observables each time an item is received from any of the source Observables, where this
* aggregation is defined by a specified function.
*
*
*
* @param o1
* the first source Observable
* @param o2
* the second source Observable
* @param o3
* the third source Observable
* @param o4
* the fourth source Observable
* @param o5
* the fifth source Observable
* @param o6
* the sixth source Observable
* @param o7
* the seventh source Observable
* @param o8
* the eighth source Observable
* @param combineFunction
* the aggregation function used to combine the items emitted by the source Observables
* @return an Observable that emits items that are the result of combining the items emitted by the source
* Observables by means of the given aggregation function
* @see RxJava Wiki: combineLatest()
*/
public final static Observable combineLatest(Observable extends T1> o1, Observable extends T2> o2, Observable extends T3> o3, Observable extends T4> o4, Observable extends T5> o5, Observable extends T6> o6, Observable extends T7> o7, Observable extends T8> o8,
Func8 super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8, ? extends R> combineFunction) {
return create(OperationCombineLatest.combineLatest(o1, o2, o3, o4, o5, o6, o7, o8, combineFunction));
}
/**
* Combines nine source Observables by emitting an item that aggregates the latest values of each of the
* source Observables each time an item is received from any of the source Observables, where this
* aggregation is defined by a specified function.
*
*
*
* @param o1
* the first source Observable
* @param o2
* the second source Observable
* @param o3
* the third source Observable
* @param o4
* the fourth source Observable
* @param o5
* the fifth source Observable
* @param o6
* the sixth source Observable
* @param o7
* the seventh source Observable
* @param o8
* the eighth source Observable
* @param o9
* the ninth source Observable
* @param combineFunction
* the aggregation function used to combine the items emitted by the source Observables
* @return an Observable that emits items that are the result of combining the items emitted by the source
* Observables by means of the given aggregation function
* @see RxJava Wiki: combineLatest()
*/
public final static Observable combineLatest(Observable extends T1> o1, Observable extends T2> o2, Observable extends T3> o3, Observable extends T4> o4, Observable extends T5> o5, Observable extends T6> o6, Observable extends T7> o7, Observable extends T8> o8,
Observable extends T9> o9,
Func9 super T1, ? super T2, ? super T3, ? super T4, ? super T5, ? super T6, ? super T7, ? super T8, ? super T9, ? extends R> combineFunction) {
return create(OperationCombineLatest.combineLatest(o1, o2, o3, o4, o5, o6, o7, o8, o9, combineFunction));
}
/**
* Returns an Observable that emits the items emitted by each of the Observables emitted by an Observable,
* one after the other, without interleaving them.
*
*
*
* @param observables
* an Observable that emits Observables
* @return an Observable that emits items all of the items emitted by the Observables emitted by
* {@code observables}, one after the other, without interleaving them
* @see RxJava Wiki: concat()
* @see MSDN: Observable.Concat
*/
public final static Observable concat(Observable extends Observable extends T>> observables) {
return create(OperationConcat.concat(observables));
}
/**
* Returns an Observable that emits the items emitted by two Observables, one after the other, without
* interleaving them.
*
*
*
* @param t1
* an Observable to be concatenated
* @param t2
* an Observable to be concatenated
* @return an Observable that emits items emitted by the two source Observables, one after the other,
* without interleaving them
* @see RxJava Wiki: concat()
* @see MSDN: Observable.Concat
*/
@SuppressWarnings("unchecked")
// suppress because the types are checked by the method signature before using a vararg
public final static Observable concat(Observable extends T> t1, Observable extends T> t2) {
return create(OperationConcat.concat(t1, t2));
}
/**
* Returns an Observable that emits the items emitted by three Observables, one after the other, without
* interleaving them.
*
*
*
* @param t1
* an Observable to be concatenated
* @param t2
* an Observable to be concatenated
* @param t3
* an Observable to be concatenated
* @return an Observable that emits items emitted by the three source Observables, one after the other,
* without interleaving them
* @see RxJava Wiki: concat()
* @see MSDN: Observable.Concat
*/
@SuppressWarnings("unchecked")
// suppress because the types are checked by the method signature before using a vararg
public final static Observable concat(Observable extends T> t1, Observable extends T> t2, Observable extends T> t3) {
return create(OperationConcat.concat(t1, t2, t3));
}
/**
* Returns an Observable that emits the items emitted by four Observables, one after the other, without
* interleaving them.
*
*
*
* @param t1
* an Observable to be concatenated
* @param t2
* an Observable to be concatenated
* @param t3
* an Observable to be concatenated
* @param t4
* an Observable to be concatenated
* @return an Observable that emits items emitted by the four source Observables, one after the other,
* without interleaving them
* @see RxJava Wiki: concat()
* @see MSDN: Observable.Concat
*/
@SuppressWarnings("unchecked")
// suppress because the types are checked by the method signature before using a vararg
public final static Observable concat(Observable extends T> t1, Observable extends T> t2, Observable extends T> t3, Observable extends T> t4) {
return create(OperationConcat.concat(t1, t2, t3, t4));
}
/**
* Returns an Observable that emits the items emitted by five Observables, one after the other, without
* interleaving them.
*
*
*
* @param t1
* an Observable to be concatenated
* @param t2
* an Observable to be concatenated
* @param t3
* an Observable to be concatenated
* @param t4
* an Observable to be concatenated
* @param t5
* an Observable to be concatenated
* @return an Observable that emits items emitted by the five source Observables, one after the other,
* without interleaving them
* @see RxJava Wiki: concat()
* @see MSDN: Observable.Concat
*/
@SuppressWarnings("unchecked")
// suppress because the types are checked by the method signature before using a vararg
public final static Observable concat(Observable extends T> t1, Observable extends T> t2, Observable extends T> t3, Observable extends T> t4, Observable extends T> t5) {
return create(OperationConcat.concat(t1, t2, t3, t4, t5));
}
/**
* Returns an Observable that emits the items emitted by six Observables, one after the other, without
* interleaving them.
*
*
*
* @param t1
* an Observable to be concatenated
* @param t2
* an Observable to be concatenated
* @param t3
* an Observable to be concatenated
* @param t4
* an Observable to be concatenated
* @param t5
* an Observable to be concatenated
* @param t6
* an Observable to be concatenated
* @return an Observable that emits items emitted by the six source Observables, one after the other,
* without interleaving them
* @see RxJava Wiki: concat()
* @see MSDN: Observable.Concat
*/
@SuppressWarnings("unchecked")
// suppress because the types are checked by the method signature before using a vararg
public final static Observable concat(Observable extends T> t1, Observable extends T> t2, Observable extends T> t3, Observable extends T> t4, Observable extends T> t5, Observable extends T> t6) {
return create(OperationConcat.concat(t1, t2, t3, t4, t5, t6));
}
/**
* Returns an Observable that emits the items emitted by seven Observables, one after the other, without
* interleaving them.
*
*
*
* @param t1
* an Observable to be concatenated
* @param t2
* an Observable to be concatenated
* @param t3
* an Observable to be concatenated
* @param t4
* an Observable to be concatenated
* @param t5
* an Observable to be concatenated
* @param t6
* an Observable to be concatenated
* @param t7
* an Observable to be concatenated
* @return an Observable that emits items emitted by the seven source Observables, one after the other,
* without interleaving them
* @see RxJava Wiki: concat()
* @see MSDN: Observable.Concat
*/
@SuppressWarnings("unchecked")
// suppress because the types are checked by the method signature before using a vararg
public final static Observable concat(Observable extends T> t1, Observable extends T> t2, Observable extends T> t3, Observable extends T> t4, Observable extends T> t5, Observable extends T> t6, Observable extends T> t7) {
return create(OperationConcat.concat(t1, t2, t3, t4, t5, t6, t7));
}
/**
* Returns an Observable that emits the items emitted by eight Observables, one after the other, without
* interleaving them.
*
*
*
* @param t1
* an Observable to be concatenated
* @param t2
* an Observable to be concatenated
* @param t3
* an Observable to be concatenated
* @param t4
* an Observable to be concatenated
* @param t5
* an Observable to be concatenated
* @param t6
* an Observable to be concatenated
* @param t7
* an Observable to be concatenated
* @param t8
* an Observable to be concatenated
* @return an Observable that emits items emitted by the eight source Observables, one after the other,
* without interleaving them
* @see RxJava Wiki: concat()
* @see MSDN: Observable.Concat
*/
@SuppressWarnings("unchecked")
// suppress because the types are checked by the method signature before using a vararg
public final static Observable concat(Observable extends T> t1, Observable extends T> t2, Observable extends T> t3, Observable extends T> t4, Observable extends T> t5, Observable extends T> t6, Observable extends T> t7, Observable extends T> t8) {
return create(OperationConcat.concat(t1, t2, t3, t4, t5, t6, t7, t8));
}
/**
* Returns an Observable that emits the items emitted by nine Observables, one after the other, without
* interleaving them.
*
*
*
* @param t1
* an Observable to be concatenated
* @param t2
* an Observable to be concatenated
* @param t3
* an Observable to be concatenated
* @param t4
* an Observable to be concatenated
* @param t5
* an Observable to be concatenated
* @param t6
* an Observable to be concatenated
* @param t7
* an Observable to be concatenated
* @param t8
* an Observable to be concatenated
* @param t9
* an Observable to be concatenated
* @return an Observable that emits items emitted by the nine source Observables, one after the other,
* without interleaving them
* @see RxJava Wiki: concat()
* @see MSDN: Observable.Concat
*/
@SuppressWarnings("unchecked")
// suppress because the types are checked by the method signature before using a vararg
public final static Observable concat(Observable extends T> t1, Observable extends T> t2, Observable extends T> t3, Observable extends T> t4, Observable extends T> t5, Observable extends T> t6, Observable extends T> t7, Observable extends T> t8, Observable extends T> t9) {
return create(OperationConcat.concat(t1, t2, t3, t4, t5, t6, t7, t8, t9));
}
/**
* Returns an Observable that calls an Observable factory to create its Observable for each new Observer
* that subscribes. That is, for each subscriber, the actual Observable that subscriber observes is
* determined by the factory function.
*
*
*
* The defer Observer allows you to defer or delay emitting items from an Observable until such time as an
* Observer subscribes to the Observable. This allows an {@link Observer} to easily obtain updates or a
* refreshed version of the sequence.
*
* @param observableFactory
* the Observable factory function to invoke for each {@link Observer} that subscribes to the
* resulting Observable
* @param
* the type of the items emitted by the Observable
* @return an Observable whose {@link Observer}s' subscriptions trigger an invocation of the given
* Observable factory function
* @see RxJava Wiki: defer()
*/
public final static Observable defer(Func0 extends Observable extends T>> observableFactory) {
return create(OperationDefer.defer(observableFactory));
}
/**
* Returns an Observable that emits no items to the {@link Observer} and immediately invokes its
* {@link Observer#onCompleted onCompleted} method.
*
*
*
* @param
* the type of the items (ostensibly) emitted by the Observable
* @return an Observable that emits no items to the {@link Observer} but immediately invokes the
* {@link Observer}'s {@link Observer#onCompleted() onCompleted} method
* @see RxJava Wiki: empty()
* @see MSDN: Observable.Empty
*/
public final static Observable empty() {
return from(new ArrayList());
}
/**
* Returns an Observable that emits no items to the {@link Observer} and immediately invokes its
* {@link Observer#onCompleted onCompleted} method on the specified Scheduler.
*
*
*
* @param scheduler
* the Scheduler to use to call the {@link Observer#onCompleted onCompleted} method
* @param
* the type of the items (ostensibly) emitted by the Observable
* @return an Observable that emits no items to the {@link Observer} but immediately invokes the
* {@link Observer}'s {@link Observer#onCompleted() onCompleted} method with the specified
* {@code scheduler}
* @see RxJava Wiki: empty()
* @see MSDN: Observable.Empty Method (IScheduler)
*/
public final static Observable empty(Scheduler scheduler) {
return Observable. empty().subscribeOn(scheduler);
}
/**
* Returns an Observable that invokes an {@link Observer}'s {@link Observer#onError onError} method when the
* Observer subscribes to it.
*
*
*
* @param exception
* the particular Throwable to pass to {@link Observer#onError onError}
* @param
* the type of the items (ostensibly) emitted by the Observable
* @return an Observable that invokes the {@link Observer}'s {@link Observer#onError onError} method when
* the Observer subscribes to it
* @see RxJava Wiki: error()
* @see MSDN: Observable.Throw
*/
public final static Observable error(Throwable exception) {
return new ThrowObservable(exception);
}
/**
* Returns an Observable that invokes an {@link Observer}'s {@link Observer#onError onError} method on the
* specified Scheduler.
*
*
*
* @param exception
* the particular Throwable to pass to {@link Observer#onError onError}
* @param scheduler
* the Scheduler on which to call {@link Observer#onError onError}
* @param
* the type of the items (ostensibly) emitted by the Observable
* @return an Observable that invokes the {@link Observer}'s {@link Observer#onError onError} method, on
* the specified Scheduler
* @see RxJava Wiki: error()
* @see MSDN: Observable.Throw
*/
public final static Observable error(Throwable exception, Scheduler scheduler) {
return Observable. error(exception).subscribeOn(scheduler);
}
/**
* Converts a {@link Future} into an Observable.
*
*
*
* You can convert any object that supports the {@link Future} interface into an Observable that emits the
* return value of the {@link Future#get} method of that object, by passing the object into the {@code from}
* method.
*
* Important note: This Observable is blocking; you cannot unsubscribe from it.
*
* @param future
* the source {@link Future}
* @param
* the type of object that the {@link Future} returns, and also the type of item to be emitted by
* the resulting Observable
* @return an Observable that emits the item from the source {@link Future}
* @see RxJava Wiki: from()
*/
public final static Observable from(Future extends T> future) {
return create(OperationToObservableFuture.toObservableFuture(future));
}
/**
* Converts a {@link Future} into an Observable, with a timeout on the Future.
*
*
*
* You can convert any object that supports the {@link Future} interface into an Observable that emits the
* return value of the {@link Future#get} method of that object, by passing the object into the {@code from}
* method.
*
* Important note: This Observable is blocking; you cannot unsubscribe from it.
*
* @param future
* the source {@link Future}
* @param timeout
* the maximum time to wait before calling {@code get()}
* @param unit
* the {@link TimeUnit} of the {@code timeout} argument
* @param
* the type of object that the {@link Future} returns, and also the type of item to be emitted by
* the resulting Observable
* @return an Observable that emits the item from the source {@link Future}
* @see RxJava Wiki: from()
*/
public final static Observable from(Future extends T> future, long timeout, TimeUnit unit) {
return create(OperationToObservableFuture.toObservableFuture(future, timeout, unit));
}
/**
* Converts a {@link Future}, operating on a specified {@link Scheduler}, into an Observable.
*
*
*
* You can convert any object that supports the {@link Future} interface into an Observable that emits the
* return value of the {@link Future#get} method of that object, by passing the object into the {@code from}
* method.
*
*
* @param future
* the source {@link Future}
* @param scheduler
* the {@link Scheduler} to wait for the Future on. Use a Scheduler such as
* {@link Schedulers#io()} that can block and wait on the Future
* @param
* the type of object that the {@link Future} returns, and also the type of item to be emitted by
* the resulting Observable
* @return an Observable that emits the item from the source {@link Future}
* @see RxJava Wiki: from()
*/
public final static Observable from(Future extends T> future, Scheduler scheduler) {
return create(OperationToObservableFuture.toObservableFuture(future)).subscribeOn(scheduler);
}
/**
* Converts an {@link Iterable} sequence into an Observable that emits the items in the sequence.
*
*
*
* @param iterable
* the source {@link Iterable} sequence
* @param
* the type of items in the {@link Iterable} sequence and the type of items to be emitted by the
* resulting Observable
* @return an Observable that emits each item in the source {@link Iterable} sequence
* @see RxJava Wiki: from()
*/
public final static Observable from(Iterable extends T> iterable) {
return create(new OnSubscribeFromIterable(iterable));
}
/**
* Converts an {@link Iterable} sequence into an Observable that operates on the specified Scheduler,
* emitting each item from the sequence.
*
*
*
* @param iterable
* the source {@link Iterable} sequence
* @param scheduler
* the Scheduler on which the Observable is to emit the items of the Iterable
* @param
* the type of items in the {@link Iterable} sequence and the type of items to be emitted by the
* resulting Observable
* @return an Observable that emits each item in the source {@link Iterable} sequence, on the specified
* Scheduler
* @see RxJava Wiki: from()
* @see MSDN: Observable.ToObservable
*/
public final static Observable from(Iterable extends T> iterable, Scheduler scheduler) {
return create(new OnSubscribeFromIterable(iterable)).subscribeOn(scheduler);
}
/**
* Converts an item into an Observable that emits that item.
*
*
*
* @param t1
* the item
* @param
* the type of the item
* @return an Observable that emits the item
* @see RxJava Wiki: from()
*/
// suppress unchecked because we are using varargs inside the method
public final static Observable from(T t1) {
return from(Arrays.asList(t1));
}
/**
* Converts two items into an Observable that emits those items.
*
*
*
* @param t1
* first item
* @param t2
* second item
* @param
* the type of these items
* @return an Observable that emits each item
* @see RxJava Wiki: from()
* @deprecated use {@link #from(Iterable)} instead such as {@code from(Arrays.asList(t1,t2))}
*/
@Deprecated
// suppress unchecked because we are using varargs inside the method
public final static Observable from(T t1, T t2) {
return from(Arrays.asList(t1, t2));
}
/**
* Converts three items into an Observable that emits those items.
*
*
*
* @param t1
* first item
* @param t2
* second item
* @param t3
* third item
* @param
* the type of these items
* @return an Observable that emits each item
* @see RxJava Wiki: from()
* @deprecated use {@link #from(Iterable)} instead such as {@code from(Arrays.asList(t1,t2,t3))}.
*/
@Deprecated
// suppress unchecked because we are using varargs inside the method
public final static Observable from(T t1, T t2, T t3) {
return from(Arrays.asList(t1, t2, t3));
}
/**
* Converts four items into an Observable that emits those items.
*
*
*
* @param t1
* first item
* @param t2
* second item
* @param t3
* third item
* @param t4
* fourth item
* @param
* the type of these items
* @return an Observable that emits each item
* @see RxJava Wiki: from()
* @deprecated use {@link #from(Iterable)} instead such as {@code from(Arrays.asList(t1,t2,t3,t4))}.
*/
@Deprecated
// suppress unchecked because we are using varargs inside the method
public final static Observable from(T t1, T t2, T t3, T t4) {
return from(Arrays.asList(t1, t2, t3, t4));
}
/**
* Converts five items into an Observable that emits those items.
*
*
*
* @param t1
* first item
* @param t2
* second item
* @param t3
* third item
* @param t4
* fourth item
* @param t5
* fifth item
* @param
* the type of these items
* @return an Observable that emits each item
* @see RxJava Wiki: from()
* @deprecated use {@link #from(Iterable)} instead such as {@code from(Arrays.asList(t1,t2,t3,t4,t5))}.
*/
@Deprecated
// suppress unchecked because we are using varargs inside the method
public final static Observable from(T t1, T t2, T t3, T t4, T t5) {
return from(Arrays.asList(t1, t2, t3, t4, t5));
}
/**
* Converts six items into an Observable that emits those items.
*
*
*
* @param t1
* first item
* @param t2
* second item
* @param t3
* third item
* @param t4
* fourth item
* @param t5
* fifth item
* @param t6
* sixth item
* @param
* the type of these items
* @return an Observable that emits each item
* @see RxJava Wiki: from()
* @deprecated use {@link #from(Iterable)} instead such as {@code from(Arrays.asList(t1,t2,t3,t4,t5,t6))}.
*/
@Deprecated
// suppress unchecked because we are using varargs inside the method
public final static Observable from(T t1, T t2, T t3, T t4, T t5, T t6) {
return from(Arrays.asList(t1, t2, t3, t4, t5, t6));
}
/**
* Converts seven items into an Observable that emits those items.
*
*
*
* @param t1
* first item
* @param t2
* second item
* @param t3
* third item
* @param t4
* fourth item
* @param t5
* fifth item
* @param t6
* sixth item
* @param t7
* seventh item
* @param
* the type of these items
* @return an Observable that emits each item
* @see RxJava Wiki: from()
* @deprecated use {@link #from(Iterable)} instead such as {@code from(Arrays.asList(t1,t2,t3,t4,t5,t6,t7))}.
*/
@Deprecated
// suppress unchecked because we are using varargs inside the method
public final static Observable from(T t1, T t2, T t3, T t4, T t5, T t6, T t7) {
return from(Arrays.asList(t1, t2, t3, t4, t5, t6, t7));
}
/**
* Converts eight items into an Observable that emits those items.
*
*
*
* @param t1
* first item
* @param t2
* second item
* @param t3
* third item
* @param t4
* fourth item
* @param t5
* fifth item
* @param t6
* sixth item
* @param t7
* seventh item
* @param t8
* eighth item
* @param
* the type of these items
* @return an Observable that emits each item
* @see RxJava Wiki: from()
* @deprecated use {@link #from(Iterable)} instead such as {@code from(Arrays.asList(t1,t2,t3,t4,t5,t6,t7,t8))}.
*/
@Deprecated
// suppress unchecked because we are using varargs inside the method
public final static Observable from(T t1, T t2, T t3, T t4, T t5, T t6, T t7, T t8) {
return from(Arrays.asList(t1, t2, t3, t4, t5, t6, t7, t8));
}
/**
* Converts nine items into an Observable that emits those items.
*
*
*
* @param t1
* first item
* @param t2
* second item
* @param t3
* third item
* @param t4
* fourth item
* @param t5
* fifth item
* @param t6
* sixth item
* @param t7
* seventh item
* @param t8
* eighth item
* @param t9
* ninth item
* @param
* the type of these items
* @return an Observable that emits each item
* @see RxJava Wiki: from()
* @deprecated use {@link #from(Iterable)} instead such as {@code from(Arrays.asList(t1,t2,t3,t4,t5,t6,t7,t8,t9))}.
*/
@Deprecated
// suppress unchecked because we are using varargs inside the method
public final static Observable from(T t1, T t2, T t3, T t4, T t5, T t6, T t7, T t8, T t9) {
return from(Arrays.asList(t1, t2, t3, t4, t5, t6, t7, t8, t9));
}
/**
* Converts ten items into an Observable that emits those items.
*
*
*
*
* @param t1
* first item
* @param t2
* second item
* @param t3
* third item
* @param t4
* fourth item
* @param t5
* fifth item
* @param t6
* sixth item
* @param t7
* seventh item
* @param t8
* eighth item
* @param t9
* ninth item
* @param t10
* tenth item
* @param
* the type of these items
* @return an Observable that emits each item
* @see RxJava Wiki: from()
* @deprecated use {@link #from(Iterable)} instead such as {@code from(Arrays.asList(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10))}.
*/
@Deprecated
// suppress unchecked because we are using varargs inside the method
public final static Observable from(T t1, T t2, T t3, T t4, T t5, T t6, T t7, T t8, T t9, T t10) {
return from(Arrays.asList(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10));
}
/**
* Converts an Array into an Observable that emits the items in the Array.
*
*
*
* @param t1
* the source Array
* @param
* the type of items in the Array and the type of items to be emitted by the resulting Observable
* @return an Observable that emits each item in the source Array
* @see RxJava Wiki: from()
*/
// @SafeVarargs // commenting out until we figure out if we can do Java7 compilation without breaking Android for just this feature
public final static Observable from(T... t1) {
return from(Arrays.asList(t1));
}
/**
* Converts an Array into an Observable that emits the items in the Array on a specified Scheduler.
*
*
*
* @param items
* the source Array
* @param scheduler
* the Scheduler on which the Observable emits the items of the Array
* @param
* the type of items in the Array and the type of items to be emitted by the resulting Observable
* @return an Observable that emits each item in the source Array
* @see RxJava Wiki: from()
*/
public final static Observable from(T[] items, Scheduler scheduler) {
return from(Arrays.asList(items), scheduler);
}
/**
* Returns an Observable that emits a sequential number every specified interval of time.
*
*
*
* @param interval
* interval size in time units (see below)
* @param unit
* time units to use for the interval size
* @return an Observable that emits a sequential number each time interval
* @see RxJava Wiki: interval()
* @see MSDN: Observable.Interval
*/
public final static Observable interval(long interval, TimeUnit unit) {
return create(OperationInterval.interval(interval, unit));
}
/**
* Returns an Observable that emits a sequential number every specified interval of time, on a
* specified Scheduler.
*
*
*
* @param interval
* interval size in time units (see below)
* @param unit
* time units to use for the interval size
* @param scheduler
* the Scheduler to use for scheduling the items
* @return an Observable that emits a sequential number each time interval
* @see RxJava Wiki: interval()
* @see MSDN: Observable.Interval
*/
public final static Observable interval(long interval, TimeUnit unit, Scheduler scheduler) {
return create(OperationInterval.interval(interval, unit, scheduler));
}
/**
* Returns an Observable that emits a single item and then completes.
*
*
*
* To convert any object into an Observable that emits that object, pass that object into the {@code just}
* method.
*
* This is similar to the {@link #from(java.lang.Object[])} method, except that {@code from()} will convert
* an {@link Iterable} object into an Observable that emits each of the items in the Iterable, one at a
* time, while the {@code just()} method converts an Iterable into an Observable that emits the entire
* Iterable as a single item.
*
* @param value
* the item to emit
* @param
* the type of that item
* @return an Observable that emits {@code value} as a single item and then completes
* @see RxJava Wiki: just()
*/
public final static Observable just(T value) {
return from(Arrays.asList(value));
}
/**
* Returns an Observable that emits a single item and then completes, on a specified Scheduler.
*
*
*
* This is a scheduler version of {@link #just(Object)}.
*
* @param value
* the item to emit
* @param
* the type of that item
* @param scheduler
* the Scheduler to emit the single item on
* @return an Observable that emits {@code value} as a single item and then completes, on a specified
* Scheduler
* @see RxJava Wiki: just()
* @deprecated use {@link #from(T)}
*/
@Deprecated
public final static Observable just(T value, Scheduler scheduler) {
return from(Arrays.asList((value)), scheduler);
}
/**
* Returns an Observable that emits the single item emitted by the source Observable with the maximum
* numeric value. If there is more than one item with the same maximum value, it emits the last-emitted of
* these.
*
*
*
* @param source
* an Observable to scan for the maximum emitted item
* @return an Observable that emits this maximum item
* @throws IllegalArgumentException
* if the source is empty
* @see RxJava Wiki: max()
* @see MSDN: Observable.Max
* @deprecated use rxjava-math module instead
*/
public final static > Observable max(Observable source) {
return OperationMinMax.max(source);
}
/**
* Flattens an Iterable of Observables into one Observable, without any transformation.
*
*
*
* You can combine the items emitted by multiple Observables so that they appear as a single Observable, by
* using the {@code merge} method.
*
* @param sequences
* the Iterable of Observables
* @return an Observable that emits items that are the result of flattening the items emitted by the
* Observables in the Iterable
* @see RxJava Wiki: merge()
* @see MSDN: Observable.Merge
*/
public final static Observable merge(Iterable extends Observable extends T>> sequences) {
return merge(from(sequences));
}
/**
* Flattens an Iterable of Observables into one Observable, without any transformation, while limiting the
* number of concurrent subscriptions to these Observables.
*
*
*
* You can combine the items emitted by multiple Observables so that they appear as a single Observable, by
* using the {@code merge} method.
*
* @param sequences
* the Iterable of Observables
* @param maxConcurrent
* the maximum number of Observables that may be subscribed to concurrently
* @return an Observable that emits items that are the result of flattening the items emitted by the
* Observables in the Iterable
* @throws IllegalArgumentException
* if {@code maxConcurrent} is less than or equal to 0
* @see RxJava Wiki: merge()
* @see MSDN: Observable.Merge
*/
public final static Observable merge(Iterable extends Observable extends T>> sequences, int maxConcurrent) {
return merge(from(sequences), maxConcurrent);
}
/**
* Flattens an Iterable of Observables into one Observable, without any transformation, while limiting the
* number of concurrent subscriptions to these Observables, and subscribing to these Observables on a
* specified Scheduler.
*
*
*
* You can combine the items emitted by multiple Observables so that they appear as a single Observable, by
* using the {@code merge} method.
*
* @param sequences
* the Iterable of Observables
* @param maxConcurrent
* the maximum number of Observables that may be subscribed to concurrently
* @param scheduler
* the Scheduler on which to traverse the Iterable of Observables
* @return an Observable that emits items that are the result of flattening the items emitted by the
* Observables in the Iterable
* @throws IllegalArgumentException
* if {@code maxConcurrent} is less than or equal to 0
* @see RxJava Wiki: merge()
* @see MSDN: Observable.Merge
*/
public final static Observable merge(Iterable extends Observable extends T>> sequences, int maxConcurrent, Scheduler scheduler) {
return merge(from(sequences, scheduler), maxConcurrent);
}
/**
* Flattens an Iterable of Observables into one Observable, without any transformation, subscribing to these
* Observables on a specified Scheduler.
*
*
*
* You can combine the items emitted by multiple Observables so that they appear as a single Observable, by
* using the {@code merge} method.
*
* @param sequences
* the Iterable of Observables
* @param scheduler
* the Scheduler on which to traverse the Iterable of Observables
* @return an Observable that emits items that are the result of flattening the items emitted by the
* Observables in the Iterable
* @see RxJava Wiki: merge()
* @see MSDN: Observable.Merge
*/
public final static Observable merge(Iterable extends Observable extends T>> sequences, Scheduler scheduler) {
return merge(from(sequences, scheduler));
}
/**
* Flattens an Observable that emits Observables into a single Observable that emits the items emitted by
* those Observables, without any transformation.
*
*
*
* You can combine the items emitted by multiple Observables so that they appear as a single Observable, by
* using the {@code merge} method.
*
* @param source
* an Observable that emits Observables
* @return an Observable that emits items that are the result of flattening the Observables emitted by the
* {@code source} Observable
* @see RxJava Wiki: merge()
* @see MSDN: Observable.Merge
*/
public final static Observable merge(Observable extends Observable extends T>> source) {
return source.lift(new OperatorMerge());
}
/**
* Flattens an Observable that emits Observables into a single Observable that emits the items emitted by
* those Observables, without any transformation, while limiting the maximum number of concurrent
* subscriptions to these Observables.
*
*
*
* You can combine the items emitted by multiple Observables so that they appear as a single Observable, by
* using the {@code merge} method.
*
* @param source
* an Observable that emits Observables
* @param maxConcurrent
* the maximum number of Observables that may be subscribed to concurrently
* @return an Observable that emits items that are the result of flattening the Observables emitted by the
* {@code source} Observable
* @throws IllegalArgumentException
* if {@code maxConcurrent} is less than or equal to 0
* @see RxJava Wiki: merge()
* @see MSDN: Observable.Merge
*/
public final static Observable merge(Observable extends Observable extends T>> source, int maxConcurrent) {
return Observable.create(OperationMergeMaxConcurrent.merge(source, maxConcurrent));
}
/**
* Flattens two Observables into a single Observable, without any transformation.
*
*