Input: Subscribes to the source and calls the given actions on the current thread . [CODESPLIT] public static < T > void subscribe ( Publisher < ? extends T > o , final Consumer < ? super T > onNext , final Consumer < ? super Throwable > onError , final Action onComplete , int bufferSize ) { ObjectHelper . requireNonNull ( onNext , "onNext is null" ) ; ObjectHelper . requireNonNull ( onError , "onError is null" ) ; ObjectHelper . requireNonNull ( onComplete , "onComplete is null" ) ; ObjectHelper . verifyPositive ( bufferSize , "number > 0 required" ) ; subscribe ( o , new BoundedSubscriber < T > ( onNext , onError , onComplete , Functions . boundedConsumer ( bufferSize ) , bufferSize ) ) ; }


Input: Adds a resource to this ResourceObserver . [CODESPLIT] public final void add ( @ NonNull Disposable resource ) { ObjectHelper . requireNonNull ( resource , "resource is null" ) ; resources . add ( resource ) ; }


Input: Tries to subscribe to a possibly Callable source s mapped ObservableSource . [CODESPLIT] @ SuppressWarnings ( "unchecked" ) public static < T , R > boolean tryScalarXMapSubscribe ( ObservableSource < T > source , Observer < ? super R > observer , Function < ? super T , ? extends ObservableSource < ? extends R > > mapper ) { if ( source instanceof Callable ) { T t ; try { t = ( ( Callable < T > ) source ) . call ( ) ; } catch ( Throwable ex ) { Exceptions . throwIfFatal ( ex ) ; EmptyDisposable . error ( ex , observer ) ; return true ; } if ( t == null ) { EmptyDisposable . complete ( observer ) ; return true ; } ObservableSource < ? extends R > r ; try { r = ObjectHelper . requireNonNull ( mapper . apply ( t ) , "The mapper returned a null ObservableSource" ) ; } catch ( Throwable ex ) { Exceptions . throwIfFatal ( ex ) ; EmptyDisposable . error ( ex , observer ) ; return true ; } if ( r instanceof Callable ) { R u ; try { u = ( ( Callable < R > ) r ) . call ( ) ; } catch ( Throwable ex ) { Exceptions . throwIfFatal ( ex ) ; EmptyDisposable . error ( ex , observer ) ; return true ; } if ( u == null ) { EmptyDisposable . complete ( observer ) ; return true ; } ScalarDisposable < R > sd = new ScalarDisposable < R > ( observer , u ) ; observer . onSubscribe ( sd ) ; sd . run ( ) ; } else { r . subscribe ( observer ) ; } return true ; } return false ; }


Input: Maps a scalar value into an Observable and emits its values . [CODESPLIT] public static < T , U > Observable < U > scalarXMap ( T value , Function < ? super T , ? extends ObservableSource < ? extends U > > mapper ) { return RxJavaPlugins . onAssembly ( new ScalarXMapObservable < T , U > ( value , mapper ) ) ; }


Input: Creates a { [CODESPLIT] public static < T > MaybeObserver < T > create ( Observer < ? super T > downstream ) { return new MaybeToObservableObserver < T > ( downstream ) ; }


Input: Wraps an { [CODESPLIT] @ NonNull @ Experimental public static Scheduler from ( @ NonNull Executor executor , boolean interruptibleWorker ) { return new ExecutorScheduler ( executor , interruptibleWorker ) ; }


Input: Shuts down the standard Schedulers . <p > The operation is idempotent and thread - safe . [CODESPLIT] public static void shutdown ( ) { computation ( ) . shutdown ( ) ; io ( ) . shutdown ( ) ; newThread ( ) . shutdown ( ) ; single ( ) . shutdown ( ) ; trampoline ( ) . shutdown ( ) ; SchedulerPoolFactory . shutdown ( ) ; }


Input: Append a non - null value to the list . <p > Don t add null to the list! [CODESPLIT] public void add ( T value ) { final int c = capacity ; int o = offset ; if ( o == c ) { Object [ ] next = new Object [ c + 1 ] ; tail [ c ] = next ; tail = next ; o = 0 ; } tail [ o ] = value ; offset = o + 1 ; }


Input: Loops over all elements of the array until a null element is encountered or the given predicate returns true . [CODESPLIT] @ SuppressWarnings ( "unchecked" ) public void forEachWhile ( NonThrowingPredicate < ? super T > consumer ) { Object [ ] a = head ; final int c = capacity ; while ( a != null ) { for ( int i = 0 ; i < c ; i ++ ) { Object o = a [ i ] ; if ( o == null ) { break ; } if ( consumer . test ( ( T ) o ) ) { return ; } } a = ( Object [ ] ) a [ c ] ; } }


Input: Interprets the contents as NotificationLite objects and calls the appropriate Subscriber method . [CODESPLIT] public < U > boolean accept ( Subscriber < ? super U > subscriber ) { Object [ ] a = head ; final int c = capacity ; while ( a != null ) { for ( int i = 0 ; i < c ; i ++ ) { Object o = a [ i ] ; if ( o == null ) { break ; } if ( NotificationLite . acceptFull ( o , subscriber ) ) { return true ; } } a = ( Object [ ] ) a [ c ] ; } return false ; }


Input: Interprets the contents as NotificationLite objects and calls the appropriate Observer method . [CODESPLIT] public < U > boolean accept ( Observer < ? super U > observer ) { Object [ ] a = head ; final int c = capacity ; while ( a != null ) { for ( int i = 0 ; i < c ; i ++ ) { Object o = a [ i ] ; if ( o == null ) { break ; } if ( NotificationLite . acceptFull ( o , observer ) ) { return true ; } } a = ( Object [ ] ) a [ c ] ; } return false ; }


Input: Loops over all elements of the array until a null element is encountered or the given predicate returns true . [CODESPLIT] @ SuppressWarnings ( "unchecked" ) public < S > void forEachWhile ( S state , BiPredicate < ? super S , ? super T > consumer ) throws Exception { Object [ ] a = head ; final int c = capacity ; for ( ; ; ) { for ( int i = 0 ; i < c ; i ++ ) { Object o = a [ i ] ; if ( o == null ) { return ; } if ( consumer . test ( state , ( T ) o ) ) { return ; } } a = ( Object [ ] ) a [ c ] ; } }


Input: Runs multiple SingleSources and signals the events of the first one that signals ( disposing the rest ) . <p > <img width = 640 height = 515 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Single . amb . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Single < T > amb ( final Iterable < ? extends SingleSource < ? extends T > > sources ) { ObjectHelper . requireNonNull ( sources , "sources is null" ) ; return RxJavaPlugins . onAssembly ( new SingleAmb < T > ( null , sources ) ) ; }


Input: Runs multiple SingleSources and signals the events of the first one that signals ( disposing the rest ) . <p > <img width = 640 height = 515 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Single . ambArray . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) @ SuppressWarnings ( "unchecked" ) public static < T > Single < T > ambArray ( final SingleSource < ? extends T > ... sources ) { if ( sources . length == 0 ) { return error ( SingleInternalHelper . < T > emptyThrower ( ) ) ; } if ( sources . length == 1 ) { return wrap ( ( SingleSource < T > ) sources [ 0 ] ) ; } return RxJavaPlugins . onAssembly ( new SingleAmb < T > ( sources , null ) ) ; }


Input: Concatenate the single values in a non - overlapping fashion of the SingleSources provided in an array . <p > <img width = 640 height = 319 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Single . concatArray . png alt = > <dl > <dt > <b > Backpressure : < / b > < / dt > <dd > The returned { [CODESPLIT] @ CheckReturnValue @ NonNull @ BackpressureSupport ( BackpressureKind . FULL ) @ SchedulerSupport ( SchedulerSupport . NONE ) @ SuppressWarnings ( { "unchecked" , "rawtypes" } ) public static < T > Flowable < T > concatArray ( SingleSource < ? extends T > ... sources ) { return RxJavaPlugins . onAssembly ( new FlowableConcatMap ( Flowable . fromArray ( sources ) , SingleInternalHelper . toFlowable ( ) , 2 , ErrorMode . BOUNDARY ) ) ; }


Input: Calls a { [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Single < T > defer ( final Callable < ? extends SingleSource < ? extends T > > singleSupplier ) { ObjectHelper . requireNonNull ( singleSupplier , "singleSupplier is null" ) ; return RxJavaPlugins . onAssembly ( new SingleDefer < T > ( singleSupplier ) ) ; }


Input: Signals a Throwable returned by the callback function for each individual SingleObserver . <p > <img width = 640 height = 283 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Single . error . c . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Single < T > error ( final Callable < ? extends Throwable > errorSupplier ) { ObjectHelper . requireNonNull ( errorSupplier , "errorSupplier is null" ) ; return RxJavaPlugins . onAssembly ( new SingleError < T > ( errorSupplier ) ) ; }


Input: Returns a { @link Single } that invokes passed function and emits its result for each new SingleObserver that subscribes . <p > Allows you to defer execution of passed function until SingleObserver subscribes to the { @link Single } . It makes passed function lazy . Result of the function invocation will be emitted by the { @link Single } . <p > <img width = 640 height = 467 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Single . fromCallable . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code fromCallable } does not operate by default on a particular { @link Scheduler } . < / dd > <dt > <b > Error handling : < / b > < / dt > <dd > If the { @link Callable } throws an exception the respective { @link Throwable } is delivered to the downstream via { @link SingleObserver#onError ( Throwable ) } except when the downstream has disposed this { @code Single } source . In this latter case the { @code Throwable } is delivered to the global error handler via { @link RxJavaPlugins#onError ( Throwable ) } as an { @link io . reactivex . exceptions . UndeliverableException UndeliverableException } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Single < T > fromCallable ( final Callable < ? extends T > callable ) { ObjectHelper . requireNonNull ( callable , "callable is null" ) ; return RxJavaPlugins . onAssembly ( new SingleFromCallable < T > ( callable ) ) ; }


Input: Converts a { @link Future } into a { @code Single } . <p > <img width = 640 height = 315 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Single . from . Future . png alt = > <p > You can convert any object that supports the { @link Future } interface into a Single that emits the return value of the { @link Future#get } method of that object by passing the object into the { @code from } method . <p > <em > Important note : < / em > This Single is blocking ; you cannot dispose it . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code fromFuture } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Single < T > fromFuture ( Future < ? extends T > future ) { return toSingle ( Flowable . < T > fromFuture ( future ) ) ; }


Input: Converts a { @link Future } into a { @code Single } with a timeout on the Future . <p > <img width = 640 height = 315 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Single . from . Future . png alt = > <p > You can convert any object that supports the { @link Future } interface into a { @code Single } that emits the return value of the { @link Future#get } method of that object by passing the object into the { @code from } method . <p > <em > Important note : < / em > This { @code Single } is blocking ; you cannot dispose it . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code fromFuture } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Single < T > fromFuture ( Future < ? extends T > future , long timeout , TimeUnit unit ) { return toSingle ( Flowable . < T > fromFuture ( future , timeout , unit ) ) ; }


Input: Converts a { @link Future } into a { @code Single } with a timeout on the Future . <p > <img width = 640 height = 315 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Single . from . Future . png alt = > <p > You can convert any object that supports the { @link Future } interface into a { @code Single } that emits the return value of the { @link Future#get } method of that object by passing the object into the { @code from } method . <p > <em > Important note : < / em > This { @code Single } is blocking ; you cannot dispose it . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > You specify the { @link Scheduler } where the blocking wait will happen . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . CUSTOM ) public static < T > Single < T > fromFuture ( Future < ? extends T > future , long timeout , TimeUnit unit , Scheduler scheduler ) { return toSingle ( Flowable . < T > fromFuture ( future , timeout , unit , scheduler ) ) ; }


Input: Flattens a { @code Single } that emits a { @code Single } into a single { @code Single } that emits the item emitted by the nested { @code Single } without any transformation . <p > <img width = 640 height = 412 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Single . merge . oo . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code merge } does not operate by default on a particular { @link Scheduler } . < / dd > <dd > The resulting { @code Single } emits the outer source s or the inner { @code SingleSource } s { @code Throwable } as is . Unlike the other { @code merge () } operators this operator won t and can t produce a { @code CompositeException } because there is only one possibility for the outer or the inner { @code SingleSource } to emit an { @code onError } signal . Therefore there is no need for a { @code mergeDelayError ( SingleSource<SingleSource<T >> ) } operator . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) @ SuppressWarnings ( { "unchecked" , "rawtypes" } ) public static < T > Single < T > merge ( SingleSource < ? extends SingleSource < ? extends T > > source ) { ObjectHelper . requireNonNull ( source , "source is null" ) ; return RxJavaPlugins . onAssembly ( new SingleFlatMap < SingleSource < ? extends T > , T > ( source , ( Function ) Functions . identity ( ) ) ) ; }


Input: Merges a Flowable sequence of SingleSource instances into a single Flowable sequence running all SingleSources at once and delaying any error ( s ) until all sources succeed or fail . <dl > <dt > <b > Backpressure : < / b > < / dt > <dd > The returned { [CODESPLIT] @ CheckReturnValue @ NonNull @ BackpressureSupport ( BackpressureKind . FULL ) @ SchedulerSupport ( SchedulerSupport . NONE ) @ SuppressWarnings ( { "unchecked" , "rawtypes" } ) public static < T > Flowable < T > mergeDelayError ( Publisher < ? extends SingleSource < ? extends T > > sources ) { ObjectHelper . requireNonNull ( sources , "sources is null" ) ; return RxJavaPlugins . onAssembly ( new FlowableFlatMapPublisher ( sources , SingleInternalHelper . toFlowable ( ) , true , Integer . MAX_VALUE , Flowable . bufferSize ( ) ) ) ; }


Input: Returns a singleton instance of a never - signalling Single ( only calls onSubscribe ) . <p > <img width = 640 height = 244 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Single . never . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) @ SuppressWarnings ( "unchecked" ) public static < T > Single < T > never ( ) { return RxJavaPlugins . onAssembly ( ( Single < T > ) SingleNever . INSTANCE ) ; }


Input: Signals success with 0L value after the given delay for each SingleObserver . <p > <img width = 640 height = 292 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Single . timer . s . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > you specify the { [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . CUSTOM ) public static Single < Long > timer ( final long delay , final TimeUnit unit , final Scheduler scheduler ) { ObjectHelper . requireNonNull ( unit , "unit is null" ) ; ObjectHelper . requireNonNull ( scheduler , "scheduler is null" ) ; return RxJavaPlugins . onAssembly ( new SingleTimer ( delay , unit , scheduler ) ) ; }


Input: <strong > Advanced use only : < / strong > creates a Single instance without any safeguards by using a callback that is called with a SingleObserver . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Single < T > unsafeCreate ( SingleSource < T > onSubscribe ) { ObjectHelper . requireNonNull ( onSubscribe , "onSubscribe is null" ) ; if ( onSubscribe instanceof Single ) { throw new IllegalArgumentException ( "unsafeCreate(Single) should be upgraded" ) ; } return RxJavaPlugins . onAssembly ( new SingleFromUnsafeSource < T > ( onSubscribe ) ) ; }


Input: Allows using and disposing a resource while running a SingleSource instance generated from that resource ( similar to a try - with - resources ) . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T , U > Single < T > using ( Callable < U > resourceSupplier , Function < ? super U , ? extends SingleSource < ? extends T > > singleFunction , Consumer < ? super U > disposer ) { return using ( resourceSupplier , singleFunction , disposer , true ) ; }


Input: Calls the specified converter function during assembly time and returns its resulting value . <p > <img width = 640 height = 553 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Single . as . png alt = > <p > This allows fluent conversion to any other type . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < R > R as ( @ NonNull SingleConverter < T , ? extends R > converter ) { return ObjectHelper . requireNonNull ( converter , "converter is null" ) . apply ( this ) ; }


Input: Hides the identity of the current Single including the Disposable that is sent to the downstream via { [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Single < T > hide ( ) { return RxJavaPlugins . onAssembly ( new SingleHide < T > ( this ) ) ; }


Input: Transform a Single by applying a particular Transformer function to it . <p > <img width = 640 height = 612 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Single . compose . png alt = > <p > This method operates on the Single itself whereas { @link #lift } operates on the Single s SingleObservers . <p > If the operator you are creating is designed to act on the individual item emitted by a Single use { @link #lift } . If your operator is designed to transform the source Single as a whole ( for instance by applying a particular set of existing RxJava operators to it ) use { @code compose } . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code compose } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ SuppressWarnings ( "unchecked" ) @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < R > Single < R > compose ( SingleTransformer < ? super T , ? extends R > transformer ) { return wrap ( ( ( SingleTransformer < T , R > ) ObjectHelper . requireNonNull ( transformer , "transformer is null" ) ) . apply ( this ) ) ; }


Input: Stores the success value or exception from the current Single and replays it to late SingleObservers . <p > The returned Single subscribes to the current Single when the first SingleObserver subscribes . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code cache } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Single < T > cache ( ) { return RxJavaPlugins . onAssembly ( new SingleCache < T > ( this ) ) ; }


Input: Returns a Flowable that emits the item emitted by the source Single then the item emitted by the specified Single . <p > <img width = 640 height = 335 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Single . concatWith . png alt = > <dl > <dt > <b > Backpressure : < / b > < / dt > <dd > The returned { @code Flowable } honors the backpressure of the downstream consumer . < / dd > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code concatWith } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ BackpressureSupport ( BackpressureKind . FULL ) @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Flowable < T > concatWith ( SingleSource < ? extends T > other ) { return concat ( this , other ) ; }


Input: Delays the emission of the success signal from the current Single by the specified amount . An error signal will not be delayed . <p > <img width = 640 height = 457 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Single . delay . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code delay } operates by default on the { @code computation } { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . COMPUTATION ) public final Single < T > delay ( long time , TimeUnit unit ) { return delay ( time , unit , Schedulers . computation ( ) , false ) ; }


Input: Delays the emission of the success signal from the current Single by the specified amount . An error signal will not be delayed . <p > <img width = 640 height = 457 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Single . delay . s . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > you specify the { @link Scheduler } where the non - blocking wait and emission happens< / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . CUSTOM ) public final Single < T > delay ( final long time , final TimeUnit unit , final Scheduler scheduler ) { return delay ( time , unit , scheduler , false ) ; }


Input: Delays the emission of the success or error signal from the current Single by the specified amount . <p > <img width = 640 height = 457 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Single . delay . se . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > you specify the { [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . CUSTOM ) public final Single < T > delay ( final long time , final TimeUnit unit , final Scheduler scheduler , boolean delayError ) { ObjectHelper . requireNonNull ( unit , "unit is null" ) ; ObjectHelper . requireNonNull ( scheduler , "scheduler is null" ) ; return RxJavaPlugins . onAssembly ( new SingleDelay < T > ( this , time , unit , scheduler , delayError ) ) ; }


Input: Delays the actual subscription to the current Single until the given other CompletableSource completes . <p > If the delaying source signals an error that error is re - emitted and no subscription to the current Single happens . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final Single < T > delaySubscription ( CompletableSource other ) { ObjectHelper . requireNonNull ( other , "other is null" ) ; return RxJavaPlugins . onAssembly ( new SingleDelayWithCompletable < T > ( this , other ) ) ; }


Input: Delays the actual subscription to the current Single until the given time delay elapsed . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . COMPUTATION ) public final Single < T > delaySubscription ( long time , TimeUnit unit ) { return delaySubscription ( time , unit , Schedulers . computation ( ) ) ; }


Input: Delays the actual subscription to the current Single until the given time delay elapsed . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . CUSTOM ) public final Single < T > delaySubscription ( long time , TimeUnit unit , Scheduler scheduler ) { return delaySubscription ( Observable . timer ( time , unit , scheduler ) ) ; }


Input: Maps the { [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) @ Experimental public final < R > Maybe < R > dematerialize ( Function < ? super T , Notification < R > > selector ) { ObjectHelper . requireNonNull ( selector , "selector is null" ) ; return RxJavaPlugins . onAssembly ( new SingleDematerialize < T , R > ( this , selector ) ) ; }


Input: Calls the specified consumer with the success item after this item has been emitted to the downstream . <p > <img width = 640 height = 460 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Single . doAfterSuccess . png alt = > <p > Note that the { [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final Single < T > doAfterSuccess ( Consumer < ? super T > onAfterSuccess ) { ObjectHelper . requireNonNull ( onAfterSuccess , "onAfterSuccess is null" ) ; return RxJavaPlugins . onAssembly ( new SingleDoAfterSuccess < T > ( this , onAfterSuccess ) ) ; }


Input: Registers an { @link Action } to be called after this Single invokes either onSuccess or onError . <p > <img width = 640 height = 460 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Single . doAfterTerminate . png alt = > <p > Note that the { @code doAfterTerminate } action is shared between subscriptions and as such should be thread - safe . < / p > [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final Single < T > doAfterTerminate ( Action onAfterTerminate ) { ObjectHelper . requireNonNull ( onAfterTerminate , "onAfterTerminate is null" ) ; return RxJavaPlugins . onAssembly ( new SingleDoAfterTerminate < T > ( this , onAfterTerminate ) ) ; }


Input: Calls the specified action after this Single signals onSuccess or onError or gets disposed by the downstream . <p > In case of a race between a terminal event and a dispose call the provided { [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final Single < T > doFinally ( Action onFinally ) { ObjectHelper . requireNonNull ( onFinally , "onFinally is null" ) ; return RxJavaPlugins . onAssembly ( new SingleDoFinally < T > ( this , onFinally ) ) ; }


Input: Calls the shared consumer with the Disposable sent through the onSubscribe for each SingleObserver that subscribes to the current Single . <p > <img width = 640 height = 347 src = https : // raw . githubusercontent . com / wiki / ReactiveX / RxJava / images / rx - operators / Single . doOnSubscribe . png alt = > < / p > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final Single < T > doOnSubscribe ( final Consumer < ? super Disposable > onSubscribe ) { ObjectHelper . requireNonNull ( onSubscribe , "onSubscribe is null" ) ; return RxJavaPlugins . onAssembly ( new SingleDoOnSubscribe < T > ( this , onSubscribe ) ) ; }


Input: Returns a Single instance that calls the given onTerminate callback just before this Single completes normally or with an exception . <p > <img width = 640 height = 305 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / doOnTerminate . png alt = > <p > This differs from { [CODESPLIT] @ Experimental @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final Single < T > doOnTerminate ( final Action onTerminate ) { ObjectHelper . requireNonNull ( onTerminate , "onTerminate is null" ) ; return RxJavaPlugins . onAssembly ( new SingleDoOnTerminate < T > ( this , onTerminate ) ) ; }


Input: Calls the shared consumer with the success value sent via onSuccess for each SingleObserver that subscribes to the current Single . <p > <img width = 640 height = 347 src = https : // raw . githubusercontent . com / wiki / ReactiveX / RxJava / images / rx - operators / Single . doOnSuccess . 2 . png alt = > < / p > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final Single < T > doOnSuccess ( final Consumer < ? super T > onSuccess ) { ObjectHelper . requireNonNull ( onSuccess , "onSuccess is null" ) ; return RxJavaPlugins . onAssembly ( new SingleDoOnSuccess < T > ( this , onSuccess ) ) ; }


Input: Calls the shared consumer with the error sent via onError for each SingleObserver that subscribes to the current Single . <p > <img width = 640 height = 349 src = https : // raw . githubusercontent . com / wiki / ReactiveX / RxJava / images / rx - operators / Single . doOnError . 2 . png alt = > < / p > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final Single < T > doOnError ( final Consumer < ? super Throwable > onError ) { ObjectHelper . requireNonNull ( onError , "onError is null" ) ; return RxJavaPlugins . onAssembly ( new SingleDoOnError < T > ( this , onError ) ) ; }


Input: Calls the shared { [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final Single < T > doOnDispose ( final Action onDispose ) { ObjectHelper . requireNonNull ( onDispose , "onDispose is null" ) ; return RxJavaPlugins . onAssembly ( new SingleDoOnDispose < T > ( this , onDispose ) ) ; }


Input: Returns a Single that is based on applying a specified function to the item emitted by the source Single where that function returns a SingleSource . <p > <img width = 640 height = 300 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Single . flatMap . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code flatMap } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final < R > Single < R > flatMap ( Function < ? super T , ? extends SingleSource < ? extends R > > mapper ) { ObjectHelper . requireNonNull ( mapper , "mapper is null" ) ; return RxJavaPlugins . onAssembly ( new SingleFlatMap < T , R > ( this , mapper ) ) ; }


Input: Returns a Maybe that is based on applying a specified function to the item emitted by the source Single where that function returns a MaybeSource . <p > <img width = 640 height = 191 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Single . flatMapMaybe . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code flatMapMaybe } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final < R > Maybe < R > flatMapMaybe ( final Function < ? super T , ? extends MaybeSource < ? extends R > > mapper ) { ObjectHelper . requireNonNull ( mapper , "mapper is null" ) ; return RxJavaPlugins . onAssembly ( new SingleFlatMapMaybe < T , R > ( this , mapper ) ) ; }


Input: Returns an Observable that is based on applying a specified function to the item emitted by the source Single where that function returns an ObservableSource . <p > <img width = 640 height = 300 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Single . flatMapObservable . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code flatMapObservable } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final < R > Observable < R > flatMapObservable ( Function < ? super T , ? extends ObservableSource < ? extends R > > mapper ) { ObjectHelper . requireNonNull ( mapper , "mapper is null" ) ; return RxJavaPlugins . onAssembly ( new SingleFlatMapObservable < T , R > ( this , mapper ) ) ; }


Input: <strong > This method requires advanced knowledge about building operators please consider other standard composition methods first ; < / strong > Returns a { @code Single } which when subscribed to invokes the { @link SingleOperator#apply ( SingleObserver ) apply ( SingleObserver ) } method of the provided { @link SingleOperator } for each individual downstream { @link Single } and allows the insertion of a custom operator by accessing the downstream s { @link SingleObserver } during this subscription phase and providing a new { @code SingleObserver } containing the custom operator s intended business logic that will be used in the subscription process going further upstream . <p > Generally such a new { @code SingleObserver } will wrap the downstream s { @code SingleObserver } and forwards the { @code onSuccess } and { @code onError } events from the upstream directly or according to the emission pattern the custom operator s business logic requires . In addition such operator can intercept the flow control calls of { @code dispose } and { @code isDisposed } that would have traveled upstream and perform additional actions depending on the same business logic requirements . <p > Example : <pre > <code > // Step 1 : Create the consumer type that will be returned by the SingleOperator . apply () : [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final < R > Single < R > lift ( final SingleOperator < ? extends R , ? super T > lift ) { ObjectHelper . requireNonNull ( lift , "lift is null" ) ; return RxJavaPlugins . onAssembly ( new SingleLift < T , R > ( this , lift ) ) ; }


Input: Returns a Single that applies a specified function to the item emitted by the source Single and emits the result of this function application . <p > <img width = 640 height = 305 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Single . map . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code map } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final < R > Single < R > map ( Function < ? super T , ? extends R > mapper ) { ObjectHelper . requireNonNull ( mapper , "mapper is null" ) ; return RxJavaPlugins . onAssembly ( new SingleMap < T , R > ( this , mapper ) ) ; }


Input: Maps the signal types of this Single into a { [CODESPLIT] @ Experimental @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Single < Notification < T > > materialize ( ) { return RxJavaPlugins . onAssembly ( new SingleMaterialize < T > ( this ) ) ; }


Input: Signals true if the current Single signals a success value that is Object - equals with the value provided . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Single < Boolean > contains ( Object value ) { return contains ( value , ObjectHelper . equalsPredicate ( ) ) ; }


Input: Flattens this and another Single into a single Flowable without any transformation . <p > <img width = 640 height = 415 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Single . mergeWith . png alt = > <p > You can combine items emitted by multiple Singles so that they appear as a single Flowable by using the { @code mergeWith } method . <dl > <dt > <b > Backpressure : < / b > < / dt > <dd > The returned { @code Flowable } honors the backpressure of the downstream consumer . < / dd > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code mergeWith } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ BackpressureSupport ( BackpressureKind . FULL ) @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Flowable < T > mergeWith ( SingleSource < ? extends T > other ) { return merge ( this , other ) ; }


Input: Modifies a Single to emit its item ( or notify of its error ) on a specified { @link Scheduler } asynchronously . <p > <img width = 640 height = 305 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Single . observeOn . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > you specify which { @link Scheduler } this operator will use . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . CUSTOM ) public final Single < T > observeOn ( final Scheduler scheduler ) { ObjectHelper . requireNonNull ( scheduler , "scheduler is null" ) ; return RxJavaPlugins . onAssembly ( new SingleObserveOn < T > ( this , scheduler ) ) ; }


Input: Instructs a Single to emit an item ( returned by a specified function ) rather than invoking { @link SingleObserver#onError onError } if it encounters an error . <p > <img width = 640 height = 451 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Single . onErrorReturn . png alt = > <p > By default when a Single encounters an error that prevents it from emitting the expected item to its subscriber the Single invokes its subscriber s { @link SingleObserver#onError } method and then quits without invoking any more of its subscriber s methods . The { @code onErrorReturn } method changes this behavior . If you pass a function ( { @code resumeFunction } ) to a Single s { @code onErrorReturn } method if the original Single encounters an error instead of invoking its subscriber s { @link SingleObserver#onError } method it will instead emit the return value of { @code resumeFunction } . <p > 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 > [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final Single < T > onErrorReturn ( final Function < Throwable , ? extends T > resumeFunction ) { ObjectHelper . requireNonNull ( resumeFunction , "resumeFunction is null" ) ; return RxJavaPlugins . onAssembly ( new SingleOnErrorReturn < T > ( this , resumeFunction , null ) ) ; }


Input: Nulls out references to the upstream producer and downstream SingleObserver if the sequence is terminated or downstream calls dispose () . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Single < T > onTerminateDetach ( ) { return RxJavaPlugins . onAssembly ( new SingleDetach < T > ( this ) ) ; }


Input: Repeatedly re - subscribes to the current Single and emits each success value . <p > <img width = 640 height = 457 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Single . repeat . png alt = > <dl > <dt > <b > Backpressure : < / b > < / dt > <dd > The returned { [CODESPLIT] @ BackpressureSupport ( BackpressureKind . FULL ) @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Flowable < T > repeat ( ) { return toFlowable ( ) . repeat ( ) ; }


Input: Repeatedly re - subscribes to the current Single indefinitely if it fails with an onError . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Single < T > retry ( ) { return toSingle ( toFlowable ( ) . retry ( ) ) ; }


Input: Re - subscribe to the current Single if the given predicate returns true when the Single fails with an onError . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Single < T > retry ( BiPredicate < ? super Integer , ? super Throwable > predicate ) { return toSingle ( toFlowable ( ) . retry ( predicate ) ) ; }


Input: Repeatedly re - subscribe at most times or until the predicate returns false whichever happens first if it fails with an onError . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Single < T > retry ( long times , Predicate < ? super Throwable > predicate ) { return toSingle ( toFlowable ( ) . retry ( times , predicate ) ) ; }


Input: Re - subscribes to the current Single if and when the Publisher returned by the handler function signals a value . <p > If the Publisher signals an onComplete the resulting Single will signal a NoSuchElementException . <p > Note that the inner { @code Publisher } 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 Publisher } signals { @code onError } or { @code onComplete } while the upstream is active the sequence is terminated with the same signal immediately . <p > The following example demonstrates how to retry an asynchronous source with a delay : <pre > <code > Single . 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 Flowable . timer ( counter . get () TimeUnit . SECONDS ) ; } ) ; } ) . blockingGet () ; < / code > < / pre > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code retryWhen } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Single < T > retryWhen ( Function < ? super Flowable < Throwable > , ? extends Publisher < ? > > handler ) { return toSingle ( toFlowable ( ) . retryWhen ( handler ) ) ; }


Input: Subscribes to a Single and provides a callback to handle the item it emits . <p > If the Single 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 > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Disposable subscribe ( Consumer < ? super T > onSuccess ) { return subscribe ( onSuccess , Functions . ON_ERROR_MISSING ) ; }


Input: Subscribes to a Single and provides callbacks to handle the item it emits or 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 > [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final Disposable subscribe ( final Consumer < ? super T > onSuccess , final Consumer < ? super Throwable > onError ) { ObjectHelper . requireNonNull ( onSuccess , "onSuccess is null" ) ; ObjectHelper . requireNonNull ( onError , "onError is null" ) ; ConsumerSingleObserver < T > observer = new ConsumerSingleObserver < T > ( onSuccess , onError ) ; subscribe ( observer ) ; return observer ; }


Input: Subscribes a given SingleObserver ( subclass ) to this Single and returns the given SingleObserver as is . <p > Usage example : <pre > <code > Single&lt ; Integer&gt ; source = Single . just ( 1 ) ; CompositeDisposable composite = new CompositeDisposable () ; [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < E extends SingleObserver < ? super T > > E subscribeWith ( E observer ) { subscribe ( observer ) ; return observer ; }


Input: Asynchronously subscribes subscribers to this Single on the specified { @link Scheduler } . <p > <img width = 640 height = 305 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Single . subscribeOn . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > You specify which { @link Scheduler } this operator will use . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . CUSTOM ) public final Single < T > subscribeOn ( final Scheduler scheduler ) { ObjectHelper . requireNonNull ( scheduler , "scheduler is null" ) ; return RxJavaPlugins . onAssembly ( new SingleSubscribeOn < T > ( this , scheduler ) ) ; }


Input: Returns a Single that emits the item emitted by the source Single until a Completable terminates . Upon termination of { @code other } this will emit a { @link CancellationException } rather than go to { @link SingleObserver#onSuccess ( Object ) } . <p > <img width = 640 height = 380 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / takeUntil . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code takeUntil } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . NONE ) public final Single < T > takeUntil ( final CompletableSource other ) { ObjectHelper . requireNonNull ( other , "other is null" ) ; return takeUntil ( new CompletableToFlowable < T > ( other ) ) ; }


Input: Signals a TimeoutException if the current Single doesn t signal a success value within the specified timeout window . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . COMPUTATION ) public final Single < T > timeout ( long timeout , TimeUnit unit ) { return timeout0 ( timeout , unit , Schedulers . computation ( ) , null ) ; }


Input: Signals a TimeoutException if the current Single doesn t signal a success value within the specified timeout window . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . CUSTOM ) public final Single < T > timeout ( long timeout , TimeUnit unit , Scheduler scheduler ) { return timeout0 ( timeout , unit , scheduler , null ) ; }


Input: Returns a { @link Completable } that discards result of the { @link Single } and calls { @code onComplete } when this source { @link Single } calls { @code onSuccess } . Error terminal event is propagated . <p > <img width = 640 height = 436 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Single . toCompletable . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code toCompletable } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) @ Deprecated public final Completable toCompletable ( ) { return RxJavaPlugins . onAssembly ( new CompletableFromSingle < T > ( this ) ) ; }


Input: Returns a { @link Future } representing the single value emitted by this { @code Single } . <p > <img width = 640 height = 467 src = https : // github . com / ReactiveX / RxJava / wiki / images / rx - operators / Single . toFuture . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code toFuture } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final Future < T > toFuture ( ) { return subscribeWith ( new FutureSingleObserver < T > ( ) ) ; }


Input: Returns a Single which makes sure when a SingleObserver disposes the Disposable that call is propagated up on the specified scheduler . <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { [CODESPLIT] @ CheckReturnValue @ NonNull @ SchedulerSupport ( SchedulerSupport . CUSTOM ) public final Single < T > unsubscribeOn ( final Scheduler scheduler ) { ObjectHelper . requireNonNull ( scheduler , "scheduler is null" ) ; return RxJavaPlugins . onAssembly ( new SingleUnsubscribeOn < T > ( this , scheduler ) ) ; }


Input: Returns a Single that emits the result of applying a specified function to the pair of items emitted by the source Single and another specified Single . <p > <img width = 640 height = 380 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Single . zip . png alt = > <dl > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code zipWith } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ SchedulerSupport ( SchedulerSupport . NONE ) public final < U , R > Single < R > zipWith ( SingleSource < U > other , BiFunction < ? super T , ? super U , ? extends R > zipper ) { return zip ( this , other , zipper ) ; }


Input: Constructs a fresh instance with the default Flowable . bufferSize () prefetch amount and no refCount - behavior . [CODESPLIT] @ CheckReturnValue @ NonNull public static < T > MulticastProcessor < T > create ( ) { return new MulticastProcessor < T > ( bufferSize ( ) , false ) ; }


Input: Constructs a fresh instance with the default Flowable . bufferSize () prefetch amount and the optional refCount - behavior . [CODESPLIT] @ CheckReturnValue @ NonNull public static < T > MulticastProcessor < T > create ( boolean refCount ) { return new MulticastProcessor < T > ( bufferSize ( ) , refCount ) ; }


Input: Initializes this Processor by setting an upstream Subscription that ignores request amounts uses a fixed buffer and allows using the onXXX and offer methods afterwards . [CODESPLIT] public void start ( ) { if ( SubscriptionHelper . setOnce ( upstream , EmptySubscription . INSTANCE ) ) { queue = new SpscArrayQueue < T > ( bufferSize ) ; } }


Input: Initializes this Processor by setting an upstream Subscription that ignores request amounts uses an unbounded buffer and allows using the onXXX and offer methods afterwards . [CODESPLIT] public void startUnbounded ( ) { if ( SubscriptionHelper . setOnce ( upstream , EmptySubscription . INSTANCE ) ) { queue = new SpscLinkedArrayQueue < T > ( bufferSize ) ; } }


Input: Tries to offer an item into the internal queue and returns false if the queue is full . [CODESPLIT] public boolean offer ( T t ) { if ( once . get ( ) ) { return false ; } ObjectHelper . requireNonNull ( t , "offer called with null. Null values are generally not allowed in 2.x operators and sources." ) ; if ( fusionMode == QueueSubscription . NONE ) { if ( queue . offer ( t ) ) { drain ( ) ; return true ; } } return false ; }


Input: { [CODESPLIT] @ Override public boolean offer ( final T e ) { if ( null == e ) { throw new NullPointerException ( "Null is not a valid element" ) ; } // local load of field to avoid repeated loads after volatile reads final AtomicReferenceArray < Object > buffer = producerBuffer ; final long index = lpProducerIndex ( ) ; final int mask = producerMask ; final int offset = calcWrappedOffset ( index , mask ) ; if ( index < producerLookAhead ) { return writeToQueue ( buffer , e , index , offset ) ; } else { final int lookAheadStep = producerLookAheadStep ; // go around the buffer or resize if full (unless we hit max capacity) int lookAheadElementOffset = calcWrappedOffset ( index + lookAheadStep , mask ) ; if ( null == lvElement ( buffer , lookAheadElementOffset ) ) { // LoadLoad producerLookAhead = index + lookAheadStep - 1 ; // joy, there's plenty of room return writeToQueue ( buffer , e , index , offset ) ; } else if ( null == lvElement ( buffer , calcWrappedOffset ( index + 1 , mask ) ) ) { // buffer is not full return writeToQueue ( buffer , e , index , offset ) ; } else { resize ( buffer , index , offset , e , mask ) ; // add a buffer and link old to new return true ; } } }


Input: { [CODESPLIT] @ Nullable @ SuppressWarnings ( "unchecked" ) @ Override public T poll ( ) { // local load of field to avoid repeated loads after volatile reads final AtomicReferenceArray < Object > buffer = consumerBuffer ; final long index = lpConsumerIndex ( ) ; final int mask = consumerMask ; final int offset = calcWrappedOffset ( index , mask ) ; final Object e = lvElement ( buffer , offset ) ; // LoadLoad boolean isNextBuffer = e == HAS_NEXT ; if ( null != e && ! isNextBuffer ) { soElement ( buffer , offset , null ) ; // StoreStore soConsumerIndex ( index + 1 ) ; // this ensures correctness on 32bit platforms return ( T ) e ; } else if ( isNextBuffer ) { return newBufferPoll ( lvNextBufferAndUnlink ( buffer , mask + 1 ) , index , mask ) ; } return null ; }


Input: Offer two elements at the same time . <p > Don t use the regular offer () with this at all! [CODESPLIT] @ Override public boolean offer ( T first , T second ) { final AtomicReferenceArray < Object > buffer = producerBuffer ; final long p = lvProducerIndex ( ) ; final int m = producerMask ; int pi = calcWrappedOffset ( p + 2 , m ) ; if ( null == lvElement ( buffer , pi ) ) { pi = calcWrappedOffset ( p , m ) ; soElement ( buffer , pi + 1 , second ) ; soElement ( buffer , pi , first ) ; soProducerIndex ( p + 2 ) ; } else { final int capacity = buffer . length ( ) ; final AtomicReferenceArray < Object > newBuffer = new AtomicReferenceArray < Object > ( capacity ) ; producerBuffer = newBuffer ; pi = calcWrappedOffset ( p , m ) ; soElement ( newBuffer , pi + 1 , second ) ; // StoreStore soElement ( newBuffer , pi , first ) ; soNext ( buffer , newBuffer ) ; soElement ( buffer , pi , HAS_NEXT ) ; // new buffer is visible after element is soProducerIndex ( p + 2 ) ; // this ensures correctness on 32bit platforms } return true ; }


Input: Returns the currently contained Disposable or null if this container is empty . [CODESPLIT] @ Nullable public Disposable get ( ) { Disposable d = resource . get ( ) ; if ( d == DisposableHelper . DISPOSED ) { return Disposables . disposed ( ) ; } return d ; }


Input: Creates a OperatorPublish instance to publish values of the given source observable . [CODESPLIT] public static < T > ConnectableObservable < T > create ( ObservableSource < T > source ) { // the current connection to source needs to be shared between the operator and its onSubscribe call final AtomicReference < PublishObserver < T > > curr = new AtomicReference < PublishObserver < T > > ( ) ; ObservableSource < T > onSubscribe = new PublishSource < T > ( curr ) ; return RxJavaPlugins . onAssembly ( new ObservablePublish < T > ( onSubscribe , source , curr ) ) ; }


Input: Complete the target with a single value or indicate there is a value available in fusion mode . [CODESPLIT] public final void complete ( T value ) { int state = get ( ) ; if ( ( state & ( FUSED_READY | FUSED_CONSUMED | TERMINATED | DISPOSED ) ) != 0 ) { return ; } Observer < ? super T > a = downstream ; if ( state == FUSED_EMPTY ) { this . value = value ; lazySet ( FUSED_READY ) ; a . onNext ( null ) ; } else { lazySet ( TERMINATED ) ; a . onNext ( value ) ; } if ( get ( ) != DISPOSED ) { a . onComplete ( ) ; } }


Input: Complete the target with an error signal . [CODESPLIT] public final void error ( Throwable t ) { int state = get ( ) ; if ( ( state & ( FUSED_READY | FUSED_CONSUMED | TERMINATED | DISPOSED ) ) != 0 ) { RxJavaPlugins . onError ( t ) ; return ; } lazySet ( TERMINATED ) ; downstream . onError ( t ) ; }


Input: Complete the target without any value . [CODESPLIT] public final void complete ( ) { int state = get ( ) ; if ( ( state & ( FUSED_READY | FUSED_CONSUMED | TERMINATED | DISPOSED ) ) != 0 ) { return ; } lazySet ( TERMINATED ) ; downstream . onComplete ( ) ; }


Input: Returns a Flowable that emits the items emitted by each of the Publishers emitted by the source Publisher one after the other without interleaving them . <p > <img width = 640 height = 380 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / concat . png alt = > <dl > <dt > <b > Backpressure : < / b > < / dt > <dd > The operator honors backpressure from downstream . Both the outer and inner { @code Publisher } sources are expected to honor backpressure as well . If the outer violates this a { @code MissingBackpressureException } is signaled . If any of the inner { @code Publisher } s violates this it <em > may< / em > throw an { @code IllegalStateException } when an inner { @code Publisher } completes . < / dd > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code concat } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ SuppressWarnings ( { "unchecked" , "rawtypes" } ) @ CheckReturnValue @ BackpressureSupport ( BackpressureKind . FULL ) @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Flowable < T > concat ( Publisher < ? extends Publisher < ? extends T > > sources , int prefetch ) { return fromPublisher ( sources ) . concatMap ( ( Function ) Functions . identity ( ) , prefetch ) ; }


Input: Concatenates a variable number of Publisher sources . <p > Note : named this way because of overload conflict with concat ( Publisher&lt ; Publisher&gt ; ) . <p > <img width = 640 height = 380 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / concat . png alt = > <dl > <dt > <b > Backpressure : < / b > < / dt > <dd > The operator honors backpressure from downstream . The { [CODESPLIT] @ CheckReturnValue @ BackpressureSupport ( BackpressureKind . FULL ) @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Flowable < T > concatArray ( Publisher < ? extends T > ... sources ) { if ( sources . length == 0 ) { return empty ( ) ; } else if ( sources . length == 1 ) { return fromPublisher ( sources [ 0 ] ) ; } return RxJavaPlugins . onAssembly ( new FlowableConcatArray < T > ( sources , false ) ) ; }


Input: Concatenates an array of Publishers eagerly into a single stream of values . <p > <img width = 640 height = 406 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / Flowable . concatArrayEager . nn . png alt = > <p > Eager concatenation means that once a subscriber subscribes this operator subscribes to all of the source Publishers . The operator buffers the values emitted by these Publishers and then drains them in order each one after the previous one completes . <dl > <dt > <b > Backpressure : < / b > < / dt > <dd > The operator honors backpressure from downstream . The { [CODESPLIT] @ CheckReturnValue @ NonNull @ BackpressureSupport ( BackpressureKind . FULL ) @ SchedulerSupport ( SchedulerSupport . NONE ) @ SuppressWarnings ( { "rawtypes" , "unchecked" } ) public static < T > Flowable < T > concatArrayEager ( int maxConcurrency , int prefetch , Publisher < ? extends T > ... sources ) { ObjectHelper . requireNonNull ( sources , "sources is null" ) ; ObjectHelper . verifyPositive ( maxConcurrency , "maxConcurrency" ) ; ObjectHelper . verifyPositive ( prefetch , "prefetch" ) ; return RxJavaPlugins . onAssembly ( new FlowableConcatMapEager ( new FlowableFromArray ( sources ) , Functions . identity ( ) , maxConcurrency , prefetch , ErrorMode . IMMEDIATE ) ) ; }


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


Input: Concatenates the Publisher sequence of Publishers into a single sequence by subscribing to each inner Publisher one after the other one at a time and delays any errors till the all inner and the outer Publishers terminate . [CODESPLIT] @ CheckReturnValue @ BackpressureSupport ( BackpressureKind . FULL ) @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Flowable < T > concatDelayError ( Publisher < ? extends Publisher < ? extends T > > sources ) { return concatDelayError ( sources , bufferSize ( ) , true ) ; }


Input: Concatenates the Publisher sequence of Publishers into a single sequence by subscribing to each inner Publisher one after the other one at a time and delays any errors till the all inner and the outer Publishers terminate . [CODESPLIT] @ SuppressWarnings ( { "unchecked" , "rawtypes" } ) @ CheckReturnValue @ BackpressureSupport ( BackpressureKind . FULL ) @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Flowable < T > concatDelayError ( Publisher < ? extends Publisher < ? extends T > > sources , int prefetch , boolean tillTheEnd ) { return fromPublisher ( sources ) . concatMapDelayError ( ( Function ) Functions . identity ( ) , prefetch , tillTheEnd ) ; }


Input: Provides an API ( via a cold Flowable ) that bridges the reactive world with the callback - style generally non - backpressured world . <p > Example : <pre > <code > Flowable . &lt ; Event&gt ; create ( emitter - &gt ; { Callback listener = new Callback () { &#64 ; Override public void onEvent ( Event e ) { emitter . onNext ( e ) ; if ( e . isLast () ) { emitter . onComplete () ; } } [CODESPLIT] @ CheckReturnValue @ NonNull @ BackpressureSupport ( BackpressureKind . SPECIAL ) @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Flowable < T > create ( FlowableOnSubscribe < T > source , BackpressureStrategy mode ) { ObjectHelper . requireNonNull ( source , "source is null" ) ; ObjectHelper . requireNonNull ( mode , "mode is null" ) ; return RxJavaPlugins . onAssembly ( new FlowableCreate < T > ( source , mode ) ) ; }


Input: Returns a Flowable that emits no items to the { @link Subscriber } and immediately invokes its { @link Subscriber#onComplete onComplete } method . <p > <img width = 640 height = 190 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / empty . png alt = > <dl > <dt > <b > Backpressure : < / b > < / dt > <dd > This source doesn t produce any elements and effectively ignores downstream backpressure . < / dd > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code empty } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ BackpressureSupport ( BackpressureKind . PASS_THROUGH ) @ SchedulerSupport ( SchedulerSupport . NONE ) @ SuppressWarnings ( "unchecked" ) public static < T > Flowable < T > empty ( ) { return RxJavaPlugins . onAssembly ( ( Flowable < T > ) FlowableEmpty . INSTANCE ) ; }


Input: Returns a Flowable that invokes a { @link Subscriber } s { @link Subscriber#onError onError } method when the Subscriber subscribes to it . <p > <img width = 640 height = 190 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / error . png alt = > <dl > <dt > <b > Backpressure : < / b > < / dt > <dd > This source doesn t produce any elements and effectively ignores downstream backpressure . < / dd > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code error } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ NonNull @ BackpressureSupport ( BackpressureKind . PASS_THROUGH ) @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Flowable < T > error ( Callable < ? extends Throwable > supplier ) { ObjectHelper . requireNonNull ( supplier , "supplier is null" ) ; return RxJavaPlugins . onAssembly ( new FlowableError < T > ( supplier ) ) ; }


Input: Converts an { @link Iterable } sequence into a Publisher that emits the items in the sequence . <p > <img width = 640 height = 315 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / from . png alt = > <dl > <dt > <b > Backpressure : < / b > < / dt > <dd > The operator honors backpressure from downstream and iterates the given { @code iterable } on demand ( i . e . when requested ) . < / dd > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code fromIterable } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ NonNull @ BackpressureSupport ( BackpressureKind . FULL ) @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Flowable < T > fromIterable ( Iterable < ? extends T > source ) { ObjectHelper . requireNonNull ( source , "source is null" ) ; return RxJavaPlugins . onAssembly ( new FlowableFromIterable < T > ( source ) ) ; }


Input: Returns a cold synchronous stateful and backpressure - aware generator of values . <p > Note that the { @link Emitter#onNext } { @link Emitter#onError } and { @link Emitter#onComplete } methods provided to the function via the { @link Emitter } instance should be called synchronously never concurrently and only while the function body is executing . Calling them from multiple threads or outside the function call is not supported and leads to an undefined behavior . <dl > <dt > <b > Backpressure : < / b > < / dt > <dd > The operator honors downstream backpressure . < / dd > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code generate } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ BackpressureSupport ( BackpressureKind . FULL ) @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T , S > Flowable < T > generate ( Callable < S > initialState , BiFunction < S , Emitter < T > , S > generator ) { return generate ( initialState , generator , Functions . emptyConsumer ( ) ) ; }


Input: Returns a Flowable that emits a { @code 0L } after the { @code initialDelay } and ever - increasing numbers after each { @code period } of time thereafter on a specified { @link Scheduler } . <p > <img width = 640 height = 200 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / timer . ps . png alt = > <dl > <dt > <b > Backpressure : < / b > < / dt > <dd > The operator generates values based on time and ignores downstream backpressure which may lead to { @code MissingBackpressureException } at some point in the chain . Consumers should consider applying one of the { @code onBackpressureXXX } operators as well . < / dd > <dt > <b > Scheduler : < / b > < / dt > <dd > You specify which { @link Scheduler } this operator will use . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ NonNull @ BackpressureSupport ( BackpressureKind . ERROR ) @ SchedulerSupport ( SchedulerSupport . CUSTOM ) public static Flowable < Long > interval ( long initialDelay , long period , TimeUnit unit , Scheduler scheduler ) { ObjectHelper . requireNonNull ( unit , "unit is null" ) ; ObjectHelper . requireNonNull ( scheduler , "scheduler is null" ) ; return RxJavaPlugins . onAssembly ( new FlowableInterval ( Math . max ( 0L , initialDelay ) , Math . max ( 0L , period ) , unit , scheduler ) ) ; }


Input: Returns a Flowable that emits a sequential number every specified interval of time . <p > <img width = 640 height = 195 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / interval . png alt = > <dl > <dt > <b > Backpressure : < / b > < / dt > <dd > The operator signals a { @code MissingBackpressureException } if the downstream is not ready to receive the next value . < / dd > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code interval } operates by default on the { @code computation } { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ BackpressureSupport ( BackpressureKind . ERROR ) @ SchedulerSupport ( SchedulerSupport . COMPUTATION ) public static Flowable < Long > interval ( long period , TimeUnit unit ) { return interval ( period , period , unit , Schedulers . computation ( ) ) ; }


Input: Returns a Flowable that emits a sequential number every specified interval of time on a specified Scheduler . <p > <img width = 640 height = 200 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / interval . s . png alt = > <dl > <dt > <b > Backpressure : < / b > < / dt > <dd > The operator generates values based on time and ignores downstream backpressure which may lead to { @code MissingBackpressureException } at some point in the chain . Consumers should consider applying one of the { @code onBackpressureXXX } operators as well . < / dd > <dt > <b > Scheduler : < / b > < / dt > <dd > You specify which { @link Scheduler } this operator will use . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ BackpressureSupport ( BackpressureKind . ERROR ) @ SchedulerSupport ( SchedulerSupport . CUSTOM ) public static Flowable < Long > interval ( long period , TimeUnit unit , Scheduler scheduler ) { return interval ( period , period , unit , scheduler ) ; }


Input: Signals a range of long values the first after some initial delay and the rest periodically after . <p > The sequence completes immediately after the last value ( start + count - 1 ) has been reached . <dl > <dt > <b > Backpressure : < / b > < / dt > <dd > The operator signals a { [CODESPLIT] @ CheckReturnValue @ BackpressureSupport ( BackpressureKind . ERROR ) @ SchedulerSupport ( SchedulerSupport . COMPUTATION ) public static Flowable < Long > intervalRange ( long start , long count , long initialDelay , long period , TimeUnit unit ) { return intervalRange ( start , count , initialDelay , period , unit , Schedulers . computation ( ) ) ; }


Input: Signals a range of long values the first after some initial delay and the rest periodically after . <p > The sequence completes immediately after the last value ( start + count - 1 ) has been reached . <dl > <dt > <b > Backpressure : < / b > < / dt > <dd > The operator signals a { [CODESPLIT] @ CheckReturnValue @ NonNull @ BackpressureSupport ( BackpressureKind . ERROR ) @ SchedulerSupport ( SchedulerSupport . CUSTOM ) public static Flowable < Long > intervalRange ( long start , long count , long initialDelay , long period , TimeUnit unit , Scheduler scheduler ) { if ( count < 0L ) { throw new IllegalArgumentException ( "count >= 0 required but it was " + count ) ; } if ( count == 0L ) { return Flowable . < Long > empty ( ) . delay ( initialDelay , unit , scheduler ) ; } long end = start + ( count - 1 ) ; if ( start > 0 && end < 0 ) { throw new IllegalArgumentException ( "Overflow! start + count is bigger than Long.MAX_VALUE" ) ; } ObjectHelper . requireNonNull ( unit , "unit is null" ) ; ObjectHelper . requireNonNull ( scheduler , "scheduler is null" ) ; return RxJavaPlugins . onAssembly ( new FlowableIntervalRange ( start , end , Math . max ( 0L , initialDelay ) , Math . max ( 0L , period ) , unit , scheduler ) ) ; }


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


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


Input: Flattens four Publishers into a single Publisher without any transformation . <p > <img width = 640 height = 380 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / merge . png alt = > <p > You can combine items emitted by multiple Publishers so that they appear as a single Publisher by using the { @code merge } method . <dl > <dt > <b > Backpressure : < / b > < / dt > <dd > The operator honors backpressure from downstream . The source { @code Publisher } s are expected to honor backpressure ; if violated the operator <em > may< / em > signal { @code MissingBackpressureException } . < / dd > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code merge } does not operate by default on a particular { @link Scheduler } . < / dd > <dt > <b > Error handling : < / b > < / dt > <dd > If any of the source { @code Publisher } s signal a { @code Throwable } via { @code onError } the resulting { @code Flowable } terminates with that { @code Throwable } and all other source { @code Publisher } s are canceled . If more than one { @code Publisher } signals an error the resulting { @code Flowable } may terminate with the first one s error or depending on the concurrency of the sources may terminate with a { @code CompositeException } containing two or more of the various error signals . { @code Throwable } s that didn t make into the composite will be sent ( individually ) to the global error handler via { @link RxJavaPlugins#onError ( Throwable ) } method as { @code UndeliverableException } errors . Similarly { @code Throwable } s signaled by source ( s ) after the returned { @code Flowable } has been canceled or terminated with a ( composite ) error will be sent to the same global error handler . Use { @link #mergeDelayError ( Publisher Publisher Publisher Publisher ) } to merge sources and terminate only when all source { @code Publisher } s have completed or failed with an error . < / dd > < / dl > [CODESPLIT] @ SuppressWarnings ( { "unchecked" , "rawtypes" } ) @ CheckReturnValue @ NonNull @ BackpressureSupport ( BackpressureKind . FULL ) @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Flowable < T > merge ( Publisher < ? extends T > source1 , Publisher < ? extends T > source2 , Publisher < ? extends T > source3 , Publisher < ? extends T > source4 ) { ObjectHelper . requireNonNull ( source1 , "source1 is null" ) ; ObjectHelper . requireNonNull ( source2 , "source2 is null" ) ; ObjectHelper . requireNonNull ( source3 , "source3 is null" ) ; ObjectHelper . requireNonNull ( source4 , "source4 is null" ) ; return fromArray ( source1 , source2 , source3 , source4 ) . flatMap ( ( Function ) Functions . identity ( ) , false , 4 ) ; }


Input: Flattens an Iterable of Publishers into one Publisher in a way that allows a Subscriber to receive all successfully emitted items from each of the source Publishers without being interrupted by an error notification from one of them . <p > This behaves like { @link #merge ( Publisher ) } except that if any of the merged Publishers notify of an error via { @link Subscriber#onError onError } { @code mergeDelayError } will refrain from propagating that error notification until all of the merged Publishers have finished emitting items . <p > <img width = 640 height = 380 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / mergeDelayError . png alt = > <p > Even if multiple merged Publishers send { @code onError } notifications { @code mergeDelayError } will only invoke the { @code onError } method of its Subscribers once . <dl > <dt > <b > Backpressure : < / b > < / dt > <dd > The operator honors backpressure from downstream . All inner { @code Publisher } s are expected to honor backpressure ; if violated the operator <em > may< / em > signal { @code MissingBackpressureException } . < / dd > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code mergeDelayError } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ SuppressWarnings ( { "unchecked" , "rawtypes" } ) @ CheckReturnValue @ BackpressureSupport ( BackpressureKind . FULL ) @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Flowable < T > mergeDelayError ( Iterable < ? extends Publisher < ? extends T > > sources ) { return fromIterable ( sources ) . flatMap ( ( Function ) Functions . identity ( ) , true ) ; }


Input: Returns a Flowable that never sends any items or notifications to a { @link Subscriber } . <p > <img width = 640 height = 185 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / never . png alt = > <p > This Publisher is useful primarily for testing purposes . <dl > <dt > <b > Backpressure : < / b > < / dt > <dd > This source doesn t produce any elements and effectively ignores downstream backpressure . < / dd > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code never } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ BackpressureSupport ( BackpressureKind . PASS_THROUGH ) @ SchedulerSupport ( SchedulerSupport . NONE ) @ SuppressWarnings ( "unchecked" ) public static < T > Flowable < T > never ( ) { return RxJavaPlugins . onAssembly ( ( Flowable < T > ) FlowableNever . INSTANCE ) ; }


Input: Returns a Flowable that emits a sequence of Integers within a specified range . <p > <img width = 640 height = 195 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / range . png alt = > <dl > <dt > <b > Backpressure : < / b > < / dt > <dd > The operator honors backpressure from downstream and signals values on - demand ( i . e . when requested ) . < / dd > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code range } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ BackpressureSupport ( BackpressureKind . FULL ) @ SchedulerSupport ( SchedulerSupport . NONE ) public static Flowable < Integer > range ( int start , int count ) { if ( count < 0 ) { throw new IllegalArgumentException ( "count >= 0 required but it was " + count ) ; } else if ( count == 0 ) { return empty ( ) ; } else if ( count == 1 ) { return just ( start ) ; } else if ( ( long ) start + ( count - 1 ) > Integer . MAX_VALUE ) { throw new IllegalArgumentException ( "Integer overflow" ) ; } return RxJavaPlugins . onAssembly ( new FlowableRange ( start , count ) ) ; }


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


Input: Returns a Single that emits a Boolean value that indicates whether two Publisher sequences are the same by comparing the items emitted by each Publisher pairwise based on the results of a specified equality function . <p > <img width = 640 height = 385 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / sequenceEqual . png alt = > <dl > <dt > <b > Backpressure : < / b > < / dt > <dd > The operator honors backpressure from downstream . The source { @code Publisher } s are expected to honor backpressure ; if violated the operator signals a { @code MissingBackpressureException } . < / dd > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code sequenceEqual } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ BackpressureSupport ( BackpressureKind . FULL ) @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Single < Boolean > sequenceEqual ( Publisher < ? extends T > source1 , Publisher < ? extends T > source2 , BiPredicate < ? super T , ? super T > isEqual ) { return sequenceEqual ( source1 , source2 , isEqual , bufferSize ( ) ) ; }


Input: Returns a Single that emits a Boolean value that indicates whether two Publisher sequences are the same by comparing the items emitted by each Publisher pairwise based on the results of a specified equality function . <p > <img width = 640 height = 385 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / sequenceEqual . png alt = > <dl > <dt > <b > Backpressure : < / b > < / dt > <dd > The operator honors backpressure from downstream . The source { @code Publisher } s are expected to honor backpressure ; if violated the operator signals a { @code MissingBackpressureException } . < / dd > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code sequenceEqual } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ NonNull @ BackpressureSupport ( BackpressureKind . FULL ) @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Single < Boolean > sequenceEqual ( Publisher < ? extends T > source1 , Publisher < ? extends T > source2 , BiPredicate < ? super T , ? super T > isEqual , int bufferSize ) { ObjectHelper . requireNonNull ( source1 , "source1 is null" ) ; ObjectHelper . requireNonNull ( source2 , "source2 is null" ) ; ObjectHelper . requireNonNull ( isEqual , "isEqual is null" ) ; ObjectHelper . verifyPositive ( bufferSize , "bufferSize" ) ; return RxJavaPlugins . onAssembly ( new FlowableSequenceEqualSingle < T > ( source1 , source2 , isEqual , bufferSize ) ) ; }


Input: Returns a Single that emits a Boolean value that indicates whether two Publisher sequences are the same by comparing the items emitted by each Publisher pairwise . <p > <img width = 640 height = 385 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / sequenceEqual . png alt = > <dl > <dt > <b > Backpressure : < / b > < / dt > <dd > This operator honors downstream backpressure and expects both of its sources to honor backpressure as well . If violated the operator will emit a MissingBackpressureException . < / dd > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code sequenceEqual } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ BackpressureSupport ( BackpressureKind . FULL ) @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Single < Boolean > sequenceEqual ( Publisher < ? extends T > source1 , Publisher < ? extends T > source2 , int bufferSize ) { return sequenceEqual ( source1 , source2 , ObjectHelper . equalsPredicate ( ) , bufferSize ) ; }


Input: Converts a Publisher that emits Publishers into a Publisher that emits the items emitted by the most recently emitted of those Publishers . <p > <img width = 640 height = 370 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / switchDo . png alt = > <p > { @code switchOnNext } subscribes to a Publisher that emits Publishers . Each time it observes one of these emitted Publishers the Publisher returned by { @code switchOnNext } begins emitting the items emitted by that Publisher . When a new Publisher is emitted { @code switchOnNext } stops emitting items from the earlier - emitted Publisher and begins emitting items from the new one . <p > The resulting Publisher completes if both the outer Publisher and the last inner Publisher if any complete . If the outer Publisher signals an onError the inner Publisher is canceled and the error delivered in - sequence . <dl > <dt > <b > Backpressure : < / b > < / dt > <dd > The operator honors backpressure from downstream . The outer { @code Publisher } is consumed in an unbounded manner ( i . e . without backpressure ) and the inner { @code Publisher } s are expected to honor backpressure but it is not enforced ; the operator won t signal a { @code MissingBackpressureException } but the violation <em > may< / em > lead to { @code OutOfMemoryError } due to internal buffer bloat . < / dd > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code switchOnNext } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ SuppressWarnings ( { "unchecked" , "rawtypes" } ) @ CheckReturnValue @ BackpressureSupport ( BackpressureKind . FULL ) @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Flowable < T > switchOnNext ( Publisher < ? extends Publisher < ? extends T > > sources , int bufferSize ) { return fromPublisher ( sources ) . switchMap ( ( Function ) Functions . identity ( ) , bufferSize ) ; }


Input: Converts a Publisher that emits Publishers into a Publisher that emits the items emitted by the most recently emitted of those Publishers and delays any exception until all Publishers terminate . <p > <img width = 640 height = 370 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / switchDo . png alt = > <p > { @code switchOnNext } subscribes to a Publisher that emits Publishers . Each time it observes one of these emitted Publishers the Publisher returned by { @code switchOnNext } begins emitting the items emitted by that Publisher . When a new Publisher is emitted { @code switchOnNext } stops emitting items from the earlier - emitted Publisher and begins emitting items from the new one . <p > The resulting Publisher completes if both the main Publisher and the last inner Publisher if any complete . If the main Publisher signals an onError the termination of the last inner Publisher will emit that error as is or wrapped into a CompositeException along with the other possible errors the former inner Publishers signaled . <dl > <dt > <b > Backpressure : < / b > < / dt > <dd > The operator honors backpressure from downstream . The outer { @code Publisher } is consumed in an unbounded manner ( i . e . without backpressure ) and the inner { @code Publisher } s are expected to honor backpressure but it is not enforced ; the operator won t signal a { @code MissingBackpressureException } but the violation <em > may< / em > lead to { @code OutOfMemoryError } due to internal buffer bloat . < / dd > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code switchOnNextDelayError } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ BackpressureSupport ( BackpressureKind . FULL ) @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Flowable < T > switchOnNextDelayError ( Publisher < ? extends Publisher < ? extends T > > sources , int prefetch ) { return fromPublisher ( sources ) . switchMapDelayError ( Functions . < Publisher < ? extends T > > identity ( ) , prefetch ) ; }


Input: Returns a Flowable that emits { @code 0L } after a specified delay and then completes . <p > <img width = 640 height = 200 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / timer . png alt = > <dl > <dt > <b > Backpressure : < / b > < / dt > <dd > This operator does not support backpressure as it uses time . If the downstream needs a slower rate it should slow the timer or use something like { @link #onBackpressureDrop } . < / dd > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code timer } operates by default on the { @code computation } { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ BackpressureSupport ( BackpressureKind . ERROR ) @ SchedulerSupport ( SchedulerSupport . COMPUTATION ) public static Flowable < Long > timer ( long delay , TimeUnit unit ) { return timer ( delay , unit , Schedulers . computation ( ) ) ; }


Input: Create a Flowable by wrapping a Publisher <em > which has to be implemented according to the Reactive - Streams specification by handling backpressure and cancellation correctly ; no safeguards are provided by the Flowable itself< / em > . <dl > <dt > <b > Backpressure : < / b > < / dt > <dd > This operator is a pass - through for backpressure and the behavior is determined by the provided Publisher implementation . < / dd > <dt > <b > Scheduler : < / b > < / dt > <dd > { [CODESPLIT] @ CheckReturnValue @ NonNull @ BackpressureSupport ( BackpressureKind . NONE ) @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T > Flowable < T > unsafeCreate ( Publisher < T > onSubscribe ) { ObjectHelper . requireNonNull ( onSubscribe , "onSubscribe is null" ) ; if ( onSubscribe instanceof Flowable ) { throw new IllegalArgumentException ( "unsafeCreate(Flowable) should be upgraded" ) ; } return RxJavaPlugins . onAssembly ( new FlowableFromPublisher < T > ( onSubscribe ) ) ; }


Input: Constructs a Publisher that creates a dependent resource object which is disposed of on cancellation . <p > <img width = 640 height = 400 src = https : // raw . github . com / wiki / ReactiveX / RxJava / images / rx - operators / using . png alt = > <dl > <dt > <b > Backpressure : < / b > < / dt > <dd > The operator is a pass - through for backpressure and otherwise depends on the backpressure support of the Publisher returned by the { @code resourceFactory } . < / dd > <dt > <b > Scheduler : < / b > < / dt > <dd > { @code using } does not operate by default on a particular { @link Scheduler } . < / dd > < / dl > [CODESPLIT] @ CheckReturnValue @ BackpressureSupport ( BackpressureKind . PASS_THROUGH ) @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T , D > Flowable < T > using ( Callable < ? extends D > resourceSupplier , Function < ? super D , ? extends Publisher < ? extends T > > sourceSupplier , Consumer < ? super D > resourceDisposer ) { return using ( resourceSupplier , sourceSupplier , resourceDisposer , true ) ; }


Input:
Returns a Flowable that emits the results of a specified combiner function applied to combinations of items emitted in sequence by an Iterable of other Publishers .
 { @code zip } applies this function in strict sequence so the first item emitted by the new Publisher will be the result of the function applied to the first item emitted by each of the source Publishers ; the second item emitted by the new Publisher will be the result of the function applied to the second item emitted by each of those Publishers ; and so forth .
 The resulting { @code Publisher<R > } returned from { @code zip } will invoke { @code onNext } as many times as the number of { @code onNext } invocations of the source Publisher that emits the fewest items .
 The operator subscribes to its sources in the order they are specified and completes eagerly if one of the sources is shorter than the rest while canceling the other sources . Therefore it is possible those other sources will never be able to run to completion ( and thus not calling { @code doOnComplete () } ) . This can also happen if the sources are exactly the same length ; if source A completes and B has been consumed and is about to complete the operator detects A won t be sending further values and it will cancel B immediately . For example :
  zip ( Arrays . asList ( range ( 1 5 ) . doOnComplete ( action1 ) range ( 6 5 ) . doOnComplete ( action2 )) ( a ) - &gt ; a )
 { @code action1 } will be called but { @code action2 } won t .
 To work around this termination property use { @link #doOnCancel ( Action ) } as well or use { @code using () } to do cleanup in case of completion or cancellation .

  Backpressure :

 The operator expects backpressure from the sources and honors backpressure from the downstream . ( I . e . zipping with { @link #interval ( long TimeUnit ) } may result in MissingBackpressureException use one of the { @code onBackpressureX } to handle similar backpressure - ignoring sources .

  Scheduler :

 { @code zip } does not operate by default on a particular { @link Scheduler } .

 [CODESPLIT] @ CheckReturnValue @ NonNull @ BackpressureSupport ( BackpressureKind . FULL ) @ SchedulerSupport ( SchedulerSupport . NONE ) public static < T , R > Flowable < R > zip ( Iterable < ? extends Publisher < ? extends T > > sources , Function < ? super Object [ ] , ? extends R > zipper ) { ObjectHelper . requireNonNull ( zipper , "zipper is null" ) ; ObjectHelper . requireNonNull ( sources , "sources is null" ) ; return RxJavaPlugins . onAssembly ( new FlowableZip < T , R > ( null , sources , zipper , bufferSize ( ) , false ) ) ; }