Input: Makes sure the fast - path emits in order . [CODESPLIT] protected final void fastPathOrderedEmit ( U value , boolean delayError , Disposable disposable ) { final Observer < ? super V > observer = downstream ; final SimplePlainQueue < U > q = queue ; if ( wip . get ( ) == 0 && wip . compareAndSet ( 0 , 1 ) ) { if ( q . isEmpty ( ) ) { accept ( observer , value ) ; if ( leave ( - 1 ) == 0 ) { return ; } } else { q . offer ( value ) ; } } else { q . offer ( value ) ; if ( ! enter ( ) ) { return ; } } QueueDrainHelper . drainLoop ( q , observer , delayError , disposable , this ) ; }


Input: Mirrors the one ObservableSource in an Iterable of several ObservableSources that first either emits an item or sends a termination notification . <p > <img width = 640 height = 385 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / amb . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code amb } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Observable < T > amb ( Iterable < ? extends ObservableSource < ? extends T > > sources ) { ObjectHelper . requireNonNull ( sources , "sources is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableAmb < T > ( null , sources ) ) ; }


Input: Mirrors the one ObservableSource in an array of several ObservableSources that first either emits an item or sends a termination notification . <p > <img width = 640 height = 385 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / amb . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code ambArray } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ SuppressWarnings ( "unchecked" ) @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Observable < T > ambArray ( ObservableSource < ? extends T > ... sources ) { ObjectHelper . requireNonNull ( sources , "sources is null" ) ; int len = sources . length ; if ( len == 0 ) { return empty ( ) ; } if ( len == 1 ) { return ( Observable < T > ) wrap ( sources [ 0 ] ) ; } return RxJavaPlugins . onAssembly ( new ObservableAmb < T > ( sources , null ) ) ; }


Input: Concatenates elements of each ObservableSource provided via an Iterable sequence into a single sequence of elements without interleaving them . <p > <img width = 640 height = 380 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / concat . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { [CODESPLIT] @ SuppressWarnings ( { "unchecked" , "rawtypes" } ) @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Observable < T > concat ( Iterable < ? extends ObservableSource < ? extends T > > sources ) { ObjectHelper . requireNonNull ( sources , "sources is null" ) ; return fromIterable ( sources ) . concatMapDelayError ( ( Function ) Functions . identity ( ) , bufferSize ( ) , false ) ; }


Input: Returns an Observable that emits the items emitted by each of the ObservableSources emitted by the source ObservableSource one after the other without interleaving them . <p > <img width = 640 height = 380 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / concat . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code concat } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ SuppressWarnings ( { "unchecked" , "rawtypes" } ) @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Observable < T > concat ( ObservableSource < ? extends ObservableSource < ? extends T > > sources , int prefetch ) { ObjectHelper . requireNonNull ( sources , "sources is null" ) ; ObjectHelper . verifyPositive ( prefetch , "prefetch" ) ; return RxJavaPlugins . onAssembly ( new ObservableConcatMap ( sources , Functions . identity ( ) , prefetch , ErrorMode . IMMEDIATE ) ) ; }


Input: Concatenates a variable number of ObservableSource sources . <p > Note : named this way because of overload conflict with concat ( ObservableSource&lt ; ObservableSource&gt ; ) <p > <img width = 640 height = 290 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / concatArray . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { [CODESPLIT] @ SuppressWarnings ( { "unchecked" , "rawtypes" } ) @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Observable < T > concatArray ( ObservableSource < ? extends T > ... sources ) { if ( sources . length == 0 ) { return empty ( ) ; } else if ( sources . length == 1 ) { return wrap ( ( ObservableSource < T > ) sources [ 0 ] ) ; } return RxJavaPlugins . onAssembly ( new ObservableConcatMap ( fromArray ( sources ) , Functions . identity ( ) , bufferSize ( ) , ErrorMode . BOUNDARY ) ) ; }


Input: Concatenates a variable number of ObservableSource sources and delays errors from any of them till all terminate . <p > <img width = 640 height = 290 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / concatArray . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { [CODESPLIT] @ SuppressWarnings ( { "unchecked" } ) @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Observable < T > concatArrayDelayError ( ObservableSource < ? extends T > ... sources ) { if ( sources . length == 0 ) { return empty ( ) ; } else if ( sources . length == 1 ) { return ( Observable < T > ) wrap ( sources [ 0 ] ) ; } return concatDelayError ( fromArray ( sources ) ) ; }


Input: Concatenates an array of ObservableSources eagerly into a single stream of values . <p > <img width = 640 height = 410 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / concatArrayEager . png alt = > <p > Eager concatenation means that once a subscriber subscribes this operator subscribes to all of the source ObservableSources . The operator buffers the values emitted by these ObservableSources and then drains them in order each one after the previous one completes . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > This method does not operate by default on a particular { [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Observable < T > concatArrayEager ( ObservableSource < ? extends T > ... sources ) { return concatArrayEager ( bufferSize ( ) , bufferSize ( ) , sources ) ; }


Input: Concatenates an array of ObservableSources eagerly into a single stream of values . <p > <img width = 640 height = 495 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / concatArrayEager . nn . png alt = > <p > Eager concatenation means that once a subscriber subscribes this operator subscribes to all of the source ObservableSources . The operator buffers the values emitted by these ObservableSources and then drains them in order each one after the previous one completes . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > This method does not operate by default on a particular { [CODESPLIT] @ SuppressWarnings ( { "rawtypes" , "unchecked" } ) @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Observable < T > concatArrayEager ( int maxConcurrency , int prefetch , ObservableSource < ? extends T > ... sources ) { return fromArray ( sources ) . concatMapEagerDelayError ( ( Function ) Functions . identity ( ) , maxConcurrency , prefetch , false ) ; }


Input: Concatenates an array of { [CODESPLIT] @ SuppressWarnings ( { "rawtypes" , "unchecked" } ) @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Observable < T > concatArrayEagerDelayError ( int maxConcurrency , int prefetch , ObservableSource < ? extends T > ... sources ) { return fromArray ( sources ) . concatMapEagerDelayError ( ( Function ) Functions . identity ( ) , maxConcurrency , prefetch , true ) ; }


Input: Concatenates the ObservableSource sequence of ObservableSources into a single sequence by subscribing to each inner ObservableSource one after the other one at a time and delays any errors till the all inner and the outer ObservableSources terminate . <p > <img width = 640 height = 380 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / concatDelayError . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code concatDelayError } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Observable < T > concatDelayError ( ObservableSource < ? extends ObservableSource < ? extends T > > sources ) { return concatDelayError ( sources , bufferSize ( ) , true ) ; }


Input: Concatenates the ObservableSource sequence of ObservableSources into a single sequence by subscribing to each inner ObservableSource one after the other one at a time and delays any errors till the all inner and the outer ObservableSources terminate . <p > <img width = 640 height = 380 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / concatDelayError . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code concatDelayError } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ SuppressWarnings ( { "rawtypes" , "unchecked" } ) @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Observable < T > concatDelayError ( ObservableSource < ? extends ObservableSource < ? extends T > > sources , int prefetch , boolean tillTheEnd ) { ObjectHelper . requireNonNull ( sources , "sources is null" ) ; ObjectHelper . verifyPositive ( prefetch , "prefetch is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableConcatMap ( sources , Functions . identity ( ) , prefetch , tillTheEnd ? ErrorMode . END : ErrorMode . BOUNDARY ) ) ; }


Input: Concatenates an ObservableSource sequence of ObservableSources eagerly into a single stream of values . <p > Eager concatenation means that once a subscriber subscribes this operator subscribes to all of the emitted source ObservableSources as they are observed . The operator buffers the values emitted by these ObservableSources and then drains them in order each one after the previous one completes . <p > <img width = 640 height = 380 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / concatEager . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > This method does not operate by default on a particular { [CODESPLIT] @ SuppressWarnings ( { "unchecked" , "rawtypes" } ) @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Observable < T > concatEager ( ObservableSource < ? extends ObservableSource < ? extends T > > sources , int maxConcurrency , int prefetch ) { return wrap ( sources ) . concatMapEager ( ( Function ) Functions . identity ( ) , maxConcurrency , prefetch ) ; }


Input: Concatenates a sequence of ObservableSources eagerly into a single stream of values . <p > Eager concatenation means that once a subscriber subscribes this operator subscribes to all of the source ObservableSources . The operator buffers the values emitted by these ObservableSources and then drains them in order each one after the previous one completes . <p > <img width = 640 height = 380 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / concatEager . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > This method does not operate by default on a particular { [CODESPLIT] @ SuppressWarnings ( { "unchecked" , "rawtypes" } ) @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Observable < T > concatEager ( Iterable < ? extends ObservableSource < ? extends T > > sources , int maxConcurrency , int prefetch ) { return fromIterable ( sources ) . concatMapEagerDelayError ( ( Function ) Functions . identity ( ) , maxConcurrency , prefetch , false ) ; }


Input: Returns an Observable that emits no items to the { @link Observer } and immediately invokes its { @link Observer#onComplete onComplete } method . <p > <img width = 640 height = 190 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / empty . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code empty } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) @ SuppressWarnings ( "unchecked" ) public static < T > Observable < T > empty ( ) { return RxJavaPlugins . onAssembly ( ( Observable < T > ) ObservableEmpty . INSTANCE ) ; }


Input: Returns an Observable that invokes an { @link Observer } s { @link Observer#onError onError } method when the Observer subscribes to it . <p > <img width = 640 height = 220 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / error . supplier . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code error } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Observable < T > error ( Callable < ? extends Throwable > errorSupplier ) { ObjectHelper . requireNonNull ( errorSupplier , "errorSupplier is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableError < T > ( errorSupplier ) ) ; }


Input: Converts an Array into an ObservableSource that emits the items in the Array . <p > <img width = 640 height = 315 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / from . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code fromArray } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) @ NonNull public static < T > Observable < T > fromArray ( T ... items ) { ObjectHelper . requireNonNull ( items , "items is null" ) ; if ( items . length == 0 ) { return empty ( ) ; } else if ( items . length == 1 ) { return just ( items [ 0 ] ) ; } return RxJavaPlugins . onAssembly ( new ObservableFromArray < T > ( items ) ) ; }


Input: Converts an { @link Iterable } sequence into an ObservableSource that emits the items in the sequence . <p > <img width = 640 height = 186 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / fromIterable . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code fromIterable } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Observable < T > fromIterable ( Iterable < ? extends T > source ) { ObjectHelper . requireNonNull ( source , "source is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableFromIterable < T > ( source ) ) ; }


Input: Converts an arbitrary Reactive - Streams Publisher into an Observable . <p > <img width = 640 height = 344 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / fromPublisher . o . png alt = > <p > The { [CODESPLIT] @ BackpressureSupport ( BackpressureKind . UNBOUNDED_IN ) @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Observable < T > fromPublisher ( Publisher < ? extends T > publisher ) { ObjectHelper . requireNonNull ( publisher , "publisher is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableFromPublisher < T > ( publisher ) ) ; }


Input: Returns a cold synchronous and stateless generator of values . <p > <img width = 640 height = 315 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / generate . 2 . png alt = > <p > Note that the { @link Emitter#onNext } { @link Emitter#onError } and { @link Emitter#onComplete } methods provided to the function via the { @link Emitter } instance should be called synchronously never concurrently and only while the function body is executing . Calling them from multiple threads or outside the function call is not supported and leads to an undefined behavior . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code generate } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Observable < T > generate ( final Consumer < Emitter < T > > generator ) { ObjectHelper . requireNonNull ( generator , "generator is null" ) ; return generate ( Functions . < Object > nullSupplier ( ) , ObservableInternalHelper . simpleGenerator ( generator ) , Functions . < Object > emptyConsumer ( ) ) ; }


Input: Returns a cold synchronous and stateful generator of values . <p > <img width = 640 height = 315 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / generate . 2 . png alt = > <p > Note that the { @link Emitter#onNext } { @link Emitter#onError } and { @link Emitter#onComplete } methods provided to the function via the { @link Emitter } instance should be called synchronously never concurrently and only while the function body is executing . Calling them from multiple threads or outside the function call is not supported and leads to an undefined behavior . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code generate } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T , S > Observable < T > generate ( Callable < S > initialState , BiFunction < S , Emitter < T > , S > generator ) { return generate ( initialState , generator , Functions . emptyConsumer ( ) ) ; }


Input: Returns an Observable that emits a { @code 0L } after the { @code initialDelay } and ever increasing numbers after each { @code period } of time thereafter on a specified { @link Scheduler } . <p > <img width = 640 height = 200 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / timer . ps . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > You specify which { @link Scheduler } this operator will use . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . CUSTOM ) public static Observable < Long > interval ( long initialDelay , long period , TimeUnit unit , Scheduler scheduler ) { ObjectHelper . requireNonNull ( unit , "unit is null" ) ; ObjectHelper . requireNonNull ( scheduler , "scheduler is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableInterval ( Math . max ( 0L , initialDelay ) , Math . max ( 0L , period ) , unit , scheduler ) ) ; }


Input: Returns an Observable that emits a sequential number every specified interval of time . <p > <img width = 640 height = 195 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / interval . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code interval } operates by default on the { @code computation } { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . COMPUTATION ) public static Observable < Long > interval ( long period , TimeUnit unit ) { return interval ( period , period , unit , Schedulers . computation ( ) ) ; }


Input: Returns an Observable that emits a sequential number every specified interval of time on a specified Scheduler . <p > <img width = 640 height = 200 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / interval . s . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > You specify which { @link Scheduler } this operator will use . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . CUSTOM ) public static Observable < Long > interval ( long period , TimeUnit unit , Scheduler scheduler ) { return interval ( period , period , unit , scheduler ) ; }


Input: Signals a range of long values the first after some initial delay and the rest periodically after . <p > The sequence completes immediately after the last value ( start + count - 1 ) has been reached . <p > <img width = 640 height = 195 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / intervalRange . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . COMPUTATION ) public static Observable < Long > intervalRange ( long start , long count , long initialDelay , long period , TimeUnit unit ) { return intervalRange ( start , count , initialDelay , period , unit , Schedulers . computation ( ) ) ; }


Input: Signals a range of long values the first after some initial delay and the rest periodically after . <p > The sequence completes immediately after the last value ( start + count - 1 ) has been reached . <p > <img width = 640 height = 195 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / intervalRange . s . png alt = > * <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > you provide the { [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . CUSTOM ) public static Observable < Long > intervalRange ( long start , long count , long initialDelay , long period , TimeUnit unit , Scheduler scheduler ) { if ( count < 0 ) { throw new IllegalArgumentException ( "count >= 0 required but it was " + count ) ; } if ( count == 0L ) { return Observable . < Long > empty ( ) . delay ( initialDelay , unit , scheduler ) ; } long end = start + ( count - 1 ) ; if ( start > 0 && end < 0 ) { throw new IllegalArgumentException ( "Overflow! start + count is bigger than Long.MAX_VALUE" ) ; } ObjectHelper . requireNonNull ( unit , "unit is null" ) ; ObjectHelper . requireNonNull ( scheduler , "scheduler is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableIntervalRange ( start , end , Math . max ( 0L , initialDelay ) , Math . max ( 0L , period ) , unit , scheduler ) ) ; }


Input: Returns an Observable that signals the given ( constant reference ) item and then completes . <p > <img width = 640 height = 290 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / just . item . png alt = > <p > Note that the item is taken and re - emitted as is and not computed by any means by { @code just } . Use { @link #fromCallable ( Callable ) } to generate a single item on demand ( when { @code Observer } s subscribe to it ) . <p > See the multi - parameter overloads of { @code just } to emit more than one ( constant reference ) items one after the other . Use { @link #fromArray ( Object ... ) } to emit an arbitrary number of items that are known upfront . <p > To emit the items of an { @link Iterable } sequence ( such as a { @link java . util . List } ) use { @link #fromIterable ( Iterable ) } . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code just } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Observable < T > just ( T item ) { ObjectHelper . requireNonNull ( item , "item is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableJust < T > ( item ) ) ; }


Input: Flattens an Iterable of ObservableSources into one ObservableSource without any transformation while limiting the number of concurrent subscriptions to these ObservableSources . <p > <img width = 640 height = 380 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / merge . png alt = > <p > You can combine the items emitted by multiple ObservableSources so that they appear as a single ObservableSource by using the { @code merge } method . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code merge } does not operate by default on a particular { @link Scheduler } . < / dd > <dt > <b > Error handling : < / b > < / dt > <dd > If any of the source { @code ObservableSource } s signal a { @code Throwable } via { @code onError } the resulting { @code Observable } terminates with that { @code Throwable } and all other source { @code ObservableSource } s are disposed . If more than one { @code ObservableSource } signals an error the resulting { @code Observable } may terminate with the first one s error or depending on the concurrency of the sources may terminate with a { @code CompositeException } containing two or more of the various error signals . { @code Throwable } s that didn t make into the composite will be sent ( individually ) to the global error handler via { @link RxJavaPlugins#onError ( Throwable ) } method as { @code UndeliverableException } errors . Similarly { @code Throwable } s signaled by source ( s ) after the returned { @code Observable } has been disposed or terminated with a ( composite ) error will be sent to the same global error handler . Use { @link #mergeDelayError ( Iterable int int ) } to merge sources and terminate only when all source { @code ObservableSource } s have completed or failed with an error . < / dd > < / dl > [CODESPLIT] @ SuppressWarnings ( { "unchecked" , "rawtypes" } ) @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Observable < T > merge ( Iterable < ? extends ObservableSource < ? extends T > > sources , int maxConcurrency , int bufferSize ) { return fromIterable ( sources ) . flatMap ( ( Function ) Functions . identity ( ) , false , maxConcurrency , bufferSize ) ; }


Input: Flattens an Iterable of ObservableSources into one ObservableSource without any transformation while limiting the number of concurrent subscriptions to these ObservableSources . <p > <img width = 640 height = 380 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / merge . png alt = > <p > You can combine the items emitted by multiple ObservableSources so that they appear as a single ObservableSource by using the { @code merge } method . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code mergeArray } does not operate by default on a particular { @link Scheduler } . < / dd > <dt > <b > Error handling : < / b > < / dt > <dd > If any of the source { @code ObservableSource } s signal a { @code Throwable } via { @code onError } the resulting { @code Observable } terminates with that { @code Throwable } and all other source { @code ObservableSource } s are disposed . If more than one { @code ObservableSource } signals an error the resulting { @code Observable } may terminate with the first one s error or depending on the concurrency of the sources may terminate with a { @code CompositeException } containing two or more of the various error signals . { @code Throwable } s that didn t make into the composite will be sent ( individually ) to the global error handler via { @link RxJavaPlugins#onError ( Throwable ) } method as { @code UndeliverableException } errors . Similarly { @code Throwable } s signaled by source ( s ) after the returned { @code Observable } has been disposed or terminated with a ( composite ) error will be sent to the same global error handler . Use { @link #mergeArrayDelayError ( int int ObservableSource ... ) } to merge sources and terminate only when all source { @code ObservableSource } s have completed or failed with an error . < / dd > < / dl > [CODESPLIT] @ SuppressWarnings ( { "unchecked" , "rawtypes" } ) @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Observable < T > mergeArray ( int maxConcurrency , int bufferSize , ObservableSource < ? extends T > ... sources ) { return fromArray ( sources ) . flatMap ( ( Function ) Functions . identity ( ) , false , maxConcurrency , bufferSize ) ; }


Input: Flattens an ObservableSource that emits ObservableSources into a single ObservableSource that emits the items emitted by those ObservableSources without any transformation . <p > <img width = 640 height = 370 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / merge . oo . png alt = > <p > You can combine the items emitted by multiple ObservableSources so that they appear as a single ObservableSource by using the { @code merge } method . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code merge } does not operate by default on a particular { @link Scheduler } . < / dd > <dt > <b > Error handling : < / b > < / dt > <dd > If any of the source { @code ObservableSource } s signal a { @code Throwable } via { @code onError } the resulting { @code Observable } terminates with that { @code Throwable } and all other source { @code ObservableSource } s are disposed . If more than one { @code ObservableSource } signals an error the resulting { @code Observable } may terminate with the first one s error or depending on the concurrency of the sources may terminate with a { @code CompositeException } containing two or more of the various error signals . { @code Throwable } s that didn t make into the composite will be sent ( individually ) to the global error handler via { @link RxJavaPlugins#onError ( Throwable ) } method as { @code UndeliverableException } errors . Similarly { @code Throwable } s signaled by source ( s ) after the returned { @code Observable } has been disposed or terminated with a ( composite ) error will be sent to the same global error handler . Use { @link #mergeDelayError ( ObservableSource ) } to merge sources and terminate only when all source { @code ObservableSource } s have completed or failed with an error . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) @ SuppressWarnings ( { "unchecked" , "rawtypes" } ) public static < T > Observable < T > merge ( ObservableSource < ? extends ObservableSource < ? extends T > > sources ) { ObjectHelper . requireNonNull ( sources , "sources is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableFlatMap ( sources , Functions . identity ( ) , false , Integer . MAX_VALUE , bufferSize ( ) ) ) ; }


Input: Flattens an Array of ObservableSources into one ObservableSource without any transformation . <p > <img width = 640 height = 370 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / merge . io . png alt = > <p > You can combine items emitted by multiple ObservableSources so that they appear as a single ObservableSource by using the { @code merge } method . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code mergeArray } does not operate by default on a particular { @link Scheduler } . < / dd > <dt > <b > Error handling : < / b > < / dt > <dd > If any of the source { @code ObservableSource } s signal a { @code Throwable } via { @code onError } the resulting { @code Observable } terminates with that { @code Throwable } and all other source { @code ObservableSource } s are disposed . If more than one { @code ObservableSource } signals an error the resulting { @code Observable } may terminate with the first one s error or depending on the concurrency of the sources may terminate with a { @code CompositeException } containing two or more of the various error signals . { @code Throwable } s that didn t make into the composite will be sent ( individually ) to the global error handler via { @link RxJavaPlugins#onError ( Throwable ) } method as { @code UndeliverableException } errors . Similarly { @code Throwable } s signaled by source ( s ) after the returned { @code Observable } has been disposed or terminated with a ( composite ) error will be sent to the same global error handler . Use { @link #mergeArrayDelayError ( ObservableSource ... ) } to merge sources and terminate only when all source { @code ObservableSource } s have completed or failed with an error . < / dd > < / dl > [CODESPLIT] @ SuppressWarnings ( { "unchecked" , "rawtypes" } ) @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Observable < T > mergeArray ( ObservableSource < ? extends T > ... sources ) { return fromArray ( sources ) . flatMap ( ( Function ) Functions . identity ( ) , sources . length ) ; }


Input: Flattens three ObservableSources into one ObservableSource in a way that allows an Observer to receive all successfully emitted items from all of the source ObservableSources without being interrupted by an error notification from one of them . <p > This behaves like { @link #merge ( ObservableSource ObservableSource ObservableSource ) } except that if any of the merged ObservableSources notify of an error via { @link Observer#onError onError } { @code mergeDelayError } will refrain from propagating that error notification until all of the merged ObservableSources have finished emitting items . <p > <img width = 640 height = 380 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / mergeDelayError . png alt = > <p > Even if multiple merged ObservableSources send { @code onError } notifications { @code mergeDelayError } will only invoke the { @code onError } method of its Observers once . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code mergeDelayError } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ SuppressWarnings ( { "unchecked" , "rawtypes" } ) @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Observable < T > mergeDelayError ( ObservableSource < ? extends T > source1 , ObservableSource < ? extends T > source2 , ObservableSource < ? extends T > source3 ) { ObjectHelper . requireNonNull ( source1 , "source1 is null" ) ; ObjectHelper . requireNonNull ( source2 , "source2 is null" ) ; ObjectHelper . requireNonNull ( source3 , "source3 is null" ) ; return fromArray ( source1 , source2 , source3 ) . flatMap ( ( Function ) Functions . identity ( ) , true , 3 ) ; }


Input: Returns an Observable that never sends any items or notifications to an { @link Observer } . <p > <img width = 640 height = 185 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / never . png alt = > <p > This ObservableSource is useful primarily for testing purposes . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code never } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) @ SuppressWarnings ( "unchecked" ) public static < T > Observable < T > never ( ) { return RxJavaPlugins . onAssembly ( ( Observable < T > ) ObservableNever . INSTANCE ) ; }


Input: Returns an Observable that emits a sequence of Integers within a specified range . <p > <img width = 640 height = 195 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / range . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code range } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public static Observable < Integer > range ( final int start , final int count ) { if ( count < 0 ) { throw new IllegalArgumentException ( "count >= 0 required but it was " + count ) ; } if ( count == 0 ) { return empty ( ) ; } if ( count == 1 ) { return just ( start ) ; } if ( ( long ) start + ( count - 1 ) > Integer . MAX_VALUE ) { throw new IllegalArgumentException ( "Integer overflow" ) ; } return RxJavaPlugins . onAssembly ( new ObservableRange ( start , count ) ) ; }


Input: Returns an Observable that emits a sequence of Longs within a specified range . <p > <img width = 640 height = 195 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / rangeLong . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code rangeLong } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public static Observable < Long > rangeLong ( long start , long count ) { if ( count < 0 ) { throw new IllegalArgumentException ( "count >= 0 required but it was " + count ) ; } if ( count == 0 ) { return empty ( ) ; } if ( count == 1 ) { return just ( start ) ; } long end = start + ( count - 1 ) ; if ( start > 0 && end < 0 ) { throw new IllegalArgumentException ( "Overflow! start + count is bigger than Long.MAX_VALUE" ) ; } return RxJavaPlugins . onAssembly ( new ObservableRangeLong ( start , count ) ) ; }


Input: Returns a Single that emits a Boolean value that indicates whether two ObservableSource sequences are the same by comparing the items emitted by each ObservableSource pairwise based on the results of a specified equality function . <p > <img width = 640 height = 380 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / sequenceEqual . 2 . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code sequenceEqual } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Single < Boolean > sequenceEqual ( ObservableSource < ? extends T > source1 , ObservableSource < ? extends T > source2 , BiPredicate < ? super T , ? super T > isEqual ) { return sequenceEqual ( source1 , source2 , isEqual , bufferSize ( ) ) ; }


Input: Returns a Single that emits a Boolean value that indicates whether two ObservableSource sequences are the same by comparing the items emitted by each ObservableSource pairwise based on the results of a specified equality function . <p > <img width = 640 height = 380 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / sequenceEqual . 2 . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code sequenceEqual } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Single < Boolean > sequenceEqual ( ObservableSource < ? extends T > source1 , ObservableSource < ? extends T > source2 , BiPredicate < ? super T , ? super T > isEqual , int bufferSize ) { ObjectHelper . requireNonNull ( source1 , "source1 is null" ) ; ObjectHelper . requireNonNull ( source2 , "source2 is null" ) ; ObjectHelper . requireNonNull ( isEqual , "isEqual is null" ) ; ObjectHelper . verifyPositive ( bufferSize , "bufferSize" ) ; return RxJavaPlugins . onAssembly ( new ObservableSequenceEqualSingle < T > ( source1 , source2 , isEqual , bufferSize ) ) ; }


Input: Returns a Single that emits a Boolean value that indicates whether two ObservableSource sequences are the same by comparing the items emitted by each ObservableSource pairwise . <p > <img width = 640 height = 380 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / sequenceEqual . 2 . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code sequenceEqual } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Single < Boolean > sequenceEqual ( ObservableSource < ? extends T > source1 , ObservableSource < ? extends T > source2 , int bufferSize ) { return sequenceEqual ( source1 , source2 , ObjectHelper . equalsPredicate ( ) , bufferSize ) ; }


Input: Converts an ObservableSource that emits ObservableSources into an ObservableSource that emits the items emitted by the most recently emitted of those ObservableSources . <p > <img width = 640 height = 370 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / switchDo . png alt = > <p > { @code switchOnNext } subscribes to an ObservableSource that emits ObservableSources . Each time it observes one of these emitted ObservableSources the ObservableSource returned by { @code switchOnNext } begins emitting the items emitted by that ObservableSource . When a new ObservableSource is emitted { @code switchOnNext } stops emitting items from the earlier - emitted ObservableSource and begins emitting items from the new one . <p > The resulting ObservableSource completes if both the outer ObservableSource and the last inner ObservableSource if any complete . If the outer ObservableSource signals an onError the inner ObservableSource is disposed and the error delivered in - sequence . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code switchOnNext } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ SuppressWarnings ( { "rawtypes" , "unchecked" } ) @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Observable < T > switchOnNext ( ObservableSource < ? extends ObservableSource < ? extends T > > sources , int bufferSize ) { ObjectHelper . requireNonNull ( sources , "sources is null" ) ; ObjectHelper . verifyPositive ( bufferSize , "bufferSize" ) ; return RxJavaPlugins . onAssembly ( new ObservableSwitchMap ( sources , Functions . identity ( ) , bufferSize , false ) ) ; }


Input: Converts an ObservableSource that emits ObservableSources into an ObservableSource that emits the items emitted by the most recently emitted of those ObservableSources and delays any exception until all ObservableSources terminate . <p > <img width = 640 height = 370 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / switchOnNextDelayError . png alt = > <p > { @code switchOnNext } subscribes to an ObservableSource that emits ObservableSources . Each time it observes one of these emitted ObservableSources the ObservableSource returned by { @code switchOnNext } begins emitting the items emitted by that ObservableSource . When a new ObservableSource is emitted { @code switchOnNext } stops emitting items from the earlier - emitted ObservableSource and begins emitting items from the new one . <p > The resulting ObservableSource completes if both the main ObservableSource and the last inner ObservableSource if any complete . If the main ObservableSource signals an onError the termination of the last inner ObservableSource will emit that error as is or wrapped into a CompositeException along with the other possible errors the former inner ObservableSources signalled . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code switchOnNextDelayError } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ SuppressWarnings ( { "rawtypes" , "unchecked" } ) @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Observable < T > switchOnNextDelayError ( ObservableSource < ? extends ObservableSource < ? extends T > > sources , int prefetch ) { ObjectHelper . requireNonNull ( sources , "sources is null" ) ; ObjectHelper . verifyPositive ( prefetch , "prefetch" ) ; return RxJavaPlugins . onAssembly ( new ObservableSwitchMap ( sources , Functions . identity ( ) , prefetch , true ) ) ; }


Input: Create an Observable by wrapping an ObservableSource <em > which has to be implemented according to the Reactive - Streams - based Observable specification by handling disposal correctly ; no safeguards are provided by the Observable itself< / em > . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Observable < T > unsafeCreate ( ObservableSource < T > onSubscribe ) { ObjectHelper . requireNonNull ( onSubscribe , "onSubscribe is null" ) ; if ( onSubscribe instanceof Observable ) { throw new IllegalArgumentException ( "unsafeCreate(Observable) should be upgraded" ) ; } return RxJavaPlugins . onAssembly ( new ObservableFromUnsafeSource < T > ( onSubscribe ) ) ; }


Input: Constructs an ObservableSource that creates a dependent resource object which is disposed of when the downstream calls dispose () . <p > <img width = 640 height = 400 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / using . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code using } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T , D > Observable < T > using ( Callable < ? extends D > resourceSupplier , Function < ? super D , ? extends ObservableSource < ? extends T > > sourceSupplier , Consumer < ? super D > disposer ) { return using ( resourceSupplier , sourceSupplier , disposer , true ) ; }


Input: Constructs an ObservableSource that creates a dependent resource object which is disposed of just before termination if you have set { @code disposeEagerly } to { @code true } and a dispose () call does not occur before termination . Otherwise resource disposal will occur on a dispose () call . Eager disposal is particularly appropriate for a synchronous ObservableSource that reuses resources . { @code disposeAction } will only be called once per subscription . <p > <img width = 640 height = 400 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / using . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code using } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T , D > Observable < T > using ( Callable < ? extends D > resourceSupplier , Function < ? super D , ? extends ObservableSource < ? extends T > > sourceSupplier , Consumer < ? super D > disposer , boolean eager ) { ObjectHelper . requireNonNull ( resourceSupplier , "resourceSupplier is null" ) ; ObjectHelper . requireNonNull ( sourceSupplier , "sourceSupplier is null" ) ; ObjectHelper . requireNonNull ( disposer , "disposer is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableUsing < T , D > ( resourceSupplier , sourceSupplier , disposer , eager ) ) ; }


Input: Wraps an ObservableSource into an Observable if not already an Observable . [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Observable < T > wrap ( ObservableSource < T > source ) { ObjectHelper . requireNonNull ( source , "source is null" ) ; if ( source instanceof Observable ) { return RxJavaPlugins . onAssembly ( ( Observable < T > ) source ) ; } return RxJavaPlugins . onAssembly ( new ObservableFromUnsafeSource < T > ( source ) ) ; }


Input: Returns an Observable that emits the results of a specified combiner function applied to combinations of items emitted in sequence by an Iterable of other ObservableSources . <p > { @code zip } applies this function in strict sequence so the first item emitted by the new ObservableSource will be the result of the function applied to the first item emitted by each of the source ObservableSources ; the second item emitted by the new ObservableSource will be the result of the function applied to the second item emitted by each of those ObservableSources ; and so forth . <p > The resulting { @code ObservableSource<R > } returned from { @code zip } will invoke { @code onNext } as many times as the number of { @code onNext } invocations of the source ObservableSource that emits the fewest items . <p > The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources . Therefore it is possible those other sources will never be able to run to completion ( and thus not calling { @code doOnComplete () } ) . This can also happen if the sources are exactly the same length ; if source A completes and B has been consumed and is about to complete the operator detects A won t be sending further values and it will dispose B immediately . For example : <pre > <code > zip ( Arrays . asList ( range ( 1 5 ) . doOnComplete ( action1 ) range ( 6 5 ) . doOnComplete ( action2 )) ( a ) - &gt ; a ) < / code > < / pre > { @code action1 } will be called but { @code action2 } won t . <br > To work around this termination property use { @link #doOnDispose ( Action ) } as well or use { @code using () } to do cleanup in case of completion or a dispose () call . <p > Note on method signature : since Java doesn t allow creating a generic array with { @code new T [] } the implementation of this operator has to create an { @code Object [] } instead . Unfortunately a { @code Function<Integer [] R > } passed to the method would trigger a { @code ClassCastException } . [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T , R > Observable < R > zip ( Iterable < ? extends ObservableSource < ? extends T > > sources , Function < ? super Object [ ] , ? extends R > zipper ) { ObjectHelper . requireNonNull ( zipper , "zipper is null" ) ; ObjectHelper . requireNonNull ( sources , "sources is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableZip < T , R > ( null , sources , zipper , bufferSize ( ) , false ) ) ; }


Input: Returns an Observable that emits the results of a specified combiner function applied to combinations of <i > n< / i > items emitted in sequence by the <i > n< / i > ObservableSources emitted by a specified ObservableSource . <p > { @code zip } applies this function in strict sequence so the first item emitted by the new ObservableSource will be the result of the function applied to the first item emitted by each of the ObservableSources emitted by the source ObservableSource ; the second item emitted by the new ObservableSource will be the result of the function applied to the second item emitted by each of those ObservableSources ; and so forth . <p > The resulting { @code ObservableSource<R > } returned from { @code zip } will invoke { @code onNext } as many times as the number of { @code onNext } invocations of the source ObservableSource that emits the fewest items . <p > The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources . Therefore it is possible those other sources will never be able to run to completion ( and thus not calling { @code doOnComplete () } ) . This can also happen if the sources are exactly the same length ; if source A completes and B has been consumed and is about to complete the operator detects A won t be sending further values and it will dispose B immediately . For example : <pre > <code > zip ( just ( range ( 1 5 ) . doOnComplete ( action1 ) range ( 6 5 ) . doOnComplete ( action2 )) ( a ) - &gt ; a ) < / code > < / pre > { @code action1 } will be called but { @code action2 } won t . <br > To work around this termination property use { @link #doOnDispose ( Action ) } as well or use { @code using () } to do cleanup in case of completion or a dispose () call . <p > Note on method signature : since Java doesn t allow creating a generic array with { @code new T [] } the implementation of this operator has to create an { @code Object [] } instead . Unfortunately a { @code Function<Integer [] R > } passed to the method would trigger a { @code ClassCastException } . [CODESPLIT] @ SuppressWarnings ( { "rawtypes" , "unchecked" } ) @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T , R > Observable < R > zip ( ObservableSource < ? extends ObservableSource < ? extends T > > sources , final Function < ? super Object [ ] , ? extends R > zipper ) { ObjectHelper . requireNonNull ( zipper , "zipper is null" ) ; ObjectHelper . requireNonNull ( sources , "sources is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableToList ( sources , 16 ) . flatMap ( ObservableInternalHelper . zipIterable ( zipper ) ) ) ; }


Input: Returns an Observable that emits the results of a specified combiner function applied to combinations of items emitted in sequence by an array of other ObservableSources . <p > { @code zip } applies this function in strict sequence so the first item emitted by the new ObservableSource will be the result of the function applied to the first item emitted by each of the source ObservableSources ; the second item emitted by the new ObservableSource will be the result of the function applied to the second item emitted by each of those ObservableSources ; and so forth . <p > The resulting { @code ObservableSource<R > } returned from { @code zip } will invoke { @code onNext } as many times as the number of { @code onNext } invocations of the source ObservableSource that emits the fewest items . <p > The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources . Therefore it is possible those other sources will never be able to run to completion ( and thus not calling { @code doOnComplete () } ) . This can also happen if the sources are exactly the same length ; if source A completes and B has been consumed and is about to complete the operator detects A won t be sending further values and it will dispose B immediately . For example : <pre > <code > zip ( new ObservableSource [] { range ( 1 5 ) . doOnComplete ( action1 ) range ( 6 5 ) . doOnComplete ( action2 ) } ( a ) - &gt ; a ) < / code > < / pre > { @code action1 } will be called but { @code action2 } won t . <br > To work around this termination property use { @link #doOnDispose ( Action ) } as well or use { @code using () } to do cleanup in case of completion or a dispose () call . <p > Note on method signature : since Java doesn t allow creating a generic array with { @code new T [] } the implementation of this operator has to create an { @code Object [] } instead . Unfortunately a { @code Function<Integer [] R > } passed to the method would trigger a { @code ClassCastException } . [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T , R > Observable < R > zipArray ( Function < ? super Object [ ] , ? extends R > zipper , boolean delayError , int bufferSize , ObservableSource < ? extends T > ... sources ) { if ( sources . length == 0 ) { return empty ( ) ; } ObjectHelper . requireNonNull ( zipper , "zipper is null" ) ; ObjectHelper . verifyPositive ( bufferSize , "bufferSize" ) ; return RxJavaPlugins . onAssembly ( new ObservableZip < T , R > ( sources , null , zipper , bufferSize , delayError ) ) ; }


Input: Returns a Single that emits a Boolean that indicates whether all of the items emitted by the source ObservableSource satisfy a condition . <p > <img width = 640 height = 264 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / all . o . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code all } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Single < Boolean > all ( Predicate < ? super T > predicate ) { ObjectHelper . requireNonNull ( predicate , "predicate is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableAllSingle < T > ( this , predicate ) ) ; }


Input: Mirrors the ObservableSource ( current or provided ) that first either emits an item or sends a termination notification . <p > <img width = 640 height = 385 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / ambWith . o . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code ambWith } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ SuppressWarnings ( "unchecked" ) @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Observable < T > ambWith ( ObservableSource < ? extends T > other ) { ObjectHelper . requireNonNull ( other , "other is null" ) ; return ambArray ( this , other ) ; }


Input: Returns a Single that emits { @code true } if any item emitted by the source ObservableSource satisfies a specified condition otherwise { @code false } . <em > Note : < / em > this always emits { @code false } if the source ObservableSource is empty . <p > <img width = 640 height = 320 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / any . 2 . png alt = > <p > In Rx . Net this is the { @code any } Observer but we renamed it in RxJava to better match Java naming idioms . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code any } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Single < Boolean > any ( Predicate < ? super T > predicate ) { ObjectHelper . requireNonNull ( predicate , "predicate is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableAnySingle < T > ( this , predicate ) ) ; }


Input: Returns the first item emitted by this { @code Observable } or throws { @code NoSuchElementException } if it emits no items . <p > <img width = 640 height = 412 src = https : // github . com / ReactiveX / RxJava / wiki / images / rx - operators / blockingFirst . o . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code blockingFirst } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final T blockingFirst ( ) { BlockingFirstObserver < T > observer = new BlockingFirstObserver < T > ( ) ; subscribe ( observer ) ; T v = observer . blockingGet ( ) ; if ( v != null ) { return v ; } throw new NoSuchElementException ( ) ; }


Input: Consumes the upstream { @code Observable } in a blocking fashion and invokes the given { @code Consumer } with each upstream item on the <em > current thread< / em > until the upstream terminates . <p > <img width = 640 height = 330 src = https : // github . com / ReactiveX / RxJava / wiki / images / rx - operators / blockingForEach . o . png alt = > <p > <em > Note : < / em > the method will only return if the upstream terminates or the current thread is interrupted . <p > This method executes the { @code Consumer } on the current thread while { @link #subscribe ( Consumer ) } executes the consumer on the original caller thread of the sequence . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code blockingForEach } does not operate by default on a particular { @link Scheduler } . < / dd > <dt > <b > Error handling : < / b > < / dt > <dd > If the source signals an error the operator wraps a checked { @link Exception } into { @link RuntimeException } and throws that . Otherwise { @code RuntimeException } s and { @link Error } s are rethrown as they are . < / dd > < / dl > [CODESPLIT] @ SchedulerSupport ( SchedulerSupport . NONE ) public final void blockingForEach ( Consumer < ? super T > onNext ) { Iterator < T > it = blockingIterable ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { try { onNext . accept ( it . next ( ) ) ; } catch ( Throwable e ) { Exceptions . throwIfFatal ( e ) ; ( ( Disposable ) it ) . dispose ( ) ; throw ExceptionHelper . wrapOrThrow ( e ) ; } } }


Input: Converts this { @code Observable } into an { @link Iterable } . <p > <img width = 640 height = 315 src = https : // github . com / ReactiveX / RxJava / wiki / images / rx - operators / blockingIterable . o . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code blockingIterable } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Iterable < T > blockingIterable ( int bufferSize ) { ObjectHelper . verifyPositive ( bufferSize , "bufferSize" ) ; return new BlockingObservableIterable < T > ( this , bufferSize ) ; }


Input: Returns the last item emitted by this { @code Observable } or throws { @code NoSuchElementException } if this { @code Observable } emits no items . <p > <img width = 640 height = 315 src = https : // github . com / ReactiveX / RxJava / wiki / images / rx - operators / blockingLast . o . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code blockingLast } does not operate by default on a particular { @link Scheduler } . < / dd > <dt > <b > Error handling : < / b > < / dt > <dd > If the source signals an error the operator wraps a checked { @link Exception } into { @link RuntimeException } and throws that . Otherwise { @code RuntimeException } s and { @link Error } s are rethrown as they are . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final T blockingLast ( ) { BlockingLastObserver < T > observer = new BlockingLastObserver < T > ( ) ; subscribe ( observer ) ; T v = observer . blockingGet ( ) ; if ( v != null ) { return v ; } throw new NoSuchElementException ( ) ; }


Input: Returns an { @link Iterable } that always returns the item most recently emitted by this { @code Observable } . <p > <img width = 640 height = 426 src = https : // github . com / ReactiveX / RxJava / wiki / images / rx - operators / blockingMostRecent . o . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code blockingMostRecent } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Iterable < T > blockingMostRecent ( T initialValue ) { return new BlockingObservableMostRecent < T > ( this , initialValue ) ; }


Input: If this { @code Observable } completes after emitting a single item return that item otherwise throw a { @code NoSuchElementException } . <p > <img width = 640 height = 315 src = https : // github . com / ReactiveX / RxJava / wiki / images / rx - operators / blockingSingle . o . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code blockingSingle } does not operate by default on a particular { @link Scheduler } . < / dd > <dt > <b > Error handling : < / b > < / dt > <dd > If the source signals an error the operator wraps a checked { @link Exception } into { @link RuntimeException } and throws that . Otherwise { @code RuntimeException } s and { @link Error } s are rethrown as they are . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final T blockingSingle ( ) { T v = singleElement ( ) . blockingGet ( ) ; if ( v == null ) { throw new NoSuchElementException ( ) ; } return v ; }


Input: If this { @code Observable } completes after emitting a single item return that item ; if it emits more than one item throw an { @code IllegalArgumentException } ; if it emits no items return a default value . <p > <img width = 640 height = 315 src = https : // github . com / ReactiveX / RxJava / wiki / images / rx - operators / blockingSingleDefault . o . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code blockingSingle } does not operate by default on a particular { @link Scheduler } . < / dd > <dt > <b > Error handling : < / b > < / dt > <dd > If the source signals an error the operator wraps a checked { @link Exception } into { @link RuntimeException } and throws that . Otherwise { @code RuntimeException } s and { @link Error } s are rethrown as they are . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final T blockingSingle ( T defaultItem ) { return single ( defaultItem ) . blockingGet ( ) ; }


Input: Returns a { @link Future } representing the only value emitted by this { @code Observable } . <p > <img width = 640 height = 312 src = https : // github . com / ReactiveX / RxJava / wiki / images / rx - operators / toFuture . o . png alt = > <p > If the { @link Observable } emits more than one item { @link java . util . concurrent . Future } will receive an { @link java . lang . IndexOutOfBoundsException } . If the { @link Observable } is empty { @link java . util . concurrent . Future } will receive an { @link java . util . NoSuchElementException } . The { @code Observable } source has to terminate in order for the returned { @code Future } to terminate as well . <p > If the { @code Observable } may emit more than one item use { @code Observable . toList () . toFuture () } . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code toFuture } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Future < T > toFuture ( ) { return subscribeWith ( new FutureObserver < T > ( ) ) ; }


Input: Subscribes to the source and calls the given callbacks <strong > on the current thread< / strong > . <p > <img width = 640 height = 393 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / blockingSubscribe . o . 1 . png alt = > <p > If the { [CODESPLIT] @ SchedulerSupport ( SchedulerSupport . NONE ) public final void blockingSubscribe ( Consumer < ? super T > onNext ) { ObservableBlockingSubscribe . subscribe ( this , onNext , Functions . ON_ERROR_MISSING , Functions . EMPTY_ACTION ) ; }


Input: Subscribes to the source and calls the given callbacks <strong > on the current thread< / strong > . <p > <img width = 640 height = 396 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / blockingSubscribe . o . 2 . png alt = > <p > Note that calling this method will block the caller thread until the upstream terminates normally or with an error . Therefore calling this method from special threads such as the Android Main Thread or the Swing Event Dispatch Thread is not recommended . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { [CODESPLIT] @ SchedulerSupport ( SchedulerSupport . NONE ) public final void blockingSubscribe ( Consumer < ? super T > onNext , Consumer < ? super Throwable > onError ) { ObservableBlockingSubscribe . subscribe ( this , onNext , onError , Functions . EMPTY_ACTION ) ; }


Input: Subscribes to the source and calls the given callbacks <strong > on the current thread< / strong > . <p > <img width = 640 height = 394 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / blockingSubscribe . o . png alt = > <p > Note that calling this method will block the caller thread until the upstream terminates normally or with an error . Therefore calling this method from special threads such as the Android Main Thread or the Swing Event Dispatch Thread is not recommended . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { [CODESPLIT] @ SchedulerSupport ( SchedulerSupport . NONE ) public final void blockingSubscribe ( Consumer < ? super T > onNext , Consumer < ? super Throwable > onError , Action onComplete ) { ObservableBlockingSubscribe . subscribe ( this , onNext , onError , onComplete ) ; }


Input: Subscribes to the source and calls the { [CODESPLIT] @ SchedulerSupport ( SchedulerSupport . NONE ) public final void blockingSubscribe ( Observer < ? super T > observer ) { ObservableBlockingSubscribe . subscribe ( this , observer ) ; }


Input: Returns an Observable that emits buffers of items it collects from the source ObservableSource . The resulting ObservableSource emits connected non - overlapping buffers each containing { @code count } items . When the source ObservableSource completes the resulting ObservableSource emits the current buffer and propagates the notification from the source ObservableSource . Note that if the source ObservableSource issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling . <p > <img width = 640 height = 320 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / buffer3 . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > This version of { @code buffer } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Observable < List < T > > buffer ( int count ) { return buffer ( count , count ) ; }


Input: Returns an Observable that emits buffers of items it collects from the source ObservableSource . The resulting ObservableSource emits buffers every { @code skip } items each containing { @code count } items . When the source ObservableSource completes the resulting ObservableSource emits the current buffer and propagates the notification from the source ObservableSource . Note that if the source ObservableSource issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling . <p > <img width = 640 height = 320 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / buffer4 . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > This version of { @code buffer } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Observable < List < T > > buffer ( int count , int skip ) { return buffer ( count , skip , ArrayListSupplier . < T > asCallable ( ) ) ; }


Input: Returns an Observable that emits buffers of items it collects from the source ObservableSource . The resulting ObservableSource emits buffers every { @code skip } items each containing { @code count } items . When the source ObservableSource completes the resulting ObservableSource emits the current buffer and propagates the notification from the source ObservableSource . Note that if the source ObservableSource issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling . <p > <img width = 640 height = 320 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / buffer4 . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > This version of { @code buffer } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < U extends Collection < ? super T > > Observable < U > buffer ( int count , int skip , Callable < U > bufferSupplier ) { ObjectHelper . verifyPositive ( count , "count" ) ; ObjectHelper . verifyPositive ( skip , "skip" ) ; ObjectHelper . requireNonNull ( bufferSupplier , "bufferSupplier is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableBuffer < T , U > ( this , count , skip , bufferSupplier ) ) ; }


Input: Returns an Observable that emits buffers of items it collects from the source ObservableSource . The resulting ObservableSource emits connected non - overlapping buffers each containing { @code count } items . When the source ObservableSource completes the resulting ObservableSource emits the current buffer and propagates the notification from the source ObservableSource . Note that if the source ObservableSource issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling . <p > <img width = 640 height = 320 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / buffer3 . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > This version of { @code buffer } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < U extends Collection < ? super T > > Observable < U > buffer ( int count , Callable < U > bufferSupplier ) { return buffer ( count , count , bufferSupplier ) ; }


Input: Returns an Observable that emits buffers of items it collects from the source ObservableSource . The resulting ObservableSource starts a new buffer periodically as determined by the { @code timeskip } argument . It emits each buffer after a fixed timespan specified by the { @code timespan } argument . When the source ObservableSource completes the resulting ObservableSource emits the current buffer and propagates the notification from the source ObservableSource . Note that if the source ObservableSource issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling . <p > <img width = 640 height = 320 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / buffer7 . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > This version of { @code buffer } operates by default on the { @code computation } { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . COMPUTATION ) public final Observable < List < T > > buffer ( long timespan , long timeskip , TimeUnit unit ) { return buffer ( timespan , timeskip , unit , Schedulers . computation ( ) , ArrayListSupplier . < T > asCallable ( ) ) ; }


Input: Returns an Observable that emits buffers of items it collects from the source ObservableSource . The resulting ObservableSource starts a new buffer periodically as determined by the { @code timeskip } argument and on the specified { @code scheduler } . It emits each buffer after a fixed timespan specified by the { @code timespan } argument . When the source ObservableSource completes the resulting ObservableSource emits the current buffer and propagates the notification from the source ObservableSource . Note that if the source ObservableSource issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling . <p > <img width = 640 height = 320 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / buffer7 . s . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > You specify which { @link Scheduler } this operator will use . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . CUSTOM ) public final < U extends Collection < ? super T > > Observable < U > buffer ( long timespan , long timeskip , TimeUnit unit , Scheduler scheduler , Callable < U > bufferSupplier ) { ObjectHelper . requireNonNull ( unit , "unit is null" ) ; ObjectHelper . requireNonNull ( scheduler , "scheduler is null" ) ; ObjectHelper . requireNonNull ( bufferSupplier , "bufferSupplier is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableBufferTimed < T , U > ( this , timespan , timeskip , unit , scheduler , bufferSupplier , Integer . MAX_VALUE , false ) ) ; }


Input: Returns an Observable that emits buffers of items it collects from the source ObservableSource . The resulting ObservableSource emits connected non - overlapping buffers each of a fixed duration specified by the { @code timespan } argument or a maximum size specified by the { @code count } argument ( whichever is reached first ) . When the source ObservableSource completes the resulting ObservableSource emits the current buffer and propagates the notification from the source ObservableSource . Note that if the source ObservableSource issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling . <p > <img width = 640 height = 320 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / buffer6 . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > This version of { @code buffer } operates by default on the { @code computation } { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . COMPUTATION ) public final Observable < List < T > > buffer ( long timespan , TimeUnit unit , int count ) { return buffer ( timespan , unit , Schedulers . computation ( ) , count ) ; }


Input: Returns an Observable that emits buffers of items it collects from the source ObservableSource . The resulting ObservableSource emits connected non - overlapping buffers each of a fixed duration specified by the { @code timespan } argument as measured on the specified { @code scheduler } or a maximum size specified by the { @code count } argument ( whichever is reached first ) . When the source ObservableSource completes the resulting ObservableSource emits the current buffer and propagates the notification from the source ObservableSource . Note that if the source ObservableSource issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling . <p > <img width = 640 height = 320 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / buffer6 . s . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > You specify which { @link Scheduler } this operator will use . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . CUSTOM ) public final Observable < List < T > > buffer ( long timespan , TimeUnit unit , Scheduler scheduler , int count ) { return buffer ( timespan , unit , scheduler , count , ArrayListSupplier . < T > asCallable ( ) , false ) ; }


Input: Returns an Observable that emits buffers of items it collects from the source ObservableSource . The resulting ObservableSource emits connected non - overlapping buffers each of a fixed duration specified by the { @code timespan } argument as measured on the specified { @code scheduler } or a maximum size specified by the { @code count } argument ( whichever is reached first ) . When the source ObservableSource completes the resulting ObservableSource emits the current buffer and propagates the notification from the source ObservableSource . Note that if the source ObservableSource issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling . <p > <img width = 640 height = 320 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / buffer6 . s . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > You specify which { @link Scheduler } this operator will use . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . CUSTOM ) public final < U extends Collection < ? super T > > Observable < U > buffer ( long timespan , TimeUnit unit , Scheduler scheduler , int count , Callable < U > bufferSupplier , boolean restartTimerOnMaxSize ) { ObjectHelper . requireNonNull ( unit , "unit is null" ) ; ObjectHelper . requireNonNull ( scheduler , "scheduler is null" ) ; ObjectHelper . requireNonNull ( bufferSupplier , "bufferSupplier is null" ) ; ObjectHelper . verifyPositive ( count , "count" ) ; return RxJavaPlugins . onAssembly ( new ObservableBufferTimed < T , U > ( this , timespan , timespan , unit , scheduler , bufferSupplier , count , restartTimerOnMaxSize ) ) ; }


Input: Returns an Observable that emits buffers of items it collects from the source ObservableSource . The resulting ObservableSource emits buffers that it creates when the specified { @code openingIndicator } ObservableSource emits an item and closes when the ObservableSource returned from { @code closingIndicator } emits an item . If any of the source ObservableSource { @code openingIndicator } or { @code closingIndicator } issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling . <p > <img width = 640 height = 470 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / buffer2 . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > This version of { @code buffer } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < TOpening , TClosing > Observable < List < T > > buffer ( ObservableSource < ? extends TOpening > openingIndicator , Function < ? super TOpening , ? extends ObservableSource < ? extends TClosing > > closingIndicator ) { return buffer ( openingIndicator , closingIndicator , ArrayListSupplier . < T > asCallable ( ) ) ; }


Input: Returns an Observable that emits buffers of items it collects from the source ObservableSource . The resulting ObservableSource emits buffers that it creates when the specified { @code openingIndicator } ObservableSource emits an item and closes when the ObservableSource returned from { @code closingIndicator } emits an item . If any of the source ObservableSource { @code openingIndicator } or { @code closingIndicator } issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling . <p > <img width = 640 height = 470 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / buffer2 . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > This version of { @code buffer } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < TOpening , TClosing , U extends Collection < ? super T > > Observable < U > buffer ( ObservableSource < ? extends TOpening > openingIndicator , Function < ? super TOpening , ? extends ObservableSource < ? extends TClosing > > closingIndicator , Callable < U > bufferSupplier ) { ObjectHelper . requireNonNull ( openingIndicator , "openingIndicator is null" ) ; ObjectHelper . requireNonNull ( closingIndicator , "closingIndicator is null" ) ; ObjectHelper . requireNonNull ( bufferSupplier , "bufferSupplier is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableBufferBoundary < T , U , TOpening , TClosing > ( this , openingIndicator , closingIndicator , bufferSupplier ) ) ; }


Input: Returns an Observable that emits non - overlapping buffered items from the source ObservableSource each time the specified boundary ObservableSource emits an item . <p > <img width = 640 height = 395 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / buffer8 . png alt = > <p > Completion of either the source or the boundary ObservableSource causes the returned ObservableSource to emit the latest buffer and complete . If either the source ObservableSource or the boundary ObservableSource issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > This version of { @code buffer } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < B > Observable < List < T > > buffer ( ObservableSource < B > boundary ) { return buffer ( boundary , ArrayListSupplier . < T > asCallable ( ) ) ; }


Input: Returns an Observable that emits non - overlapping buffered items from the source ObservableSource each time the specified boundary ObservableSource emits an item . <p > <img width = 640 height = 395 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / buffer8 . png alt = > <p > Completion of either the source or the boundary ObservableSource causes the returned ObservableSource to emit the latest buffer and complete . If either the source ObservableSource or the boundary ObservableSource issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > This version of { @code buffer } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < B > Observable < List < T > > buffer ( ObservableSource < B > boundary , final int initialCapacity ) { ObjectHelper . verifyPositive ( initialCapacity , "initialCapacity" ) ; return buffer ( boundary , Functions . < T > createArrayList ( initialCapacity ) ) ; }


Input: Returns an Observable that emits non - overlapping buffered items from the source ObservableSource each time the specified boundary ObservableSource emits an item . <p > <img width = 640 height = 395 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / buffer8 . png alt = > <p > Completion of either the source or the boundary ObservableSource causes the returned ObservableSource to emit the latest buffer and complete . If either the source ObservableSource or the boundary ObservableSource issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > This version of { @code buffer } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < B , U extends Collection < ? super T > > Observable < U > buffer ( ObservableSource < B > boundary , Callable < U > bufferSupplier ) { ObjectHelper . requireNonNull ( boundary , "boundary is null" ) ; ObjectHelper . requireNonNull ( bufferSupplier , "bufferSupplier is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableBufferExactBoundary < T , U , B > ( this , boundary , bufferSupplier ) ) ; }


Input: Returns an Observable that emits buffers of items it collects from the source ObservableSource . The resulting ObservableSource emits connected non - overlapping buffers . It emits the current buffer and replaces it with a new buffer whenever the ObservableSource produced by the specified { @code boundarySupplier } emits an item . <p > <img width = 640 height = 395 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / buffer1 . png alt = > <p > If either the source { @code ObservableSource } or the boundary { @code ObservableSource } issues an { @code onError } notification the event is passed on immediately without first emitting the buffer it is in the process of assembling . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > This version of { @code buffer } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < B > Observable < List < T > > buffer ( Callable < ? extends ObservableSource < B > > boundarySupplier ) { return buffer ( boundarySupplier , ArrayListSupplier . < T > asCallable ( ) ) ; }


Input: Returns an Observable that subscribes to this ObservableSource lazily caches all of its events and replays them in the same order as received to all the downstream subscribers . <p > <img width = 640 height = 410 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / cacheWithInitialCapacity . o . png alt = > <p > This is useful when you want an ObservableSource to cache responses and you can t control the subscribe / dispose behavior of all the { @link Observer } s . <p > The operator subscribes only when the first downstream subscriber subscribes and maintains a single subscription towards this ObservableSource . In contrast the operator family of { @link #replay () } that return a { @link ConnectableObservable } require an explicit call to { @link ConnectableObservable#connect () } . <p > <em > Note : < / em > You sacrifice the ability to dispose the origin when you use the { @code cache } Observer so be careful not to use this Observer on ObservableSources that emit an infinite or very large number of items that will use up memory . A possible workaround is to apply takeUntil with a predicate or another source before ( and perhaps after ) the application of cache () . <pre > <code > AtomicBoolean shouldStop = new AtomicBoolean () ; [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Observable < T > cacheWithInitialCapacity ( int initialCapacity ) { ObjectHelper . verifyPositive ( initialCapacity , "initialCapacity" ) ; return RxJavaPlugins . onAssembly ( new ObservableCache < T > ( this , initialCapacity ) ) ; }


Input: Collects items emitted by the finite source ObservableSource into a single mutable data structure and returns a Single that emits this structure . <p > <img width = 640 height = 330 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / collect . 2 . png alt = > <p > This is a simplified version of { @code reduce } that does not need to return the state on each pass . <p > Note that this operator requires the upstream to signal { @code onComplete } for the accumulator object 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 collect } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < U > Single < U > collect ( Callable < ? extends U > initialValueSupplier , BiConsumer < ? super U , ? super T > collector ) { ObjectHelper . requireNonNull ( initialValueSupplier , "initialValueSupplier is null" ) ; ObjectHelper . requireNonNull ( collector , "collector is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableCollectSingle < T , U > ( this , initialValueSupplier , collector ) ) ; }


Input: Collects items emitted by the finite source ObservableSource into a single mutable data structure and returns a Single that emits this structure . <p > <img width = 640 height = 330 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / collectInto . o . png alt = > <p > This is a simplified version of { @code reduce } that does not need to return the state on each pass . <p > Note that this operator requires the upstream to signal { @code onComplete } for the accumulator object 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 collectInto } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < U > Single < U > collectInto ( final U initialValue , BiConsumer < ? super U , ? super T > collector ) { ObjectHelper . requireNonNull ( initialValue , "initialValue is null" ) ; return collect ( Functions . justCallable ( initialValue ) , collector ) ; }


Input: Transform an ObservableSource by applying a particular Transformer function to it . <p > This method operates on the ObservableSource itself whereas { @link #lift } operates on the ObservableSource s Observers . <p > If the operator you are creating is designed to act on the individual items emitted by a source ObservableSource use { @link #lift } . If your operator is designed to transform the source ObservableSource as a whole ( for instance by applying a particular set of existing RxJava operators to it ) use { @code compose } . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code compose } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ SuppressWarnings ( "unchecked" ) @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < R > Observable < R > compose ( ObservableTransformer < ? super T , ? extends R > composer ) { return wrap ( ( ( ObservableTransformer < T , R > ) ObjectHelper . requireNonNull ( composer , "composer is null" ) ) . apply ( this ) ) ; }


Input: Returns a new Observable that emits items resulting from applying a function that you supply to each item emitted by the source ObservableSource where that function returns an ObservableSource and then emitting the items that result from concatenating those resulting ObservableSources . <p > <img width = 640 height = 305 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / concatMap . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code concatMap } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < R > Observable < R > concatMap ( Function < ? super T , ? extends ObservableSource < ? extends R > > mapper ) { return concatMap ( mapper , 2 ) ; }


Input: Returns a new Observable that emits items resulting from applying a function that you supply to each item emitted by the source ObservableSource where that function returns an ObservableSource and then emitting the items that result from concatenating those resulting ObservableSources . <p > <img width = 640 height = 305 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / concatMap . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code concatMap } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < R > Observable < R > concatMap ( Function < ? super T , ? extends ObservableSource < ? extends R > > mapper , int prefetch ) { ObjectHelper . requireNonNull ( mapper , "mapper is null" ) ; ObjectHelper . verifyPositive ( prefetch , "prefetch" ) ; if ( this instanceof ScalarCallable ) { @ SuppressWarnings ( "unchecked" ) T v = ( ( ScalarCallable < T > ) this ) . call ( ) ; if ( v == null ) { return empty ( ) ; } return ObservableScalarXMap . scalarXMap ( v , mapper ) ; } return RxJavaPlugins . onAssembly ( new ObservableConcatMap < T , R > ( this , mapper , prefetch , ErrorMode . IMMEDIATE ) ) ; }


Input: Maps each of the items into an ObservableSource subscribes to them one after the other one at a time and emits their values in order while delaying any error from either this or any of the inner ObservableSources till all of them terminate . <p > <img width = 640 height = 347 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / concatMapDelayError . o . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code concatMapDelayError } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < R > Observable < R > concatMapDelayError ( Function < ? super T , ? extends ObservableSource < ? extends R > > mapper ) { return concatMapDelayError ( mapper , bufferSize ( ) , true ) ; }


Input: Maps a sequence of values into ObservableSources and concatenates these ObservableSources eagerly into a single ObservableSource . <p > Eager concatenation means that once a subscriber subscribes this operator subscribes to all of the source ObservableSources . The operator buffers the values emitted by these ObservableSources and then drains them in order each one after the previous one completes . <p > <img width = 640 height = 360 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / concatMapEager . o . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > This method does not operate by default on a particular { [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < R > Observable < R > concatMapEager ( Function < ? super T , ? extends ObservableSource < ? extends R > > mapper ) { return concatMapEager ( mapper , Integer . MAX_VALUE , bufferSize ( ) ) ; }


Input: Maps a sequence of values into ObservableSources and concatenates these ObservableSources eagerly into a single ObservableSource . <p > Eager concatenation means that once a subscriber subscribes this operator subscribes to all of the source ObservableSources . The operator buffers the values emitted by these ObservableSources and then drains them in order each one after the previous one completes . <p > <img width = 640 height = 360 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / concatMapEager . o . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > This method does not operate by default on a particular { [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < R > Observable < R > concatMapEager ( Function < ? super T , ? extends ObservableSource < ? extends R > > mapper , int maxConcurrency , int prefetch ) { ObjectHelper . requireNonNull ( mapper , "mapper is null" ) ; ObjectHelper . verifyPositive ( maxConcurrency , "maxConcurrency" ) ; ObjectHelper . verifyPositive ( prefetch , "prefetch" ) ; return RxJavaPlugins . onAssembly ( new ObservableConcatMapEager < T , R > ( this , mapper , ErrorMode . IMMEDIATE , maxConcurrency , prefetch ) ) ; }


Input: Maps a sequence of values into ObservableSources and concatenates these ObservableSources eagerly into a single ObservableSource . <p > Eager concatenation means that once a subscriber subscribes this operator subscribes to all of the source ObservableSources . The operator buffers the values emitted by these ObservableSources and then drains them in order each one after the previous one completes . <p > <img width = 640 height = 390 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / concatMapEagerDelayError . o . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > This method does not operate by default on a particular { [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < R > Observable < R > concatMapEagerDelayError ( Function < ? super T , ? extends ObservableSource < ? extends R > > mapper , int maxConcurrency , int prefetch , boolean tillTheEnd ) { ObjectHelper . requireNonNull ( mapper , "mapper is null" ) ; ObjectHelper . verifyPositive ( maxConcurrency , "maxConcurrency" ) ; ObjectHelper . verifyPositive ( prefetch , "prefetch" ) ; return RxJavaPlugins . onAssembly ( new ObservableConcatMapEager < T , R > ( this , mapper , tillTheEnd ? ErrorMode . END : ErrorMode . BOUNDARY , maxConcurrency , prefetch ) ) ; }