signature:
public class Observable { /** * Instructs an ObservableSource to emit an item ( returned by a specified function ) rather than invoking
 * { @ link Observer # onError onError } if it encounters an error .
 * < img width = " 640 " height = " 310 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / onErrorReturn . o . png " alt = " " >
 * By default , when an ObservableSource encounters an error that prevents it from emitting the expected item to
 * its { @ link Observer } , the ObservableSource invokes its Observer ' s { @ code onError } method , and then quits
 * without invoking any more of its Observer ' s methods . The { @ code onErrorReturn } method changes this
 * behavior . If you pass a function ( { @ code resumeFunction } ) to an ObservableSource ' s { @ code onErrorReturn }
 * method , if the original ObservableSource encounters an error , instead of invoking its Observer ' s
 * { @ code onError } method , it will instead emit the return value of { @ code resumeFunction } .
 * You can use this to prevent errors from propagating or to supply fallback data should errors be
 * encountered .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code onErrorReturn } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param valueSupplier
 * a function that returns a single value that will be emitted along with a regular onComplete in case
 * the current Observable signals an onError event
 * @ return the original ObservableSource with appropriately modified behavior
 * @ see < a href = " http : / / reactivex . io / documentation / operators / catch . html " > ReactiveX operators documentation : Catch < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Observable < T > onErrorReturn ( Function < ? super Throwable , ? extends T > valueSupplier ) { } }

implementation: ObjectHelper . requireNonNull ( valueSupplier , "valueSupplier is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableOnErrorReturn < T > ( this , valueSupplier ) ) ;


signature:
public class Observable { /** * Instructs an ObservableSource to pass control to another ObservableSource rather than invoking
 * { @ link Observer # onError onError } if it encounters an { @ link java . lang . Exception } .
 * This differs from { @ link # onErrorResumeNext } in that this one does not handle { @ link java . lang . Throwable }
 * or { @ link java . lang . Error } but lets those continue through .
 * < img width = " 640 " height = " 310 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / onExceptionResumeNextViaObservableSource . png " alt = " " >
 * By default , when an ObservableSource encounters an exception that prevents it from emitting the expected item
 * to its { @ link Observer } , the ObservableSource invokes its Observer ' s { @ code onError } method , and then quits
 * without invoking any more of its Observer ' s methods . The { @ code onExceptionResumeNext } method changes
 * this behavior . If you pass another ObservableSource ( { @ code resumeSequence } ) to an ObservableSource ' s
 * { @ code onExceptionResumeNext } method , if the original ObservableSource encounters an exception , instead of
 * invoking its Observer ' s { @ code onError } method , it will instead relinquish control to
 * { @ code resumeSequence } which will invoke the Observer ' s { @ link Observer # onNext onNext } method if it is
 * able to do so . In such a case , because no ObservableSource necessarily invokes { @ code onError } , the Observer
 * may never know that an exception happened .
 * You can use this to prevent exceptions from propagating or to supply fallback data should exceptions be
 * encountered .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code onExceptionResumeNext } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param next
 * the next ObservableSource that will take over if the source ObservableSource encounters
 * an exception
 * @ return the original ObservableSource , with appropriately modified behavior
 * @ see < a href = " http : / / reactivex . io / documentation / operators / catch . html " > ReactiveX operators documentation : Catch < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Observable < T > onExceptionResumeNext ( final ObservableSource < ? extends T > next ) { } }

implementation: ObjectHelper . requireNonNull ( next , "next is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableOnErrorNext < T > ( this , Functions . justFunction ( next ) , true ) ) ;


signature:
public class Observable { /** * Nulls out references to the upstream producer and downstream Observer if
 * the sequence is terminated or downstream calls dispose ( ) .
 * < img width = " 640 " height = " 246 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / onTerminateDetach . o . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code onTerminateDetach } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ return an Observable which nulls out references to the upstream producer and downstream Observer if
 * the sequence is terminated or downstream calls dispose ( )
 * @ since 2.0 */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Observable < T > onTerminateDetach ( ) { } }

implementation: return RxJavaPlugins . onAssembly ( new ObservableDetach < T > ( this ) ) ;


signature:
public class Observable { /** * Returns an Observable that emits the results of invoking a specified selector on items emitted by a
 * { @ link ConnectableObservable } that shares a single subscription to the underlying sequence .
 * < img width = " 640 " height = " 647 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / publishFunction . o . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code publish } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param < R >
 * the type of items emitted by the resulting ObservableSource
 * @ param selector
 * a function that can use the multicasted source sequence as many times as needed , without
 * causing multiple subscriptions to the source sequence . Observers to the given source will
 * receive all notifications of the source from the time of the subscription forward .
 * @ return an Observable that emits the results of invoking the selector on the items emitted by a { @ link ConnectableObservable } that shares a single subscription to the underlying sequence
 * @ see < a href = " http : / / reactivex . io / documentation / operators / publish . html " > ReactiveX operators documentation : Publish < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < R > Observable < R > publish ( Function < ? super Observable < T > , ? extends ObservableSource < R > > selector ) { } }

implementation: ObjectHelper . requireNonNull ( selector , "selector is null" ) ; return RxJavaPlugins . onAssembly ( new ObservablePublishSelector < T , R > ( this , selector ) ) ;


signature:
public class Observable { /** * Returns a Maybe that applies a specified accumulator function to the first item emitted by a source
 * ObservableSource , then feeds the result of that function along with the second item emitted by the source
 * ObservableSource into the same function , and so on until all items have been emitted by the finite source ObservableSource ,
 * and emits the final result from the final call to your function as its sole item .
 * < img width = " 640 " height = " 320 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / reduce . 2 . png " alt = " " >
 * This technique , which is called " reduce " here , is sometimes called " aggregate , " " fold , " " accumulate , "
 * " compress , " or " inject " in other programming contexts . Groovy , for instance , has an { @ code inject } method
 * that does a similar operation on lists .
 * 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 reduce } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param reducer
 * an accumulator function to be invoked on each item emitted by the source ObservableSource , whose
 * result will be used in the next accumulator call
 * @ return a Maybe that emits a single item that is the result of accumulating the items emitted by
 * the source ObservableSource
 * @ see < a href = " http : / / reactivex . io / documentation / operators / reduce . html " > ReactiveX operators documentation : Reduce < / a >
 * @ see < a href = " http : / / en . wikipedia . org / wiki / Fold _ ( higher - order _ function ) " > Wikipedia : Fold ( higher - order function ) < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Maybe < T > reduce ( BiFunction < T , T , T > reducer ) { } }

implementation: ObjectHelper . requireNonNull ( reducer , "reducer is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableReduceMaybe < T > ( this , reducer ) ) ;


signature:
public class Observable { /** * Returns a Single that applies a specified accumulator function to the first item emitted by a source
 * ObservableSource and a specified seed value , then feeds the result of that function along with the second item
 * emitted by an ObservableSource into the same function , and so on until all items have been emitted by the
 * finite source ObservableSource , emitting the final result from the final call to your function as its sole item .
 * < img width = " 640 " height = " 325 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / reduceSeed . o . png " alt = " " >
 * This technique , which is called " reduce " here , is sometimes called " aggregate , " " fold , " " accumulate , "
 * " compress , " or " inject " in other programming contexts . Groovy , for instance , has an { @ code inject } method
 * that does a similar operation on lists .
 * Note that the { @ code seed } is shared among all subscribers to the resulting ObservableSource
 * and may cause problems if it is mutable . To make sure each subscriber gets its own value , defer
 * the application of this operator via { @ link # defer ( Callable ) } :
 * < pre > < code >
 * ObservableSource & lt ; T & gt ; source = . . .
 * Single . defer ( ( ) - & gt ; source . reduce ( new ArrayList & lt ; & gt ; ( ) , ( list , item ) - & gt ; list . add ( item ) ) ) ;
 * / / alternatively , by using compose to stay fluent
 * source . compose ( o - & gt ;
 * Observable . defer ( ( ) - & gt ; o . reduce ( new ArrayList & lt ; & gt ; ( ) , ( list , item ) - & gt ; list . add ( item ) ) . toObservable ( ) )
 * ) . firstOrError ( ) ;
 * / / or , by using reduceWith instead of reduce
 * source . reduceWith ( ( ) - & gt ; new ArrayList & lt ; & gt ; ( ) , ( list , item ) - & gt ; list . add ( item ) ) ) ;
 * < / code > < / pre >
 * 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 reduce } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param < R > the accumulator and output value type
 * @ param seed
 * the initial ( seed ) accumulator value
 * @ param reducer
 * an accumulator function to be invoked on each item emitted by the source ObservableSource , the
 * result of which will be used in the next accumulator call
 * @ return a Single that emits a single item that is the result of accumulating the output from the
 * items emitted by the source ObservableSource
 * @ see < a href = " http : / / reactivex . io / documentation / operators / reduce . html " > ReactiveX operators documentation : Reduce < / a >
 * @ see < a href = " http : / / en . wikipedia . org / wiki / Fold _ ( higher - order _ function ) " > Wikipedia : Fold ( higher - order function ) < / a >
 * @ see # reduceWith ( Callable , BiFunction ) */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < R > Single < R > reduce ( R seed , BiFunction < R , ? super T , R > reducer ) { } }

implementation: ObjectHelper . requireNonNull ( seed , "seed is null" ) ; ObjectHelper . requireNonNull ( reducer , "reducer is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableReduceSeedSingle < T , R > ( this , seed , reducer ) ) ;


signature:
public class Observable { /** * Returns a Single that applies a specified accumulator function to the first item emitted by a source
 * ObservableSource and a seed value derived from calling a specified seedSupplier , then feeds the result
 * of that function along with the second item emitted by an ObservableSource into the same function ,
 * and so on until all items have been emitted by the finite source ObservableSource , emitting the final result
 * from the final call to your function as its sole item .
 * < img width = " 640 " height = " 325 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / reduceWith . o . png " alt = " " >
 * This technique , which is called " reduce " here , is sometimes called " aggregate , " " fold , " " accumulate , "
 * " compress , " or " inject " in other programming contexts . Groovy , for instance , has an { @ code inject } method
 * that does a similar operation on lists .
 * 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 reduceWith } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param < R > the accumulator and output value type
 * @ param seedSupplier
 * the Callable that provides the initial ( seed ) accumulator value for each individual Observer
 * @ param reducer
 * an accumulator function to be invoked on each item emitted by the source ObservableSource , the
 * result of which will be used in the next accumulator call
 * @ return a Single that emits a single item that is the result of accumulating the output from the
 * items emitted by the source ObservableSource
 * @ see < a href = " http : / / reactivex . io / documentation / operators / reduce . html " > ReactiveX operators documentation : Reduce < / a >
 * @ see < a href = " http : / / en . wikipedia . org / wiki / Fold _ ( higher - order _ function ) " > Wikipedia : Fold ( higher - order function ) < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < R > Single < R > reduceWith ( Callable < R > seedSupplier , BiFunction < R , ? super T , R > reducer ) { } }

implementation: ObjectHelper . requireNonNull ( seedSupplier , "seedSupplier is null" ) ; ObjectHelper . requireNonNull ( reducer , "reducer is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableReduceWithSingle < T , R > ( this , seedSupplier , reducer ) ) ;


signature:
public class Observable { /** * Returns an Observable that repeats the sequence of items emitted by the source ObservableSource indefinitely .
 * < img width = " 640 " height = " 287 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / repeatInf . o . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code repeat } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ return an Observable that emits the items emitted by the source ObservableSource repeatedly and in sequence
 * @ see < a href = " http : / / reactivex . io / documentation / operators / repeat . html " > ReactiveX operators documentation : Repeat < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Observable < T > repeat ( ) { } }

implementation: return repeat ( Long . MAX_VALUE ) ;


signature:
public class Observable { /** * Returns an Observable that repeats the sequence of items emitted by the source ObservableSource at most
 * { @ code count } times .
 * < img width = " 640 " height = " 336 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / repeatCount . o . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code repeat } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param times
 * the number of times the source ObservableSource items are repeated , a count of 0 will yield an empty
 * sequence
 * @ return an Observable that repeats the sequence of items emitted by the source ObservableSource at most
 * { @ code count } times
 * @ throws IllegalArgumentException
 * if { @ code count } is less than zero
 * @ see < a href = " http : / / reactivex . io / documentation / operators / repeat . html " > ReactiveX operators documentation : Repeat < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Observable < T > repeat ( long times ) { } }

implementation: if ( times < 0 ) { throw new IllegalArgumentException ( "times >= 0 required but it was " + times ) ; } if ( times == 0 ) { return empty ( ) ; } return RxJavaPlugins . onAssembly ( new ObservableRepeat < T > ( this , times ) ) ;


signature:
public class Observable { /** * Returns an Observable that repeats the sequence of items emitted by the source ObservableSource until
 * the provided stop function returns true .
 * < img width = " 640 " height = " 262 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / repeatUntil . o . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code repeatUntil } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param stop
 * a boolean supplier that is called when the current Observable completes ;
 * if it returns true , the returned Observable completes ; if it returns false ,
 * the upstream Observable is resubscribed .
 * @ return the new Observable instance
 * @ throws NullPointerException
 * if { @ code stop } is null
 * @ see < a href = " http : / / reactivex . io / documentation / operators / repeat . html " > ReactiveX operators documentation : Repeat < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Observable < T > repeatUntil ( BooleanSupplier stop ) { } }

implementation: ObjectHelper . requireNonNull ( stop , "stop is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableRepeatUntil < T > ( this , stop ) ) ;


signature:
public class Observable { /** * Returns an Observable that emits the same values as the source ObservableSource with the exception of an
 * { @ code onComplete } . An { @ code onComplete } notification from the source will result in the emission of
 * a { @ code void } item to the ObservableSource provided as an argument to the { @ code notificationHandler }
 * function . If that ObservableSource calls { @ code onComplete } or { @ code onError } then { @ code repeatWhen } will
 * call { @ code onComplete } or { @ code onError } on the child subscription . Otherwise , this ObservableSource will
 * resubscribe to the source ObservableSource .
 * < img width = " 640 " height = " 430 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / repeatWhen . f . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code repeatWhen } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param handler
 * receives an ObservableSource of notifications with which a user can complete or error , aborting the repeat .
 * @ return the source ObservableSource modified with repeat logic
 * @ see < a href = " http : / / reactivex . io / documentation / operators / repeat . html " > ReactiveX operators documentation : Repeat < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Observable < T > repeatWhen ( final Function < ? super Observable < Object > , ? extends ObservableSource < ? > > handler ) { } }

implementation: ObjectHelper . requireNonNull ( handler , "handler is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableRepeatWhen < T > ( this , handler ) ) ;


signature:
public class Observable { /** * Returns an Observable that emits items that are the results of invoking a specified selector on the items
 * emitted by a { @ link ConnectableObservable } that shares a single subscription to the source ObservableSource .
 * < img width = " 640 " height = " 449 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / replay . o . f . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > This version of { @ code replay } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param < R >
 * the type of items emitted by the resulting ObservableSource
 * @ param selector
 * the selector function , which can use the multicasted sequence as many times as needed , without
 * causing multiple subscriptions to the ObservableSource
 * @ return an Observable that emits items that are the results of invoking the selector on a
 * { @ link ConnectableObservable } that shares a single subscription to the source ObservableSource
 * @ see < a href = " http : / / reactivex . io / documentation / operators / replay . html " > ReactiveX operators documentation : Replay < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < R > Observable < R > replay ( Function < ? super Observable < T > , ? extends ObservableSource < R > > selector ) { } }

implementation: ObjectHelper . requireNonNull ( selector , "selector is null" ) ; return ObservableReplay . multicastSelector ( ObservableInternalHelper . replayCallable ( this ) , selector ) ;


signature:
public class Observable { /** * Returns an Observable that emits items that are the results of invoking a specified selector on items
 * emitted by a { @ link ConnectableObservable } that shares a single subscription to the source ObservableSource ,
 * replaying no more than { @ code bufferSize } items that were emitted within a specified time window .
 * Note that due to concurrency requirements , { @ code replay ( bufferSize ) } may hold strong references to more than
 * { @ code bufferSize } source emissions .
 * < img width = " 640 " height = " 350 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / replay . o . fnt . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > This version of { @ code replay } operates by default on the { @ code computation } { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param < R >
 * the type of items emitted by the resulting ObservableSource
 * @ param selector
 * a selector function , which can use the multicasted sequence as many times as needed , without
 * causing multiple subscriptions to the ObservableSource
 * @ param bufferSize
 * the buffer size that limits the number of items the connectable ObservableSource can replay
 * @ param time
 * the duration of the window in which the replayed items must have been emitted
 * @ param unit
 * the time unit of { @ code time }
 * @ return an Observable that emits items that are the results of invoking the selector on items emitted by
 * a { @ link ConnectableObservable } that shares a single subscription to the source ObservableSource , and
 * replays no more than { @ code bufferSize } items that were emitted within the window defined by
 * { @ code time }
 * @ see < a href = " http : / / reactivex . io / documentation / operators / replay . html " > ReactiveX operators documentation : Replay < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . COMPUTATION ) public final < R > Observable < R > replay ( Function < ? super Observable < T > , ? extends ObservableSource < R > > selector , int bufferSize , long time , TimeUnit unit ) { } }

implementation: return replay ( selector , bufferSize , time , unit , Schedulers . computation ( ) ) ;


signature:
public class Observable { /** * Returns an Observable that emits items that are the results of invoking a specified selector on items
 * emitted by a { @ link ConnectableObservable } that shares a single subscription to the source ObservableSource .
 * < img width = " 640 " height = " 406 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / replay . o . fs . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > You specify which { @ link Scheduler } this operator will use . < / dd >
 * < / dl >
 * @ param < R >
 * the type of items emitted by the resulting ObservableSource
 * @ param selector
 * a selector function , which can use the multicasted sequence as many times as needed , without
 * causing multiple subscriptions to the ObservableSource
 * @ param scheduler
 * the Scheduler where the replay is observed
 * @ return an Observable that emits items that are the results of invoking the selector on items emitted by
 * a { @ link ConnectableObservable } that shares a single subscription to the source ObservableSource ,
 * replaying all items
 * @ see < a href = " http : / / reactivex . io / documentation / operators / replay . html " > ReactiveX operators documentation : Replay < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . CUSTOM ) public final < R > Observable < R > replay ( final Function < ? super Observable < T > , ? extends ObservableSource < R > > selector , final Scheduler scheduler ) { } }

implementation: ObjectHelper . requireNonNull ( selector , "selector is null" ) ; ObjectHelper . requireNonNull ( scheduler , "scheduler is null" ) ; return ObservableReplay . multicastSelector ( ObservableInternalHelper . replayCallable ( this ) , ObservableInternalHelper . replayFunction ( selector , scheduler ) ) ;


signature:
public class Observable { /** * Returns a { @ link ConnectableObservable } that shares a single subscription to the source ObservableSource that
 * replays at most { @ code bufferSize } items emitted by that ObservableSource . A Connectable ObservableSource resembles
 * an ordinary ObservableSource , except that it does not begin emitting items when it is subscribed to , but only
 * when its { @ code connect } method is called .
 * Note that due to concurrency requirements , { @ code replay ( bufferSize ) } may hold strong references to more than
 * { @ code bufferSize } source emissions .
 * < img width = " 640 " height = " 445 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / replay . o . n . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > This version of { @ code replay } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param bufferSize
 * the buffer size that limits the number of items that can be replayed
 * @ return a { @ link ConnectableObservable } that shares a single subscription to the source ObservableSource and
 * replays at most { @ code bufferSize } items emitted by that ObservableSource
 * @ see < a href = " http : / / reactivex . io / documentation / operators / replay . html " > ReactiveX operators documentation : Replay < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final ConnectableObservable < T > replay ( final int bufferSize ) { } }

implementation: ObjectHelper . verifyPositive ( bufferSize , "bufferSize" ) ; return ObservableReplay . create ( this , bufferSize ) ;


signature:
public class Observable { /** * Returns a { @ link ConnectableObservable } that shares a single subscription to the source ObservableSource and
 * replays at most { @ code bufferSize } items that were emitted during a specified time window . A Connectable
 * ObservableSource resembles an ordinary ObservableSource , except that it does not begin emitting items when it is
 * subscribed to , but only when its { @ code connect } method is called .
 * Note that due to concurrency requirements , { @ code replay ( bufferSize ) } may hold strong references to more than
 * { @ code bufferSize } source emissions .
 * < img width = " 640 " height = " 445 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / replay . o . nt . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > This version of { @ code replay } operates by default on the { @ code computation } { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param bufferSize
 * the buffer size that limits the number of items that can be replayed
 * @ param time
 * the duration of the window in which the replayed items must have been emitted
 * @ param unit
 * the time unit of { @ code time }
 * @ return a { @ link ConnectableObservable } that shares a single subscription to the source ObservableSource and
 * replays at most { @ code bufferSize } items that were emitted during the window defined by
 * { @ code time }
 * @ see < a href = " http : / / reactivex . io / documentation / operators / replay . html " > ReactiveX operators documentation : Replay < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . COMPUTATION ) public final ConnectableObservable < T > replay ( int bufferSize , long time , TimeUnit unit ) { } }

implementation: return replay ( bufferSize , time , unit , Schedulers . computation ( ) ) ;


signature:
public class Observable { /** * Returns a { @ link ConnectableObservable } that shares a single subscription to the source ObservableSource and
 * that replays a maximum of { @ code bufferSize } items that are emitted within a specified time window . A
 * Connectable ObservableSource resembles an ordinary ObservableSource , except that it does not begin emitting items
 * when it is subscribed to , but only when its { @ code connect } method is called .
 * Note that due to concurrency requirements , { @ code replay ( bufferSize ) } may hold strong references to more than
 * { @ code bufferSize } source emissions .
 * < img width = " 640 " height = " 445 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / replay . o . nts . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > You specify which { @ link Scheduler } this operator will use . < / dd >
 * < / dl >
 * @ param bufferSize
 * the buffer size that limits the number of items that can be replayed
 * @ param time
 * the duration of the window in which the replayed items must have been emitted
 * @ param unit
 * the time unit of { @ code time }
 * @ param scheduler
 * the scheduler that is used as a time source for the window
 * @ return a { @ link ConnectableObservable } that shares a single subscription to the source ObservableSource and
 * replays at most { @ code bufferSize } items that were emitted during the window defined by
 * { @ code time }
 * @ throws IllegalArgumentException
 * if { @ code bufferSize } is less than zero
 * @ see < a href = " http : / / reactivex . io / documentation / operators / replay . html " > ReactiveX operators documentation : Replay < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . CUSTOM ) public final ConnectableObservable < T > replay ( final int bufferSize , final long time , final TimeUnit unit , final Scheduler scheduler ) { } }

implementation: ObjectHelper . verifyPositive ( bufferSize , "bufferSize" ) ; ObjectHelper . requireNonNull ( unit , "unit is null" ) ; ObjectHelper . requireNonNull ( scheduler , "scheduler is null" ) ; return ObservableReplay . create ( this , time , unit , scheduler , bufferSize ) ;


signature:
public class Observable { /** * Returns a { @ link ConnectableObservable } that shares a single subscription to the source ObservableSource and
 * replays at most { @ code bufferSize } items emitted by that ObservableSource . A Connectable ObservableSource resembles
 * an ordinary ObservableSource , except that it does not begin emitting items when it is subscribed to , but only
 * when its { @ code connect } method is called .
 * Note that due to concurrency requirements , { @ code replay ( bufferSize ) } may hold strong references to more than
 * { @ code bufferSize } source emissions .
 * < img width = " 640 " height = " 445 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / replay . o . ns . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > You specify which { @ link Scheduler } this operator will use . < / dd >
 * < / dl >
 * @ param bufferSize
 * the buffer size that limits the number of items that can be replayed
 * @ param scheduler
 * the scheduler on which the Observers will observe the emitted items
 * @ return a { @ link ConnectableObservable } that shares a single subscription to the source ObservableSource and
 * replays at most { @ code bufferSize } items that were emitted by the ObservableSource
 * @ see < a href = " http : / / reactivex . io / documentation / operators / replay . html " > ReactiveX operators documentation : Replay < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . CUSTOM ) public final ConnectableObservable < T > replay ( final int bufferSize , final Scheduler scheduler ) { } }

implementation: ObjectHelper . verifyPositive ( bufferSize , "bufferSize" ) ; return ObservableReplay . observeOn ( replay ( bufferSize ) , scheduler ) ;


signature:
public class Observable { /** * Returns a { @ link ConnectableObservable } that shares a single subscription to the source ObservableSource that
 * will replay all of its items and notifications to any future { @ link Observer } on the given
 * { @ link Scheduler } . A Connectable ObservableSource resembles an ordinary ObservableSource , except that it does not
 * begin emitting items when it is subscribed to , but only when its { @ code connect } method is called .
 * < img width = " 640 " height = " 445 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / replay . o . s . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > You specify which { @ link Scheduler } this operator will use . < / dd >
 * < / dl >
 * @ param scheduler
 * the Scheduler on which the Observers will observe the emitted items
 * @ return a { @ link ConnectableObservable } that shares a single subscription to the source ObservableSource that
 * will replay all of its items and notifications to any future { @ link Observer } on the given
 * { @ link Scheduler }
 * @ see < a href = " http : / / reactivex . io / documentation / operators / replay . html " > ReactiveX operators documentation : Replay < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . CUSTOM ) public final ConnectableObservable < T > replay ( final Scheduler scheduler ) { } }

implementation: ObjectHelper . requireNonNull ( scheduler , "scheduler is null" ) ; return ObservableReplay . observeOn ( replay ( ) , scheduler ) ;


signature:
public class Observable { /** * Returns an Observable that mirrors the source ObservableSource , resubscribing to it if it calls { @ code onError }
 * ( infinite retry count ) .
 * < img width = " 640 " height = " 315 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / retry . png " alt = " " >
 * If the source ObservableSource calls { @ link Observer # onError } , this method will resubscribe to the source
 * ObservableSource rather than propagating the { @ code onError } call .
 * Any and all items emitted by the source ObservableSource will be emitted by the resulting ObservableSource , even
 * those emitted during failed subscriptions . For example , if an ObservableSource fails at first but emits
 * { @ code [ 1 , 2 ] } then succeeds the second time and emits { @ code [ 1 , 2 , 3 , 4 , 5 ] } then the complete sequence
 * of emissions and notifications would be { @ code [ 1 , 2 , 1 , 2 , 3 , 4 , 5 , onComplete ] } .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code retry } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ return the source ObservableSource modified with retry logic
 * @ see < a href = " http : / / reactivex . io / documentation / operators / retry . html " > ReactiveX operators documentation : Retry < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Observable < T > retry ( ) { } }

implementation: return retry ( Long . MAX_VALUE , Functions . alwaysTrue ( ) ) ;


signature:
public class Observable { /** * Returns an Observable that mirrors the source ObservableSource , resubscribing to it if it calls { @ code onError }
 * and the predicate returns true for that specific exception and retry count .
 * < img width = " 640 " height = " 235 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / retry . o . ne . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code retry } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param predicate
 * the predicate that determines if a resubscription may happen in case of a specific exception
 * and retry count
 * @ return the source ObservableSource modified with retry logic
 * @ see # retry ( )
 * @ see < a href = " http : / / reactivex . io / documentation / operators / retry . html " > ReactiveX operators documentation : Retry < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Observable < T > retry ( BiPredicate < ? super Integer , ? super Throwable > predicate ) { } }

implementation: ObjectHelper . requireNonNull ( predicate , "predicate is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableRetryBiPredicate < T > ( this , predicate ) ) ;


signature:
public class Observable { /** * Returns an Observable that mirrors the source ObservableSource , resubscribing to it if it calls { @ code onError }
 * up to a specified number of retries .
 * < img width = " 640 " height = " 325 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / retry . o . n . png " alt = " " >
 * If the source ObservableSource calls { @ link Observer # onError } , this method will resubscribe to the source
 * ObservableSource for a maximum of { @ code count } resubscriptions rather than propagating the
 * { @ code onError } call .
 * Any and all items emitted by the source ObservableSource will be emitted by the resulting ObservableSource , even
 * those emitted during failed subscriptions . For example , if an ObservableSource fails at first but emits
 * { @ code [ 1 , 2 ] } then succeeds the second time and emits { @ code [ 1 , 2 , 3 , 4 , 5 ] } then the complete sequence
 * of emissions and notifications would be { @ code [ 1 , 2 , 1 , 2 , 3 , 4 , 5 , onComplete ] } .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code retry } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param times
 * the number of times to resubscribe if the current Observable fails
 * @ return the source ObservableSource modified with retry logic
 * @ see < a href = " http : / / reactivex . io / documentation / operators / retry . html " > ReactiveX operators documentation : Retry < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Observable < T > retry ( long times ) { } }

implementation: return retry ( times , Functions . alwaysTrue ( ) ) ;


signature:
public class Observable { /** * Retries at most times or until the predicate returns false , whichever happens first .
 * < img width = " 640 " height = " 269 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / retry . o . nfe . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code retry } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param times the number of times to resubscribe if the current Observable fails
 * @ param predicate the predicate called with the failure Throwable and should return true to trigger a retry .
 * @ return the new Observable instance */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Observable < T > retry ( long times , Predicate < ? super Throwable > predicate ) { } }

implementation: if ( times < 0 ) { throw new IllegalArgumentException ( "times >= 0 required but it was " + times ) ; } ObjectHelper . requireNonNull ( predicate , "predicate is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableRetryPredicate < T > ( this , times , predicate ) ) ;


signature:
public class Observable { /** * Retries the current Observable if the predicate returns true .
 * < img width = " 640 " height = " 248 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / retry . o . e . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code retry } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param predicate the predicate that receives the failure Throwable and should return true to trigger a retry .
 * @ return the new Observable instance */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Observable < T > retry ( Predicate < ? super Throwable > predicate ) { } }

implementation: return retry ( Long . MAX_VALUE , predicate ) ;


signature:
public class Observable { /** * Returns an Observable that emits the same values as the source ObservableSource with the exception of an
 * { @ code onError } . An { @ code onError } notification from the source will result in the emission of a
 * { @ link Throwable } item to the ObservableSource provided as an argument to the { @ code notificationHandler }
 * function . If that ObservableSource calls { @ code onComplete } or { @ code onError } then { @ code retry } will call
 * { @ code onComplete } or { @ code onError } on the child subscription . Otherwise , this ObservableSource will
 * resubscribe to the source ObservableSource .
 * < img width = " 640 " height = " 430 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / retryWhen . f . png " alt = " " >
 * Example :
 * This retries 3 times , each time incrementing the number of seconds it waits .
 * < pre > < code >
 * Observable . create ( ( ObservableEmitter & lt ; ? super String & gt ; s ) - & gt ; {
 * System . out . println ( " subscribing " ) ;
 * s . onError ( new RuntimeException ( " always fails " ) ) ;
 * } ) . retryWhen ( attempts - & gt ; {
 * return attempts . zipWith ( Observable . range ( 1 , 3 ) , ( n , i ) - & gt ; i ) . flatMap ( i - & gt ; {
 * System . out . println ( " delay retry by " + i + " second ( s ) " ) ;
 * return Observable . timer ( i , TimeUnit . SECONDS ) ;
 * } ) . blockingForEach ( System . out : : println ) ;
 * < / code > < / pre >
 * Output is :
 * < pre > { @ code
 * subscribing
 * delay retry by 1 second ( s )
 * subscribing
 * delay retry by 2 second ( s )
 * subscribing
 * delay retry by 3 second ( s )
 * subscribing
 * } < / pre >
 * Note that the inner { @ code ObservableSource } returned by the handler function should signal
 * either { @ code onNext } , { @ code onError } or { @ code onComplete } in response to the received
 * { @ code Throwable } to indicate the operator should retry or terminate . If the upstream to
 * the operator is asynchronous , signalling onNext followed by onComplete immediately may
 * result in the sequence to be completed immediately . Similarly , if this inner
 * { @ code ObservableSource } signals { @ code onError } or { @ code onComplete } while the upstream is
 * active , the sequence is terminated with the same signal immediately .
 * The following example demonstrates how to retry an asynchronous source with a delay :
 * < pre > < code >
 * Observable . timer ( 1 , TimeUnit . SECONDS )
 * . doOnSubscribe ( s - & gt ; System . out . println ( " subscribing " ) )
 * . map ( v - & gt ; { throw new RuntimeException ( ) ; } )
 * . retryWhen ( errors - & gt ; {
 * AtomicInteger counter = new AtomicInteger ( ) ;
 * return errors
 * . takeWhile ( e - & gt ; counter . getAndIncrement ( ) ! = 3)
 * . flatMap ( e - & gt ; {
 * System . out . println ( " delay retry by " + counter . get ( ) + " second ( s ) " ) ;
 * return Observable . timer ( counter . get ( ) , TimeUnit . SECONDS ) ;
 * . blockingSubscribe ( System . out : : println , System . out : : println ) ;
 * < / code > < / pre >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code retryWhen } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param handler
 * receives an ObservableSource of notifications with which a user can complete or error , aborting the
 * retry
 * @ return the source ObservableSource modified with retry logic
 * @ see < a href = " http : / / reactivex . io / documentation / operators / retry . html " > ReactiveX operators documentation : Retry < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Observable < T > retryWhen ( final Function < ? super Observable < Throwable > , ? extends ObservableSource < ? > > handler ) { } }

implementation: ObjectHelper . requireNonNull ( handler , "handler is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableRetryWhen < T > ( this , handler ) ) ;


signature:
public class Observable { /** * Returns an Observable that emits the most recently emitted item ( if any ) emitted by the source ObservableSource
 * within periodic time intervals .
 * < img width = " 640 " height = " 305 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / sample . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code sample } operates by default on the { @ code computation } { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param period
 * the sampling rate
 * @ param unit
 * the { @ link TimeUnit } in which { @ code period } is defined
 * @ return an Observable that emits the results of sampling the items emitted by the source ObservableSource at
 * the specified time interval
 * @ see < a href = " http : / / reactivex . io / documentation / operators / sample . html " > ReactiveX operators documentation : Sample < / a >
 * @ see # throttleLast ( long , TimeUnit ) */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . COMPUTATION ) public final Observable < T > sample ( long period , TimeUnit unit ) { } }

implementation: return sample ( period , unit , Schedulers . computation ( ) ) ;


signature:
public class Observable { /** * Returns an Observable that emits the most recently emitted item ( if any ) emitted by the source ObservableSource
 * within periodic time intervals , where the intervals are defined on a particular Scheduler .
 * < img width = " 640 " height = " 305 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / sample . s . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > You specify which { @ link Scheduler } this operator will use . < / dd >
 * < / dl >
 * @ param period
 * the sampling rate
 * @ param unit
 * the { @ link TimeUnit } in which { @ code period } is defined
 * @ param scheduler
 * the { @ link Scheduler } to use when sampling
 * @ return an Observable that emits the results of sampling the items emitted by the source ObservableSource at
 * the specified time interval
 * @ see < a href = " http : / / reactivex . io / documentation / operators / sample . html " > ReactiveX operators documentation : Sample < / a >
 * @ see # throttleLast ( long , TimeUnit , Scheduler ) */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . CUSTOM ) public final Observable < T > sample ( long period , TimeUnit unit , Scheduler scheduler ) { } }

implementation: ObjectHelper . requireNonNull ( unit , "unit is null" ) ; ObjectHelper . requireNonNull ( scheduler , "scheduler is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableSampleTimed < T > ( this , period , unit , scheduler , false ) ) ;


signature:
public class Observable { /** * Returns an Observable that , when the specified { @ code sampler } ObservableSource emits an item or completes ,
 * emits the most recently emitted item ( if any ) emitted by the source ObservableSource since the previous
 * emission from the { @ code sampler } ObservableSource .
 * < img width = " 640 " height = " 289 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / sample . o . nolast . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > This version of { @ code sample } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param < U > the element type of the sampler ObservableSource
 * @ param sampler
 * the ObservableSource to use for sampling the source ObservableSource
 * @ return an Observable that emits the results of sampling the items emitted by this ObservableSource whenever
 * the { @ code sampler } ObservableSource emits an item or completes
 * @ see < a href = " http : / / reactivex . io / documentation / operators / sample . html " > ReactiveX operators documentation : Sample < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < U > Observable < T > sample ( ObservableSource < U > sampler ) { } }

implementation: ObjectHelper . requireNonNull ( sampler , "sampler is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableSampleWithObservable < T > ( this , sampler , false ) ) ;


signature:
public class Observable { /** * Returns an Observable that applies a specified accumulator function to the first item emitted by a source
 * ObservableSource , then feeds the result of that function along with the second item emitted by the source
 * ObservableSource into the same function , and so on until all items have been emitted by the source ObservableSource ,
 * emitting the result of each of these iterations .
 * < img width = " 640 " height = " 320 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / scan . png " alt = " " >
 * This sort of function is sometimes called an accumulator .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code scan } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param accumulator
 * an accumulator function to be invoked on each item emitted by the source ObservableSource , whose
 * result will be emitted to { @ link Observer } s via { @ link Observer # onNext onNext } and used in the
 * next accumulator call
 * @ return an Observable that emits the results of each call to the accumulator function
 * @ see < a href = " http : / / reactivex . io / documentation / operators / scan . html " > ReactiveX operators documentation : Scan < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Observable < T > scan ( BiFunction < T , T , T > accumulator ) { } }

implementation: ObjectHelper . requireNonNull ( accumulator , "accumulator is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableScan < T > ( this , accumulator ) ) ;


signature:
public class Observable { /** * Returns an Observable that applies a specified accumulator function to the first item emitted by a source
 * ObservableSource and a seed value , then feeds the result of that function along with the second item emitted by
 * the source ObservableSource into the same function , and so on until all items have been emitted by the source
 * ObservableSource , emitting the result of each of these iterations .
 * < img width = " 640 " height = " 320 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / scanSeed . png " alt = " " >
 * This sort of function is sometimes called an accumulator .
 * Note that the ObservableSource that results from this method will emit { @ code initialValue } as its first
 * emitted item .
 * Note that the { @ code initialValue } is shared among all subscribers to the resulting ObservableSource
 * and may cause problems if it is mutable . To make sure each subscriber gets its own value , defer
 * the application of this operator via { @ link # defer ( Callable ) } :
 * < pre > < code >
 * ObservableSource & lt ; T & gt ; source = . . .
 * Observable . defer ( ( ) - & gt ; source . scan ( new ArrayList & lt ; & gt ; ( ) , ( list , item ) - & gt ; list . add ( item ) ) ) ;
 * / / alternatively , by using compose to stay fluent
 * source . compose ( o - & gt ;
 * Observable . defer ( ( ) - & gt ; o . scan ( new ArrayList & lt ; & gt ; ( ) , ( list , item ) - & gt ; list . add ( item ) ) )
 * < / code > < / pre >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code scan } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param < R > the initial , accumulator and result type
 * @ param initialValue
 * the initial ( seed ) accumulator item
 * @ param accumulator
 * an accumulator function to be invoked on each item emitted by the source ObservableSource , whose
 * result will be emitted to { @ link Observer } s via { @ link Observer # onNext onNext } and used in the
 * next accumulator call
 * @ return an Observable that emits { @ code initialValue } followed by the results of each call to the
 * accumulator function
 * @ see < a href = " http : / / reactivex . io / documentation / operators / scan . html " > ReactiveX operators documentation : Scan < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < R > Observable < R > scan ( final R initialValue , BiFunction < R , ? super T , R > accumulator ) { } }

implementation: ObjectHelper . requireNonNull ( initialValue , "initialValue is null" ) ; return scanWith ( Functions . justCallable ( initialValue ) , accumulator ) ;


signature:
public class Observable { /** * Returns an Observable that applies a specified accumulator function to the first item emitted by a source
 * ObservableSource and a seed value , then feeds the result of that function along with the second item emitted by
 * the source ObservableSource into the same function , and so on until all items have been emitted by the source
 * ObservableSource , emitting the result of each of these iterations .
 * < img width = " 640 " height = " 320 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / scanSeed . png " alt = " " >
 * This sort of function is sometimes called an accumulator .
 * Note that the ObservableSource that results from this method will emit the value returned
 * by the { @ code seedSupplier } as its first item .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code scanWith } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param < R > the initial , accumulator and result type
 * @ param seedSupplier
 * a Callable that returns the initial ( seed ) accumulator item for each individual Observer
 * @ param accumulator
 * an accumulator function to be invoked on each item emitted by the source ObservableSource , whose
 * result will be emitted to { @ link Observer } s via { @ link Observer # onNext onNext } and used in the
 * next accumulator call
 * @ return an Observable that emits { @ code initialValue } followed by the results of each call to the
 * accumulator function
 * @ see < a href = " http : / / reactivex . io / documentation / operators / scan . html " > ReactiveX operators documentation : Scan < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < R > Observable < R > scanWith ( Callable < R > seedSupplier , BiFunction < R , ? super T , R > accumulator ) { } }

implementation: ObjectHelper . requireNonNull ( seedSupplier , "seedSupplier is null" ) ; ObjectHelper . requireNonNull ( accumulator , "accumulator is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableScanSeed < T , R > ( this , seedSupplier , accumulator ) ) ;


signature:
public class Observable { /** * Forces an ObservableSource ' s emissions and notifications to be serialized and for it to obey
 * < a href = " http : / / reactivex . io / documentation / contract . html " > the ObservableSource contract < / a > in other ways .
 * It is possible for an ObservableSource to invoke its Observers ' methods asynchronously , perhaps from
 * different threads . This could make such an ObservableSource poorly - behaved , in that it might try to invoke
 * { @ code onComplete } or { @ code onError } before one of its { @ code onNext } invocations , or it might call
 * { @ code onNext } from two different threads concurrently . You can force such an ObservableSource to be
 * well - behaved and sequential by applying the { @ code serialize } method to it .
 * < img width = " 640 " height = " 400 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / synchronize . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code serialize } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ return an { @ link ObservableSource } that is guaranteed to be well - behaved and to make only serialized calls to
 * its observers
 * @ see < a href = " http : / / reactivex . io / documentation / operators / serialize . html " > ReactiveX operators documentation : Serialize < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Observable < T > serialize ( ) { } }

implementation: return RxJavaPlugins . onAssembly ( new ObservableSerialized < T > ( this ) ) ;


signature:
public class Observable { /** * Returns a Maybe that completes if this Observable is empty or emits the single item emitted by this Observable ,
 * or signals an { @ code IllegalArgumentException } if this Observable emits more than one item .
 * < img width = " 640 " height = " 217 " src = " https : / / raw . githubusercontent . com / wiki / ReactiveX / RxJava / images / rx - operators / singleElement . o . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code singleElement } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ return a { @ link Maybe } that emits the single item emitted by the source ObservableSource
 * @ see < a href = " http : / / reactivex . io / documentation / operators / first . html " > ReactiveX operators documentation : First < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Maybe < T > singleElement ( ) { } }

implementation: return RxJavaPlugins . onAssembly ( new ObservableSingleMaybe < T > ( this ) ) ;


signature:
public class Observable { /** * Returns a Single that emits the single item emitted by this Observable , if this Observable
 * emits only a single item , or a default item if the source ObservableSource emits no items . If the source
 * ObservableSource emits more than one item , an { @ code IllegalArgumentException } is signalled instead .
 * < img width = " 640 " height = " 315 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / single . 2 . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code single } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param defaultItem
 * a default value to emit if the source ObservableSource emits no item
 * @ return the new Single instance
 * @ see < a href = " http : / / reactivex . io / documentation / operators / first . html " > ReactiveX operators documentation : First < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Single < T > single ( T defaultItem ) { } }

implementation: ObjectHelper . requireNonNull ( defaultItem , "defaultItem is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableSingleSingle < T > ( this , defaultItem ) ) ;


signature:
public class Observable { /** * Returns a Single that emits the single item emitted by this Observable if this Observable
 * emits only a single item , otherwise
 * if this Observable completes without emitting any items or emits more than one item a
 * { @ link NoSuchElementException } or { @ code IllegalArgumentException } will be signalled respectively .
 * < img width = " 640 " height = " 228 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / singleOrError . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code singleOrError } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ return the new Single instance
 * @ see < a href = " http : / / reactivex . io / documentation / operators / first . html " > ReactiveX operators documentation : First < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Single < T > singleOrError ( ) { } }

implementation: return RxJavaPlugins . onAssembly ( new ObservableSingleSingle < T > ( this , null ) ) ;


signature:
public class Observable { /** * Returns an Observable that skips the first { @ code count } items emitted by the source ObservableSource and emits
 * the remainder .
 * < img width = " 640 " height = " 305 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / skip . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > This version of { @ code skip } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param count
 * the number of items to skip
 * @ return an Observable that is identical to the source ObservableSource except that it does not emit the first
 * { @ code count } items that the source ObservableSource emits
 * @ see < a href = " http : / / reactivex . io / documentation / operators / skip . html " > ReactiveX operators documentation : Skip < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Observable < T > skip ( long count ) { } }

implementation: if ( count <= 0 ) { return RxJavaPlugins . onAssembly ( this ) ; } return RxJavaPlugins . onAssembly ( new ObservableSkip < T > ( this , count ) ) ;


signature:
public class Observable { /** * Returns an Observable that skips values emitted by the source ObservableSource before a specified time window
 * elapses .
 * < img width = " 640 " height = " 305 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / skip . t . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code skip } does not operate on any particular scheduler but uses the current time
 * from the { @ code computation } { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param time
 * the length of the time window to skip
 * @ param unit
 * the time unit of { @ code time }
 * @ return an Observable that skips values emitted by the source ObservableSource before the time window defined
 * by { @ code time } elapses and the emits the remainder
 * @ see < a href = " http : / / reactivex . io / documentation / operators / skip . html " > ReactiveX operators documentation : Skip < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . COMPUTATION ) public final Observable < T > skip ( long time , TimeUnit unit ) { } }

implementation: return skipUntil ( timer ( time , unit ) ) ;


signature:
public class Observable { /** * Returns an Observable that skips values emitted by the source ObservableSource before a specified time window
 * on a specified { @ link Scheduler } elapses .
 * < img width = " 640 " height = " 305 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / skip . ts . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > You specify which { @ link Scheduler } this operator will use for the timed skipping < / dd >
 * < / dl >
 * @ param time
 * the length of the time window to skip
 * @ param unit
 * the time unit of { @ code time }
 * @ param scheduler
 * the { @ link Scheduler } on which the timed wait happens
 * @ return an Observable that skips values emitted by the source ObservableSource before the time window defined
 * by { @ code time } and { @ code scheduler } elapses , and then emits the remainder
 * @ see < a href = " http : / / reactivex . io / documentation / operators / skip . html " > ReactiveX operators documentation : Skip < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . CUSTOM ) public final Observable < T > skip ( long time , TimeUnit unit , Scheduler scheduler ) { } }

implementation: return skipUntil ( timer ( time , unit , scheduler ) ) ;


signature:
public class Observable { /** * Returns an Observable that drops a specified number of items from the end of the sequence emitted by the
 * source ObservableSource .
 * < img width = " 640 " height = " 305 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / skipLast . png " alt = " " >
 * This Observer accumulates a queue long enough to store the first { @ code count } items . As more items are
 * received , items are taken from the front of the queue and emitted by the returned ObservableSource . This causes
 * such items to be delayed .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > This version of { @ code skipLast } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param count
 * number of items to drop from the end of the source sequence
 * @ return an Observable that emits the items emitted by the source ObservableSource except for the dropped ones
 * at the end
 * @ throws IndexOutOfBoundsException
 * if { @ code count } is less than zero
 * @ see < a href = " http : / / reactivex . io / documentation / operators / skiplast . html " > ReactiveX operators documentation : SkipLast < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Observable < T > skipLast ( int count ) { } }

implementation: if ( count < 0 ) { throw new IndexOutOfBoundsException ( "count >= 0 required but it was " + count ) ; } if ( count == 0 ) { return RxJavaPlugins . onAssembly ( this ) ; } return RxJavaPlugins . onAssembly ( new ObservableSkipLast < T > ( this , count ) ) ;


signature:
public class Observable { /** * Returns an Observable that drops items emitted by the source ObservableSource during a specified time window
 * before the source completes .
 * < img width = " 640 " height = " 305 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / skipLast . t . png " alt = " " >
 * Note : this action will cache the latest items arriving in the specified time window .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code skipLast } does not operate on any particular scheduler but uses the current time
 * from the { @ code computation } { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param time
 * the length of the time window
 * @ param unit
 * the time unit of { @ code time }
 * @ return an Observable that drops those items emitted by the source ObservableSource in a time window before the
 * source completes defined by { @ code time }
 * @ see < a href = " http : / / reactivex . io / documentation / operators / skiplast . html " > ReactiveX operators documentation : SkipLast < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . TRAMPOLINE ) public final Observable < T > skipLast ( long time , TimeUnit unit ) { } }

implementation: return skipLast ( time , unit , Schedulers . trampoline ( ) , false , bufferSize ( ) ) ;


signature:
public class Observable { /** * Returns an Observable that drops items emitted by the source ObservableSource during a specified time window
 * ( defined on a specified scheduler ) before the source completes .
 * < img width = " 640 " height = " 340 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / skipLast . ts . png " alt = " " >
 * Note : this action will cache the latest items arriving in the specified time window .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > You specify which { @ link Scheduler } this operator will use for tracking the current time < / dd >
 * < / dl >
 * @ param time
 * the length of the time window
 * @ param unit
 * the time unit of { @ code time }
 * @ param scheduler
 * the scheduler used as the time source
 * @ return an Observable that drops those items emitted by the source ObservableSource in a time window before the
 * source completes defined by { @ code time } and { @ code scheduler }
 * @ see < a href = " http : / / reactivex . io / documentation / operators / skiplast . html " > ReactiveX operators documentation : SkipLast < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . CUSTOM ) public final Observable < T > skipLast ( long time , TimeUnit unit , Scheduler scheduler ) { } }

implementation: return skipLast ( time , unit , scheduler , false , bufferSize ( ) ) ;


signature:
public class Observable { /** * Returns an Observable that drops items emitted by the source ObservableSource during a specified time window
 * ( defined on a specified scheduler ) before the source completes .
 * < img width = " 640 " height = " 340 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / skipLast . ts . png " alt = " " >
 * Note : this action will cache the latest items arriving in the specified time window .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > You specify which { @ link Scheduler } this operator will use . < / dd >
 * < / dl >
 * @ param time
 * the length of the time window
 * @ param unit
 * the time unit of { @ code time }
 * @ param scheduler
 * the scheduler used as the time source
 * @ param delayError
 * if true , an exception signalled by the current Observable is delayed until the regular elements are consumed
 * by the downstream ; if false , an exception is immediately signalled and all regular elements dropped
 * @ param bufferSize
 * the hint about how many elements to expect to be skipped
 * @ return an Observable that drops those items emitted by the source ObservableSource in a time window before the
 * source completes defined by { @ code time } and { @ code scheduler }
 * @ see < a href = " http : / / reactivex . io / documentation / operators / skiplast . html " > ReactiveX operators documentation : SkipLast < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . CUSTOM ) public final Observable < T > skipLast ( long time , TimeUnit unit , Scheduler scheduler , boolean delayError , int bufferSize ) { } }

implementation:
ObjectHelper . requireNonNull ( unit , "unit is null" ) ; ObjectHelper . requireNonNull ( scheduler , "scheduler is null" ) ; ObjectHelper . verifyPositive ( bufferSize , "bufferSize" ) ; // the internal buffer holds pairs of ( timestamp , value ) so double the default buffer size
int s = bufferSize << 1 ; return RxJavaPlugins . onAssembly ( new ObservableSkipLastTimed < T > ( this , time , unit , scheduler , s , delayError ) ) ;


signature:
public class Observable { /** * Returns an Observable that skips items emitted by the source ObservableSource until a second ObservableSource emits
 * an item .
 * < img width = " 640 " height = " 375 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / skipUntil . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code skipUntil } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param < U > the element type of the other ObservableSource
 * @ param other
 * the second ObservableSource that has to emit an item before the source ObservableSource ' s elements begin
 * to be mirrored by the resulting ObservableSource
 * @ return an Observable that skips items from the source ObservableSource until the second ObservableSource emits an
 * item , then emits the remaining items
 * @ see < a href = " http : / / reactivex . io / documentation / operators / skipuntil . html " > ReactiveX operators documentation : SkipUntil < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < U > Observable < T > skipUntil ( ObservableSource < U > other ) { } }

implementation: ObjectHelper . requireNonNull ( other , "other is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableSkipUntil < T , U > ( this , other ) ) ;


signature:
public class Observable { /** * Returns an Observable that skips all items emitted by the source ObservableSource as long as a specified
 * condition holds true , but emits all further source items as soon as the condition becomes false .
 * < img width = " 640 " height = " 305 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / skipWhile . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code skipWhile } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param predicate
 * a function to test each item emitted from the source ObservableSource
 * @ return an Observable that begins emitting items emitted by the source ObservableSource when the specified
 * predicate becomes false
 * @ see < a href = " http : / / reactivex . io / documentation / operators / skipwhile . html " > ReactiveX operators documentation : SkipWhile < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Observable < T > skipWhile ( Predicate < ? super T > predicate ) { } }

implementation: ObjectHelper . requireNonNull ( predicate , "predicate is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableSkipWhile < T > ( this , predicate ) ) ;


signature:
public class Observable { /** * Returns an Observable that emits the events emitted by source ObservableSource , in a
 * sorted order . Each item emitted by the ObservableSource must implement { @ link Comparable } with respect to all
 * other items in the sequence .
 * < img width = " 640 " height = " 315 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / sorted . png " alt = " " >
 * If any item emitted by this Observable does not implement { @ link Comparable } with respect to
 * all other items emitted by this Observable , no items will be emitted and the
 * sequence is terminated with a { @ link ClassCastException } .
 * < p > Note that calling { @ code sorted } with long , non - terminating or infinite sources
 * might cause { @ link OutOfMemoryError }
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code sorted } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ return an Observable that emits the items emitted by the source ObservableSource in sorted order */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Observable < T > sorted ( ) { } }

implementation: return toList ( ) . toObservable ( ) . map ( Functions . listSorter ( Functions . < T > naturalComparator ( ) ) ) . flatMapIterable ( Functions . < List < T > > identity ( ) ) ;


signature:
public class Observable { /** * Returns an Observable that emits the events emitted by source ObservableSource , in a
 * sorted order based on a specified comparison function .
 * < p > Note that calling { @ code sorted } with long , non - terminating or infinite sources
 * might cause { @ link OutOfMemoryError }
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code sorted } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param sortFunction
 * a function that compares two items emitted by the source ObservableSource and returns an Integer
 * that indicates their sort order
 * @ return an Observable that emits the items emitted by the source ObservableSource in sorted order */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Observable < T > sorted ( Comparator < ? super T > sortFunction ) { } }

implementation: ObjectHelper . requireNonNull ( sortFunction , "sortFunction is null" ) ; return toList ( ) . toObservable ( ) . map ( Functions . listSorter ( sortFunction ) ) . flatMapIterable ( Functions . < List < T > > identity ( ) ) ;


signature:
public class Observable { /** * Returns an Observable that emits the items in a specified { @ link Iterable } before it begins to emit items
 * emitted by the source ObservableSource .
 * < img width = " 640 " height = " 315 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / startWith . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code startWith } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param items
 * an Iterable that contains the items you want the modified ObservableSource to emit first
 * @ return an Observable that emits the items in the specified { @ link Iterable } and then emits the items
 * emitted by the source ObservableSource
 * @ see < a href = " http : / / reactivex . io / documentation / operators / startwith . html " > ReactiveX operators documentation : StartWith < / a > */
@ SuppressWarnings ( "unchecked" ) @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Observable < T > startWith ( Iterable < ? extends T > items ) { } }

implementation: return concatArray ( fromIterable ( items ) , this ) ;


signature:
public class Observable { /** * Returns an Observable that emits the items in a specified { @ link ObservableSource } before it begins to emit
 * items emitted by the source ObservableSource .
 * < img width = " 640 " height = " 315 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / startWith . o . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code startWith } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param other
 * an ObservableSource that contains the items you want the modified ObservableSource to emit first
 * @ return an Observable that emits the items in the specified { @ link ObservableSource } and then emits the items
 * emitted by the source ObservableSource
 * @ see < a href = " http : / / reactivex . io / documentation / operators / startwith . html " > ReactiveX operators documentation : StartWith < / a > */
@ SuppressWarnings ( "unchecked" ) @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Observable < T > startWith ( ObservableSource < ? extends T > other ) { } }

implementation: ObjectHelper . requireNonNull ( other , "other is null" ) ; return concatArray ( other , this ) ;


signature:
public class Observable { /** * Returns an Observable that emits a specified item before it begins to emit items emitted by the source
 * ObservableSource .
 * < img width = " 640 " height = " 315 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / startWith . item . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code startWith } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param item
 * the item to emit first
 * @ return an Observable that emits the specified item before it begins to emit items emitted by the source
 * ObservableSource
 * @ see < a href = " http : / / reactivex . io / documentation / operators / startwith . html " > ReactiveX operators documentation : StartWith < / a > */
@ SuppressWarnings ( "unchecked" ) @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Observable < T > startWith ( T item ) { } }

implementation: ObjectHelper . requireNonNull ( item , "item is null" ) ; return concatArray ( just ( item ) , this ) ;


signature:
public class Observable { /** * Returns an Observable that emits the specified items before it begins to emit items emitted by the source
 * ObservableSource .
 * < img width = " 640 " height = " 315 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / startWithArray . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code startWithArray } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param items
 * the array of values to emit first
 * @ return an Observable that emits the specified items before it begins to emit items emitted by the source
 * ObservableSource
 * @ see < a href = " http : / / reactivex . io / documentation / operators / startwith . html " > ReactiveX operators documentation : StartWith < / a > */
@ SuppressWarnings ( "unchecked" ) @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Observable < T > startWithArray ( T ... items ) { } }

implementation: Observable < T > fromArray = fromArray ( items ) ; if ( fromArray == empty ( ) ) { return RxJavaPlugins . onAssembly ( this ) ; } return concatArray ( fromArray , this ) ;


signature:
public class Observable { /** * Subscribes to an ObservableSource and provides a callback to handle the items it emits .
 * If the Observable emits an error , it is wrapped into an
 * { @ link io . reactivex . exceptions . OnErrorNotImplementedException OnErrorNotImplementedException }
 * and routed to the RxJavaPlugins . onError handler .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code subscribe } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param onNext
 * the { @ code Consumer < T > } you have designed to accept emissions from the ObservableSource
 * @ return a { @ link Disposable } reference with which the caller can stop receiving items before
 * the ObservableSource has finished sending them
 * @ throws NullPointerException
 * if { @ code onNext } is null
 * @ see < a href = " http : / / reactivex . io / documentation / operators / subscribe . html " > ReactiveX operators documentation : Subscribe < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Disposable subscribe ( Consumer < ? super T > onNext ) { } }

implementation: return subscribe ( onNext , Functions . ON_ERROR_MISSING , Functions . EMPTY_ACTION , Functions . emptyConsumer ( ) ) ;


signature:
public class Observable { /** * Subscribes to an ObservableSource and provides callbacks to handle the items it emits and any error
 * notification it issues .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code subscribe } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param onNext
 * the { @ code Consumer < T > } you have designed to accept emissions from the ObservableSource
 * @ param onError
 * the { @ code Consumer < Throwable > } you have designed to accept any error notification from the
 * ObservableSource
 * @ return a { @ link Disposable } reference with which the caller can stop receiving items before
 * the ObservableSource has finished sending them
 * @ see < a href = " http : / / reactivex . io / documentation / operators / subscribe . html " > ReactiveX operators documentation : Subscribe < / a >
 * @ throws NullPointerException
 * if { @ code onNext } is null , or
 * if { @ code onError } is null */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Disposable subscribe ( Consumer < ? super T > onNext , Consumer < ? super Throwable > onError ) { } }

implementation: return subscribe ( onNext , onError , Functions . EMPTY_ACTION , Functions . emptyConsumer ( ) ) ;


signature:
public class Observable { /** * Subscribes to an ObservableSource and provides callbacks to handle the items it emits and any error or
 * completion notification it issues .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code subscribe } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param onNext
 * the { @ code Consumer < T > } you have designed to accept emissions from the ObservableSource
 * @ param onError
 * the { @ code Consumer < Throwable > } you have designed to accept any error notification from the
 * ObservableSource
 * @ param onComplete
 * the { @ code Action } you have designed to accept a completion notification from the
 * ObservableSource
 * @ param onSubscribe
 * the { @ code Consumer } that receives the upstream ' s Disposable
 * @ return a { @ link Disposable } reference with which the caller can stop receiving items before
 * the ObservableSource has finished sending them
 * @ throws NullPointerException
 * if { @ code onNext } is null , or
 * if { @ code onError } is null , or
 * if { @ code onComplete } is null , or
 * if { @ code onSubscribe } is null
 * @ see < a href = " http : / / reactivex . io / documentation / operators / subscribe . html " > ReactiveX operators documentation : Subscribe < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Disposable subscribe ( Consumer < ? super T > onNext , Consumer < ? super Throwable > onError , Action onComplete , Consumer < ? super Disposable > onSubscribe ) { } }

implementation: ObjectHelper . requireNonNull ( onNext , "onNext is null" ) ; ObjectHelper . requireNonNull ( onError , "onError is null" ) ; ObjectHelper . requireNonNull ( onComplete , "onComplete is null" ) ; ObjectHelper . requireNonNull ( onSubscribe , "onSubscribe is null" ) ; LambdaObserver < T > ls = new LambdaObserver < T > ( onNext , onError , onComplete , onSubscribe ) ; subscribe ( ls ) ; return ls ;


signature:
public class Observable { /** * Asynchronously subscribes Observers to this ObservableSource on the specified { @ link Scheduler } .
 * < img width = " 640 " height = " 305 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / subscribeOn . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > You specify which { @ link Scheduler } this operator will use . < / dd >
 * < / dl >
 * @ param scheduler
 * the { @ link Scheduler } to perform subscription actions on
 * @ return the source ObservableSource modified so that its subscriptions happen on the
 * specified { @ link Scheduler }
 * @ see < a href = " http : / / reactivex . io / documentation / operators / subscribeon . html " > ReactiveX operators documentation : SubscribeOn < / a >
 * @ see < a href = " http : / / www . grahamlea . com / 2014/07 / rxjava - threading - examples / " > RxJava Threading Examples < / a >
 * @ see # observeOn */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . CUSTOM ) public final Observable < T > subscribeOn ( Scheduler scheduler ) { } }

implementation: ObjectHelper . requireNonNull ( scheduler , "scheduler is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableSubscribeOn < T > ( this , scheduler ) ) ;


signature:
public class Observable { /** * Returns an Observable that emits the items emitted by the source ObservableSource or the items of an alternate
 * ObservableSource if the source ObservableSource is empty .
 * < img width = " 640 " height = " 255 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / switchifempty . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code switchIfEmpty } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param other
 * the alternate ObservableSource to subscribe to if the source does not emit any items
 * @ return an ObservableSource that emits the items emitted by the source ObservableSource or the items of an
 * alternate ObservableSource if the source ObservableSource is empty .
 * @ since 1.1.0 */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Observable < T > switchIfEmpty ( ObservableSource < ? extends T > other ) { } }

implementation: ObjectHelper . requireNonNull ( other , "other is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableSwitchIfEmpty < T > ( this , other ) ) ;


signature:
public class Observable { /** * Returns a new ObservableSource by applying a function that you supply to each item emitted by the source
 * ObservableSource that returns an ObservableSource , and then emitting the items emitted by the most recently emitted
 * of these ObservableSources .
 * The resulting ObservableSource completes if both the upstream ObservableSource and the last inner ObservableSource , if any , complete .
 * If the upstream ObservableSource signals an onError , the inner ObservableSource is disposed and the error delivered in - sequence .
 * < img width = " 640 " height = " 350 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / switchMap . png " alt = " " >
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code switchMap } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < / dl >
 * @ param < R > the element type of the inner ObservableSources and the output
 * @ param mapper
 * a function that , when applied to an item emitted by the source ObservableSource , returns an
 * ObservableSource
 * @ param bufferSize
 * the number of elements to prefetch from the current active inner ObservableSource
 * @ return an Observable that emits the items emitted by the ObservableSource returned from applying { @ code func } to the most recently emitted item emitted by the source ObservableSource
 * @ see < a href = " http : / / reactivex . io / documentation / operators / flatmap . html " > ReactiveX operators documentation : FlatMap < / a > */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < R > Observable < R > switchMap ( Function < ? super T , ? extends ObservableSource < ? extends R > > mapper , int bufferSize ) { } }

implementation: ObjectHelper . requireNonNull ( mapper , "mapper is null" ) ; ObjectHelper . verifyPositive ( bufferSize , "bufferSize" ) ; 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 ObservableSwitchMap < T , R > ( this , mapper , bufferSize , false ) ) ;


signature:
public class Observable { /** * Maps the upstream values into { @ link CompletableSource } s , subscribes to the newer one while
 * disposing the subscription to the previous { @ code CompletableSource } , thus keeping at most one
 * active { @ code CompletableSource } running .
 * < img width = " 640 " height = " 521 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / switchMapCompletable . f . png " alt = " " >
 * Since a { @ code CompletableSource } doesn ' t produce any items , the resulting reactive type of
 * this operator is a { @ link Completable } that can only indicate successful completion or
 * a failure in any of the inner { @ code CompletableSource } s or the failure of the current
 * { @ link Observable } .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code switchMapCompletable } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < dt > < b > Error handling : < / b > < / dt >
 * < dd > If either this { @ code Observable } or the active { @ code CompletableSource } signals an { @ code onError } ,
 * the resulting { @ code Completable } is terminated immediately with that { @ code Throwable } .
 * Use the { @ link # switchMapCompletableDelayError ( Function ) } to delay such inner failures until
 * every inner { @ code CompletableSource } s and the main { @ code Observable } terminates in some fashion .
 * If they fail concurrently , the operator may combine the { @ code Throwable } s into a
 * { @ link io . reactivex . exceptions . CompositeException CompositeException }
 * and signal it to the downstream instead . If any inactivated ( switched out ) { @ code CompletableSource }
 * signals an { @ code onError } late , the { @ code Throwable } s will be signalled to the global error handler via
 * { @ link RxJavaPlugins # onError ( Throwable ) } method as { @ code UndeliverableException } errors .
 * < / dd >
 * < / dl >
 * < p > History : 2.1.11 - experimental
 * @ param mapper the function called with each upstream item and should return a
 * { @ link CompletableSource } to be subscribed to and awaited for
 * ( non blockingly ) for its terminal event
 * @ return the new Completable instance
 * @ see # switchMapCompletableDelayError ( Function )
 * @ since 2.2 */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Completable switchMapCompletable ( @ NonNull Function < ? super T , ? extends CompletableSource > mapper ) { } }

implementation: ObjectHelper . requireNonNull ( mapper , "mapper is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableSwitchMapCompletable < T > ( this , mapper , false ) ) ;


signature:
public class Observable { /** * Maps the upstream values into { @ link CompletableSource } s , subscribes to the newer one while
 * disposing the subscription to the previous { @ code CompletableSource } , thus keeping at most one
 * active { @ code CompletableSource } running and delaying any main or inner errors until all
 * of them terminate .
 * < img width = " 640 " height = " 453 " src = " https : / / raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / switchMapCompletableDelayError . f . png " alt = " " >
 * Since a { @ code CompletableSource } doesn ' t produce any items , the resulting reactive type of
 * this operator is a { @ link Completable } that can only indicate successful completion or
 * a failure in any of the inner { @ code CompletableSource } s or the failure of the current
 * { @ link Observable } .
 * < dl >
 * < dt > < b > Scheduler : < / b > < / dt >
 * < dd > { @ code switchMapCompletableDelayError } does not operate by default on a particular { @ link Scheduler } . < / dd >
 * < dt > < b > Error handling : < / b > < / dt >
 * < dd > Errors of this { @ code Observable } and all the { @ code CompletableSource } s , who had the chance
 * to run to their completion , are delayed until
 * all of them terminate in some fashion . At this point , if there was only one failure , the respective
 * { @ code Throwable } is emitted to the downstream . It there were more than one failures , the
 * operator combines all { @ code Throwable } s into a { @ link io . reactivex . exceptions . CompositeException CompositeException }
 * and signals that to the downstream .
 * If any inactivated ( switched out ) { @ code CompletableSource }
 * signals an { @ code onError } late , the { @ code Throwable } s will be signalled to the global error handler via
 * { @ link RxJavaPlugins # onError ( Throwable ) } method as { @ code UndeliverableException } errors .
 * < / dd >
 * < / dl >
 * < p > History : 2.1.11 - experimental
 * @ param mapper the function called with each upstream item and should return a
 * { @ link CompletableSource } to be subscribed to and awaited for
 * ( non blockingly ) for its terminal event
 * @ return the new Completable instance
 * @ see # switchMapCompletableDelayError ( Function )
 * @ since 2.2 */
@ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Completable switchMapCompletableDelayError ( @ NonNull Function < ? super T , ? extends CompletableSource > mapper ) { } }

implementation: ObjectHelper . requireNonNull ( mapper , "mapper is null" ) ; return RxJavaPlugins . onAssembly ( new ObservableSwitchMapCompletable < T > ( this , mapper , true ) ) ;