T - the type of the item emitted by the Singlepublic abstract classSingle<T>extendsObjectimplementsSingleSource<T>
Single class implements the Reactive Pattern for a single value response.Single behaves similarly toObservable except that it can only emit either a single successful value or an error (there is no "onComplete" notification as there is for anObservable).
TheSingle class implements theSingleSource base interface and the default consumer type it interacts with is theSingleObserver via thesubscribe(SingleObserver) method.
TheSingle operates with the following sequential protocol:
onSubscribe (onSuccess | onError)? Note thatonSuccess andonError are mutually exclusive events; unlikeObservable,onSuccess is never followed byonError.
LikeObservable, a runningSingle can be stopped through theDisposable instance provided to consumers throughSingleObserver.onSubscribe(io.reactivex.disposables.Disposable).
Like anObservable, aSingle is lazy, can be either "hot" or "cold", synchronous or asynchronous.Single instances returned by the methods of this class arecold and there is a standardhot implementation in the form of a subject:SingleSubject.
The documentation for this class makes use of marble diagrams. The following legend explains these diagrams:

SeeFlowable orObservable for the implementation of the Reactive Pattern for a stream or vector of values.
For more information see theReactiveX documentation.
Example:
Disposable d = Single.just("Hello World") .delay(10, TimeUnit.SECONDS, Schedulers.io()) .subscribeWith(new DisposableSingleObserver<String>() { @Override public void onStart() { System.out.println("Started"); } @Override public void onSuccess(String value) { System.out.println("Success: " + value); } @Override public void onError(Throwable error) { error.printStackTrace(); } }); Thread.sleep(5000); d.dispose(); Note that by design, subscriptions viasubscribe(SingleObserver) can't be disposed from the outside (hence thevoid return of thesubscribe(SingleObserver) method) and it is the responsibility of the implementor of theSingleObserver to allow this to happen. RxJava supports such usage with the standardDisposableSingleObserver instance. For convenience, thesubscribeWith(SingleObserver) method is provided as well to allow working with aSingleObserver (or subclass) instance to be applied with in a fluent manner (such as in the example above).
DisposableSingleObserver| Constructor and Description |
|---|
Single() |
| Modifier and Type | Method and Description |
|---|---|
static <T> Single<T> | amb(Iterable<? extendsSingleSource<? extends T>> sources)Runs multiple SingleSources and signals the events of the first one that signals (disposing the rest). |
static <T> Single<T> | ambArray(SingleSource<? extends T>... sources)Runs multiple SingleSources and signals the events of the first one that signals (disposing the rest). |
Single<T> | ambWith(SingleSource<? extendsT> other)Signals the event of this or the other SingleSource whichever signals first. |
<R> R | as(SingleConverter<T,? extends R> converter)Calls the specified converter function during assembly time and returns its resulting value. |
T | blockingGet()Waits in a blocking fashion until the current Single signals a success value (which is returned) or an exception (which is propagated). |
Single<T> | cache()Stores the success value or exception from the current Single and replays it to late SingleObservers. |
<U> Single<U> | cast(Class<? extends U> clazz)Casts the success value of the current Single into the target type or signals a ClassCastException if not compatible. |
<R> Single<R> | compose(SingleTransformer<? superT,? extends R> transformer)Transform a Single by applying a particular Transformer function to it. |
static <T> Flowable<T> | concat(Iterable<? extendsSingleSource<? extends T>> sources)Concatenate the single values, in a non-overlapping fashion, of the SingleSources provided by an Iterable sequence. |
static <T> Observable<T> | concat(ObservableSource<? extendsSingleSource<? extends T>> sources)Concatenate the single values, in a non-overlapping fashion, of the SingleSources provided by an Observable sequence. |
static <T> Flowable<T> | concat(Publisher<? extendsSingleSource<? extends T>> sources)Concatenate the single values, in a non-overlapping fashion, of the SingleSources provided by a Publisher sequence. |
static <T> Flowable<T> | concat(Publisher<? extendsSingleSource<? extends T>> sources, int prefetch)Concatenate the single values, in a non-overlapping fashion, of the SingleSources provided by a Publisher sequence and prefetched by the specified amount. |
static <T> Flowable<T> | concat(SingleSource<? extends T> source1,SingleSource<? extends T> source2)Returns a Flowable that emits the items emitted by two Singles, one after the other. |
static <T> Flowable<T> | concat(SingleSource<? extends T> source1,SingleSource<? extends T> source2,SingleSource<? extends T> source3)Returns a Flowable that emits the items emitted by three Singles, one after the other. |
static <T> Flowable<T> | concat(SingleSource<? extends T> source1,SingleSource<? extends T> source2,SingleSource<? extends T> source3,SingleSource<? extends T> source4)Returns a Flowable that emits the items emitted by four Singles, one after the other. |
static <T> Flowable<T> | concatArray(SingleSource<? extends T>... sources)Concatenate the single values, in a non-overlapping fashion, of the SingleSources provided in an array. |
static <T> Flowable<T> | concatArrayEager(SingleSource<? extends T>... sources)Concatenates a sequence of SingleSource eagerly into a single stream of values. |
static <T> Flowable<T> | concatEager(Iterable<? extendsSingleSource<? extends T>> sources)Concatenates a sequence of SingleSources eagerly into a single stream of values. |
static <T> Flowable<T> | concatEager(Publisher<? extendsSingleSource<? extends T>> sources)Concatenates a Publisher sequence of SingleSources eagerly into a single stream of values. |
Flowable<T> | concatWith(SingleSource<? extendsT> other)Returns a Flowable that emits the item emitted by the source Single, then the item emitted by the specified Single. |
Single<Boolean> | contains(Object value)Signals true if the current Single signals a success value that is Object-equals with the value provided. |
Single<Boolean> | contains(Object value,BiPredicate<Object,Object> comparer)Signals true if the current Single signals a success value that is equal with the value provided by calling a bi-predicate. |
static <T> Single<T> | create(SingleOnSubscribe<T> source)Provides an API (via a cold Single) that bridges the reactive world with the callback-style world. |
static <T> Single<T> | defer(Callable<? extendsSingleSource<? extends T>> singleSupplier)Calls a Callable for each individualSingleObserver to return the actualSingleSource to be subscribed to. |
Single<T> | delay(long time,TimeUnit unit)Delays the emission of the success signal from the current Single by the specified amount. |
Single<T> | delay(long time,TimeUnit unit, boolean delayError)Delays the emission of the success or error signal from the current Single by the specified amount. |
Single<T> | delay(long time,TimeUnit unit,Scheduler scheduler)Delays the emission of the success signal from the current Single by the specified amount. |
Single<T> | delay(long time,TimeUnit unit,Scheduler scheduler, boolean delayError)Delays the emission of the success or error signal from the current Single by the specified amount. |
Single<T> | delaySubscription(CompletableSource other)Delays the actual subscription to the current Single until the given other CompletableSource completes. |
Single<T> | delaySubscription(long time,TimeUnit unit)Delays the actual subscription to the current Single until the given time delay elapsed. |
Single<T> | delaySubscription(long time,TimeUnit unit,Scheduler scheduler)Delays the actual subscription to the current Single until the given time delay elapsed. |
<U> Single<T> | delaySubscription(ObservableSource<U> other)Delays the actual subscription to the current Single until the given other ObservableSource signals its first value or completes. |
<U> Single<T> | delaySubscription(Publisher<U> other)Delays the actual subscription to the current Single until the given other Publisher signals its first value or completes. |
<U> Single<T> | delaySubscription(SingleSource<U> other)Delays the actual subscription to the current Single until the given other SingleSource signals success. |
<R> Maybe<R> | dematerialize(Function<? superT,Notification<R>> selector)Maps the Notification success value of this Single back into normalonSuccess,onError oronComplete signals as aMaybe source. |
Single<T> | doAfterSuccess(Consumer<? superT> onAfterSuccess)Calls the specified consumer with the success item after this item has been emitted to the downstream. |
Single<T> | doAfterTerminate(Action onAfterTerminate)Registers an Action to be called after this Single invokes either onSuccess or onError. |
Single<T> | doFinally(Action onFinally)Calls the specified action after this Single signals onSuccess or onError or gets disposed by the downstream. |
Single<T> | doOnDispose(Action onDispose)Calls the shared Action if a SingleObserver subscribed to the current Single disposes the common Disposable it received via onSubscribe. |
Single<T> | doOnError(Consumer<? superThrowable> onError)Calls the shared consumer with the error sent via onError for each SingleObserver that subscribes to the current Single. |
Single<T> | doOnEvent(BiConsumer<? superT,? superThrowable> onEvent)Calls the shared consumer with the error sent via onError or the value via onSuccess for each SingleObserver that subscribes to the current Single. |
Single<T> | doOnSubscribe(Consumer<? superDisposable> onSubscribe)Calls the shared consumer with the Disposable sent through the onSubscribe for each SingleObserver that subscribes to the current Single. |
Single<T> | doOnSuccess(Consumer<? superT> onSuccess)Calls the shared consumer with the success value sent via onSuccess for each SingleObserver that subscribes to the current Single. |
Single<T> | doOnTerminate(Action onTerminate)Returns a Single instance that calls the given onTerminate callback just before this Single completes normally or with an exception. |
static <T> Single<Boolean> | equals(SingleSource<? extends T> first,SingleSource<? extends T> second)Compares two SingleSources and emits true if they emit the same value (compared via Object.equals). |
static <T> Single<T> | error(Callable<? extendsThrowable> errorSupplier)Signals a Throwable returned by the callback function for each individual SingleObserver. |
static <T> Single<T> | error(Throwable exception)Returns a Single that invokes a subscriber's onError method when the subscriber subscribes to it. |
Maybe<T> | filter(Predicate<? superT> predicate)Filters the success item of the Single via a predicate function and emitting it if the predicate returns true, completing otherwise. |
<R> Single<R> | flatMap(Function<? superT,? extendsSingleSource<? extends R>> mapper)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. |
Completable | flatMapCompletable(Function<? superT,? extendsCompletableSource> mapper)Returns a Completable that completes based on applying a specified function to the item emitted by the sourceSingle, where that function returns aCompletable. |
<R> Maybe<R> | flatMapMaybe(Function<? superT,? extendsMaybeSource<? extends R>> mapper)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. |
<R> Observable<R> | flatMapObservable(Function<? superT,? extendsObservableSource<? extends R>> mapper)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. |
<R> Flowable<R> | flatMapPublisher(Function<? superT,? extendsPublisher<? extends R>> mapper)Returns a Flowable that emits items based on applying a specified function to the item emitted by the source Single, where that function returns a Publisher. |
<U> Flowable<U> | flattenAsFlowable(Function<? superT,? extendsIterable<? extends U>> mapper) |
<U> Observable<U> | flattenAsObservable(Function<? superT,? extendsIterable<? extends U>> mapper)Maps the success value of the upstream Single into anIterable and emits its items as anObservable sequence. |
static <T> Single<T> | fromCallable(Callable<? extends T> callable)Returns a Single that invokes passed function and emits its result for each new SingleObserver that subscribes. |
static <T> Single<T> | fromFuture(Future<? extends T> future)Converts a Future into aSingle. |
static <T> Single<T> | fromFuture(Future<? extends T> future, long timeout,TimeUnit unit)Converts a Future into aSingle, with a timeout on the Future. |
static <T> Single<T> | fromFuture(Future<? extends T> future, long timeout,TimeUnit unit,Scheduler scheduler)Converts a Future into aSingle, with a timeout on the Future. |
static <T> Single<T> | fromFuture(Future<? extends T> future,Scheduler scheduler) |
static <T> Single<T> | fromObservable(ObservableSource<? extends T> observableSource)Wraps a specific ObservableSource into a Single and signals its single element or error. |
static <T> Single<T> | fromPublisher(Publisher<? extends T> publisher)Wraps a specific Publisher into a Single and signals its single element or error. |
Single<T> | hide()Hides the identity of the current Single, including the Disposable that is sent to the downstream via onSubscribe(). |
Completable | ignoreElement()Returns a Completable that ignores the success value of thisSingle and callsonComplete instead on the returnedCompletable. |
static <T> Single<T> | just(T item)Returns a Single that emits a specified item. |
<R> Single<R> | lift(SingleOperator<? extends R,? superT> lift)This method requires advanced knowledge about building operators, please consider other standard composition methods first; Returns a Single which, when subscribed to, invokes theapply(SingleObserver) method of the providedSingleOperator for each individual downstreamSingle and allows the insertion of a custom operator by accessing the downstream'sSingleObserver during this subscription phase and providing a newSingleObserver, containing the custom operator's intended business logic, that will be used in the subscription process going further upstream. |
<R> Single<R> | map(Function<? superT,? extends R> mapper)Returns a Single that applies a specified function to the item emitted by the source Single and emits the result of this function application. |
Single<Notification<T>> | materialize()Maps the signal types of this Single into a Notification of the same kind and emits it as a single success value to downstream. |
static <T> Flowable<T> | merge(Iterable<? extendsSingleSource<? extends T>> sources)Merges an Iterable sequence of SingleSource instances into a single Flowable sequence, running all SingleSources at once. |
static <T> Flowable<T> | merge(Publisher<? extendsSingleSource<? extends T>> sources)Merges a Flowable sequence of SingleSource instances into a single Flowable sequence, running all SingleSources at once. |
static <T> Single<T> | merge(SingleSource<? extendsSingleSource<? extends T>> source)Flattens a Single that emits aSingle into a singleSingle that emits the item emitted by the nestedSingle, without any transformation. |
static <T> Flowable<T> | merge(SingleSource<? extends T> source1,SingleSource<? extends T> source2)Flattens two Singles into a single Flowable, without any transformation. |
static <T> Flowable<T> | merge(SingleSource<? extends T> source1,SingleSource<? extends T> source2,SingleSource<? extends T> source3)Flattens three Singles into a single Flowable, without any transformation. |
static <T> Flowable<T> | merge(SingleSource<? extends T> source1,SingleSource<? extends T> source2,SingleSource<? extends T> source3,SingleSource<? extends T> source4)Flattens four Singles into a single Flowable, without any transformation. |
static <T> Flowable<T> | mergeDelayError(Iterable<? extendsSingleSource<? extends T>> sources)Merges an Iterable 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. |
static <T> Flowable<T> | mergeDelayError(Publisher<? extendsSingleSource<? extends T>> sources)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. |
static <T> Flowable<T> | mergeDelayError(SingleSource<? extends T> source1,SingleSource<? extends T> source2)Flattens two Singles into a single Flowable, without any transformation, delaying any error(s) until all sources succeed or fail. |
static <T> Flowable<T> | mergeDelayError(SingleSource<? extends T> source1,SingleSource<? extends T> source2,SingleSource<? extends T> source3)Flattens three Singles into a single Flowable, without any transformation, delaying any error(s) until all sources succeed or fail. |
static <T> Flowable<T> | mergeDelayError(SingleSource<? extends T> source1,SingleSource<? extends T> source2,SingleSource<? extends T> source3,SingleSource<? extends T> source4)Flattens four Singles into a single Flowable, without any transformation, delaying any error(s) until all sources succeed or fail. |
Flowable<T> | mergeWith(SingleSource<? extendsT> other)Flattens this and another Single into a single Flowable, without any transformation. |
static <T> Single<T> | never()Returns a singleton instance of a never-signalling Single (only calls onSubscribe). |
Single<T> | observeOn(Scheduler scheduler)Modifies a Single to emit its item (or notify of its error) on a specified Scheduler, asynchronously. |
Single<T> | onErrorResumeNext(Function<? superThrowable,? extendsSingleSource<? extendsT>> resumeFunctionInCaseOfError)Instructs a Single to pass control to another Single rather than invoking SingleObserver.onError(Throwable) if it encounters an error. |
Single<T> | onErrorResumeNext(Single<? extendsT> resumeSingleInCaseOfError)Instructs a Single to pass control to another Single rather than invoking SingleObserver.onError(Throwable) if it encounters an error. |
Single<T> | onErrorReturn(Function<Throwable,? extendsT> resumeFunction)Instructs a Single to emit an item (returned by a specified function) rather than invoking onError if it encounters an error. |
Single<T> | onErrorReturnItem(T value)Signals the specified value as success in case the current Single signals an error. |
Single<T> | onTerminateDetach()Nulls out references to the upstream producer and downstream SingleObserver if the sequence is terminated or downstream calls dispose(). |
Flowable<T> | repeat()Repeatedly re-subscribes to the current Single and emits each success value. |
Flowable<T> | repeat(long times)Re-subscribes to the current Single at most the given number of times and emits each success value. |
Flowable<T> | repeatUntil(BooleanSupplier stop)Re-subscribes to the current Single until the given BooleanSupplier returns true. |
Flowable<T> | repeatWhen(Function<? superFlowable<Object>,? extendsPublisher<?>> handler)Re-subscribes to the current Single if the Publisher returned by the handler function signals a value in response to a value signalled through the Flowable the handle receives. |
Single<T> | retry()Repeatedly re-subscribes to the current Single indefinitely if it fails with an onError. |
Single<T> | retry(BiPredicate<? superInteger,? superThrowable> predicate)Re-subscribe to the current Single if the given predicate returns true when the Single fails with an onError. |
Single<T> | retry(long times)Repeatedly re-subscribe at most the specified times to the current Single if it fails with an onError. |
Single<T> | retry(long times,Predicate<? superThrowable> predicate)Repeatedly re-subscribe at most times or until the predicate returns false, whichever happens first if it fails with an onError. |
Single<T> | retry(Predicate<? superThrowable> predicate)Re-subscribe to the current Single if the given predicate returns true when the Single fails with an onError. |
Single<T> | retryWhen(Function<? superFlowable<Throwable>,? extendsPublisher<?>> handler)Re-subscribes to the current Single if and when the Publisher returned by the handler function signals a value. |
Disposable | subscribe()Subscribes to a Single but ignore its emission or notification. |
Disposable | subscribe(BiConsumer<? superT,? superThrowable> onCallback)Subscribes to a Single and provides a composite callback to handle the item it emits or any error notification it issues. |
Disposable | subscribe(Consumer<? superT> onSuccess)Subscribes to a Single and provides a callback to handle the item it emits. |
Disposable | subscribe(Consumer<? superT> onSuccess,Consumer<? superThrowable> onError)Subscribes to a Single and provides callbacks to handle the item it emits or any error notification it issues. |
void | subscribe(SingleObserver<? superT> observer)Subscribes the given SingleObserver to this SingleSource instance. |
protected abstract void | subscribeActual(SingleObserver<? superT> observer)Implement this method in subclasses to handle the incoming SingleObservers. |
Single<T> | subscribeOn(Scheduler scheduler)Asynchronously subscribes subscribers to this Single on the specified Scheduler. |
<E extendsSingleObserver<? superT>> | subscribeWith(E observer)Subscribes a given SingleObserver (subclass) to this Single and returns the given SingleObserver as is. |
Single<T> | takeUntil(CompletableSource other)Returns a Single that emits the item emitted by the source Single until a Completable terminates. |
<E> Single<T> | takeUntil(Publisher<E> other)Returns a Single that emits the item emitted by the source Single until a Publisher emits an item. |
<E> Single<T> | takeUntil(SingleSource<? extends E> other)Returns a Single that emits the item emitted by the source Single until a second Single emits an item. |
TestObserver<T> | test()Creates a TestObserver and subscribes it to this Single. |
TestObserver<T> | test(boolean cancelled)Creates a TestObserver optionally in cancelled state, then subscribes it to this Single. |
Single<T> | timeout(long timeout,TimeUnit unit)Signals a TimeoutException if the current Single doesn't signal a success value within the specified timeout window. |
Single<T> | timeout(long timeout,TimeUnit unit,Scheduler scheduler)Signals a TimeoutException if the current Single doesn't signal a success value within the specified timeout window. |
Single<T> | timeout(long timeout,TimeUnit unit,Scheduler scheduler,SingleSource<? extendsT> other)Runs the current Single and if it doesn't signal within the specified timeout window, it is disposed and the other SingleSource subscribed to. |
Single<T> | timeout(long timeout,TimeUnit unit,SingleSource<? extendsT> other)Runs the current Single and if it doesn't signal within the specified timeout window, it is disposed and the other SingleSource subscribed to. |
staticSingle<Long> | timer(long delay,TimeUnit unit)Signals success with 0L value after the given delay for each SingleObserver. |
staticSingle<Long> | timer(long delay,TimeUnit unit,Scheduler scheduler)Signals success with 0L value after the given delay for each SingleObserver. |
<R> R | to(Function<? superSingle<T>,R> convert)Calls the specified converter function with the current Single instance during assembly time and returns its result. |
Completable | toCompletable()Deprecated. see ignoreElement() instead, will be removed in 3.0 |
Flowable<T> | toFlowable()Converts this Single into a Flowable. |
Future<T> | toFuture()Returns a Future representing the single value emitted by thisSingle. |
Maybe<T> | toMaybe()Converts this Single into a Maybe. |
Observable<T> | toObservable()Converts this Single into an Observable. |
static <T> Single<T> | unsafeCreate(SingleSource<T> onSubscribe)Advanced use only: creates a Single instance without any safeguards by using a callback that is called with a SingleObserver. |
Single<T> | unsubscribeOn(Scheduler scheduler)Returns a Single which makes sure when a SingleObserver disposes the Disposable, that call is propagated up on the specified scheduler. |
static <T,U> Single<T> | using(Callable<U> resourceSupplier,Function<? super U,? extendsSingleSource<? extends T>> singleFunction,Consumer<? super U> disposer)Allows using and disposing a resource while running a SingleSource instance generated from that resource (similar to a try-with-resources). |
static <T,U> Single<T> | using(Callable<U> resourceSupplier,Function<? super U,? extendsSingleSource<? extends T>> singleFunction,Consumer<? super U> disposer, boolean eager)Allows using and disposing a resource while running a SingleSource instance generated from that resource (similar to a try-with-resources). |
static <T> Single<T> | wrap(SingleSource<T> source)Wraps a SingleSource instance into a new Single instance if not already a Single instance. |
static <T,R> Single<R> | zip(Iterable<? extendsSingleSource<? extends T>> sources,Function<? superObject[],? extends R> zipper)Waits until all SingleSource sources provided by the Iterable sequence signal a success value and calls a zipper function with an array of these values to return a result to be emitted to downstream. |
static <T1,T2,R> Single<R> | zip(SingleSource<? extends T1> source1,SingleSource<? extends T2> source2,BiFunction<? super T1,? super T2,? extends R> zipper)Returns a Single that emits the results of a specified combiner function applied to two items emitted by two other Singles. |
static <T1,T2,T3,R> | zip(SingleSource<? extends T1> source1,SingleSource<? extends T2> source2,SingleSource<? extends T3> source3,Function3<? super T1,? super T2,? super T3,? extends R> zipper)Returns a Single that emits the results of a specified combiner function applied to three items emitted by three other Singles. |
static <T1,T2,T3,T4,R> | zip(SingleSource<? extends T1> source1,SingleSource<? extends T2> source2,SingleSource<? extends T3> source3,SingleSource<? extends T4> source4,Function4<? super T1,? super T2,? super T3,? super T4,? extends R> zipper)Returns a Single that emits the results of a specified combiner function applied to four items emitted by four other Singles. |
static <T1,T2,T3,T4,T5,R> | zip(SingleSource<? extends T1> source1,SingleSource<? extends T2> source2,SingleSource<? extends T3> source3,SingleSource<? extends T4> source4,SingleSource<? extends T5> source5,Function5<? super T1,? super T2,? super T3,? super T4,? super T5,? extends R> zipper)Returns a Single that emits the results of a specified combiner function applied to five items emitted by five other Singles. |
static <T1,T2,T3,T4,T5,T6,R> | zip(SingleSource<? extends T1> source1,SingleSource<? extends T2> source2,SingleSource<? extends T3> source3,SingleSource<? extends T4> source4,SingleSource<? extends T5> source5,SingleSource<? extends T6> source6,Function6<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? extends R> zipper)Returns a Single that emits the results of a specified combiner function applied to six items emitted by six other Singles. |
static <T1,T2,T3,T4,T5,T6,T7,R> | zip(SingleSource<? extends T1> source1,SingleSource<? extends T2> source2,SingleSource<? extends T3> source3,SingleSource<? extends T4> source4,SingleSource<? extends T5> source5,SingleSource<? extends T6> source6,SingleSource<? extends T7> source7,Function7<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? extends R> zipper)Returns a Single that emits the results of a specified combiner function applied to seven items emitted by seven other Singles. |
static <T1,T2,T3,T4,T5,T6,T7,T8,R> | zip(SingleSource<? extends T1> source1,SingleSource<? extends T2> source2,SingleSource<? extends T3> source3,SingleSource<? extends T4> source4,SingleSource<? extends T5> source5,SingleSource<? extends T6> source6,SingleSource<? extends T7> source7,SingleSource<? extends T8> source8,Function8<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? super T8,? extends R> zipper)Returns a Single that emits the results of a specified combiner function applied to eight items emitted by eight other Singles. |
static <T1,T2,T3,T4,T5,T6,T7,T8,T9,R> | zip(SingleSource<? extends T1> source1,SingleSource<? extends T2> source2,SingleSource<? extends T3> source3,SingleSource<? extends T4> source4,SingleSource<? extends T5> source5,SingleSource<? extends T6> source6,SingleSource<? extends T7> source7,SingleSource<? extends T8> source8,SingleSource<? extends T9> source9,Function9<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? super T8,? super T9,? extends R> zipper)Returns a Single that emits the results of a specified combiner function applied to nine items emitted by nine other Singles. |
static <T,R> Single<R> | zipArray(Function<? superObject[],? extends R> zipper,SingleSource<? extends T>... sources)Waits until all SingleSource sources provided via an array signal a success value and calls a zipper function with an array of these values to return a result to be emitted to downstream. |
<U,R> Single<R> | zipWith(SingleSource<U> other,BiFunction<? superT,? super U,? extends R> zipper)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. |
@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Single<T> amb(Iterable<? extendsSingleSource<? extends T>> sources)

amb does not operate by default on a particularScheduler.T - the value typesources - the Iterable sequence of sources. A subscription to each source will occur in the same order as in this Iterable.@CheckReturnValue@SchedulerSupport(value="none")public static <T> Single<T> ambArray(SingleSource<? extends T>... sources)

ambArray does not operate by default on a particularScheduler.T - the value typesources - the array of sources. A subscription to each source will occur in the same order as in this array.@CheckReturnValue@NonNull@SchedulerSupport(value="none")@BackpressureSupport(value=FULL)public static <T> Flowable<T> concat(Iterable<? extendsSingleSource<? extends T>> sources)

Flowable honors the backpressure of the downstream consumer.concat does not operate by default on a particularScheduler.T - the value typesources - the Iterable sequence of SingleSource instances@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Observable<T> concat(ObservableSource<? extendsSingleSource<? extends T>> sources)

concat does not operate by default on a particularScheduler.T - the value typesources - the ObservableSource of SingleSource instances@CheckReturnValue@NonNull@BackpressureSupport(value=FULL)@SchedulerSupport(value="none")public static <T> Flowable<T> concat(Publisher<? extendsSingleSource<? extends T>> sources)

Flowable honors the backpressure of the downstream consumer and the sourcesPublisher is expected to honor it as well.concat does not operate by default on a particularScheduler.T - the value typesources - the Publisher of SingleSource instances@CheckReturnValue@NonNull@BackpressureSupport(value=FULL)@SchedulerSupport(value="none")public static <T> Flowable<T> concat(Publisher<? extendsSingleSource<? extends T>> sources, int prefetch)

Flowable honors the backpressure of the downstream consumer and the sourcesPublisher is expected to honor it as well.concat does not operate by default on a particularScheduler.T - the value typesources - the Publisher of SingleSource instancesprefetch - the number of SingleSources to prefetch from the Publisher@CheckReturnValue@NonNull@BackpressureSupport(value=FULL)@SchedulerSupport(value="none")public static <T> Flowable<T> concat(SingleSource<? extends T> source1,SingleSource<? extends T> source2)

Flowable honors the backpressure of the downstream consumer.concat does not operate by default on a particularScheduler.T - the common value typesource1 - a Single to be concatenatedsource2 - a Single to be concatenated@CheckReturnValue@NonNull@BackpressureSupport(value=FULL)@SchedulerSupport(value="none")public static <T> Flowable<T> concat(SingleSource<? extends T> source1,SingleSource<? extends T> source2,SingleSource<? extends T> source3)

Flowable honors the backpressure of the downstream consumer.concat does not operate by default on a particularScheduler.T - the common value typesource1 - a Single to be concatenatedsource2 - a Single to be concatenatedsource3 - a Single to be concatenated@CheckReturnValue@NonNull@BackpressureSupport(value=FULL)@SchedulerSupport(value="none")public static <T> Flowable<T> concat(SingleSource<? extends T> source1,SingleSource<? extends T> source2,SingleSource<? extends T> source3,SingleSource<? extends T> source4)

Flowable honors the backpressure of the downstream consumer.concat does not operate by default on a particularScheduler.T - the common value typesource1 - a Single to be concatenatedsource2 - a Single to be concatenatedsource3 - a Single to be concatenatedsource4 - a Single to be concatenated@CheckReturnValue@NonNull@BackpressureSupport(value=FULL)@SchedulerSupport(value="none")public static <T> Flowable<T> concatArray(SingleSource<? extends T>... sources)

Flowable honors the backpressure of the downstream consumer.concatArray does not operate by default on a particularScheduler.T - the value typesources - the array of SingleSource instances@BackpressureSupport(value=FULL)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Flowable<T> concatArrayEager(SingleSource<? extends T>... sources)

Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the source SingleSources. The operator buffers the value emitted by these SingleSources and then drains them in order, each one after the previous one completes.
Scheduler.T - the value typesources - a sequence of Single that need to be eagerly concatenated@BackpressureSupport(value=FULL)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Flowable<T> concatEager(Publisher<? extendsSingleSource<? extends T>> sources)

Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the emitted source Publishers as they are observed. The operator buffers the values emitted by these Publishers and then drains them in order, each one after the previous one completes.
MissingBackpressureException.Scheduler.T - the value typesources - a sequence of Publishers that need to be eagerly concatenated@BackpressureSupport(value=FULL)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Flowable<T> concatEager(Iterable<? extendsSingleSource<? extends T>> sources)

Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the source SingleSources. The operator buffers the values emitted by these SingleSources and then drains them in order, each one after the previous one completes.
Scheduler.T - the value typesources - a sequence of SingleSource that need to be eagerly concatenated@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Single<T> create(SingleOnSubscribe<T> source)

Example:
Single.<Event>create(emitter -> { Callback listener = new Callback() { @Override public void onEvent(Event e) { emitter.onSuccess(e); } @Override public void onFailure(Exception e) { emitter.onError(e); } }; AutoCloseable c = api.someMethod(listener); emitter.setCancellable(c::close); });create does not operate by default on a particularScheduler.T - the value typesource - the emitter that is called when a SingleObserver subscribes to the returnedSingleSingleOnSubscribe,Cancellable@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Single<T> defer(Callable<? extendsSingleSource<? extends T>> singleSupplier)
Callable for each individualSingleObserver to return the actualSingleSource to be subscribed to.
defer does not operate by default on a particularScheduler.T - the value typesingleSupplier - theCallable that is called for each individualSingleObserver and returns a SingleSource instance to subscribe to@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Single<T> error(Callable<? extendsThrowable> errorSupplier)

error does not operate by default on a particularScheduler.T - the value typeerrorSupplier - the callable that is called for each individual SingleObserver and returns a Throwable instance to be emitted.@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Single<T> error(Throwable exception)
onError method when the subscriber subscribes to it.
error does not operate by default on a particularScheduler.T - the type of the item (ostensibly) emitted by the Singleexception - the particular Throwable to pass toonErroronError method when the subscriber subscribes to it@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Single<T> fromCallable(Callable<? extends T> callable)
Single that invokes passed function and emits its result for each new SingleObserver that subscribes. Allows you to defer execution of passed function until SingleObserver subscribes to theSingle. It makes passed function "lazy". Result of the function invocation will be emitted by theSingle.

fromCallable does not operate by default on a particularScheduler.Callable throws an exception, the respectiveThrowable is delivered to the downstream viaSingleObserver.onError(Throwable), except when the downstream has disposed thisSingle source. In this latter case, theThrowable is delivered to the global error handler viaRxJavaPlugins.onError(Throwable) as anUndeliverableException.T - the type of the item emitted by theSingle.callable - function which execution should be deferred, it will be invoked when SingleObserver will subscribe to theSingle.Single whoseSingleObservers' subscriptions trigger an invocation of the given function.@CheckReturnValue@SchedulerSupport(value="none")public static <T> Single<T> fromFuture(Future<? extends T> future)
Future into aSingle.
You can convert any object that supports theFuture interface into a Single that emits the return value of theFuture.get() method of that object, by passing the object into thefrom method.
Important note: This Single is blocking; you cannot dispose it.
fromFuture does not operate by default on a particularScheduler.T - the type of object that theFuture returns, and also the type of item to be emitted by the resultingSinglefuture - the sourceFutureSingle that emits the item from the sourceFuture@CheckReturnValue@SchedulerSupport(value="none")public static <T> Single<T> fromFuture(Future<? extends T> future, long timeout,TimeUnit unit)
Future into aSingle, with a timeout on the Future.
You can convert any object that supports theFuture interface into aSingle that emits the return value of theFuture.get() method of that object, by passing the object into thefrom method.
Important note: ThisSingle is blocking; you cannot dispose it.
fromFuture does not operate by default on a particularScheduler.T - the type of object that theFuture returns, and also the type of item to be emitted by the resultingSinglefuture - the sourceFuturetimeout - the maximum time to wait before callinggetunit - theTimeUnit of thetimeout argumentSingle that emits the item from the sourceFuture@CheckReturnValue@SchedulerSupport(value="custom")public static <T> Single<T> fromFuture(Future<? extends T> future, long timeout,TimeUnit unit,Scheduler scheduler)
Future into aSingle, with a timeout on the Future.
You can convert any object that supports theFuture interface into aSingle that emits the return value of theFuture.get() method of that object, by passing the object into thefrom method.
Important note: ThisSingle is blocking; you cannot dispose it.
Scheduler where the blocking wait will happen.T - the type of object that theFuture returns, and also the type of item to be emitted by the resultingSinglefuture - the sourceFuturetimeout - the maximum time to wait before callinggetunit - theTimeUnit of thetimeout argumentscheduler - the Scheduler to use for the blocking waitSingle that emits the item from the sourceFuture@CheckReturnValue@SchedulerSupport(value="custom")public static <T> Single<T> fromFuture(Future<? extends T> future,Scheduler scheduler)
Future, operating on a specifiedScheduler, into aSingle.
You can convert any object that supports theFuture interface into aSingle that emits the return value of theFuture.get() method of that object, by passing the object into thefrom method.
Scheduler this operator will use.T - the type of object that theFuture returns, and also the type of item to be emitted by the resultingSinglefuture - the sourceFuturescheduler - theScheduler to wait for the Future on. Use a Scheduler such asSchedulers.io() that can block and wait on the FutureSingle that emits the item from the sourceFuture@BackpressureSupport(value=UNBOUNDED_IN)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Single<T> fromPublisher(Publisher<? extends T> publisher)
If the source Publisher is empty, a NoSuchElementException is signalled. If the source has more than one element, an IndexOutOfBoundsException is signalled.
ThePublisher must follow theReactive Streams specification. Violating the specification may result in undefined behavior.
If possible, usecreate(SingleOnSubscribe) to create a source-likeSingle instead.
Note that even thoughPublisher appears to be a functional interface, it is not recommended to implement it through a lambda as the specification requires state management that is not achievable with a stateless lambda.

publisher is consumed in an unbounded fashion but will be cancelled if it produced more than one item.fromPublisher does not operate by default on a particularScheduler.T - the value typepublisher - the source Publisher instance, not nullcreate(SingleOnSubscribe)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Single<T> fromObservable(ObservableSource<? extends T> observableSource)
If the ObservableSource is empty, a NoSuchElementException is signalled. If the source has more than one element, an IndexOutOfBoundsException is signalled.

fromObservable does not operate by default on a particularScheduler.T - the type of the item emitted by theSingle.observableSource - the source Observable, not null@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic static <T> Single<T> just(T item)
Single that emits a specified item.
To convert any object into aSingle that emits that object, pass that object into thejust method.
just does not operate by default on a particularScheduler.T - the type of that itemitem - the item to emitSingle that emitsitem@CheckReturnValue@NonNull@BackpressureSupport(value=FULL)@SchedulerSupport(value="none")public static <T> Flowable<T> merge(Iterable<? extendsSingleSource<? extends T>> sources)

Flowable honors the backpressure of the downstream consumer.merge does not operate by default on a particularScheduler.SingleSources signal aThrowable viaonError, the resultingFlowable terminates with thatThrowable and all other sourceSingleSources are disposed. If more than oneSingleSource signals an error, the resultingFlowable may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeException containing two or more of the various error signals.Throwables that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable) method asUndeliverableException errors. Similarly,Throwables signaled by source(s) after the returnedFlowable has been cancelled or terminated with a (composite) error will be sent to the same global error handler. UsemergeDelayError(Iterable) to merge sources and terminate only when all sourceSingleSources have completed or failed with an error.T - the common and resulting value typesources - the Iterable sequence of SingleSource sourcesmergeDelayError(Iterable)@CheckReturnValue@NonNull@BackpressureSupport(value=FULL)@SchedulerSupport(value="none")public static <T> Flowable<T> merge(Publisher<? extendsSingleSource<? extends T>> sources)

Flowable honors the backpressure of the downstream consumer.merge does not operate by default on a particularScheduler.SingleSources signal aThrowable viaonError, the resultingFlowable terminates with thatThrowable and all other sourceSingleSources are disposed. If more than oneSingleSource signals an error, the resultingFlowable may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeException containing two or more of the various error signals.Throwables that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable) method asUndeliverableException errors. Similarly,Throwables signaled by source(s) after the returnedFlowable has been cancelled or terminated with a (composite) error will be sent to the same global error handler. UsemergeDelayError(Publisher) to merge sources and terminate only when all sourceSingleSources have completed or failed with an error.T - the common and resulting value typesources - the Flowable sequence of SingleSource sourcesmergeDelayError(Publisher)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Single<T> merge(SingleSource<? extendsSingleSource<? extends T>> source)
Single that emits aSingle into a singleSingle that emits the item emitted by the nestedSingle, without any transformation.
merge does not operate by default on a particularScheduler.Single emits the outer source's or the innerSingleSource'sThrowable as is. Unlike the othermerge() operators, this operator won't and can't produce aCompositeException because there is only one possibility for the outer or the innerSingleSource to emit anonError signal. Therefore, there is no need for amergeDelayError(SingleSource<SingleSource<T>>) operator.T - the value type of the sources and the outputsource - aSingle that emits aSingleSingle that emits the item that is the result of flattening theSingle emitted bysource@CheckReturnValue@NonNull@BackpressureSupport(value=FULL)@SchedulerSupport(value="none")public static <T> Flowable<T> merge(SingleSource<? extends T> source1,SingleSource<? extends T> source2)

You can combine items emitted by multiple Singles so that they appear as a single Flowable, by using themerge method.
Flowable honors the backpressure of the downstream consumer.merge does not operate by default on a particularScheduler.SingleSources signal aThrowable viaonError, the resultingFlowable terminates with thatThrowable and all other sourceSingleSources are disposed. If more than oneSingleSource signals an error, the resultingFlowable may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeException containing two or more of the various error signals.Throwables that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable) method asUndeliverableException errors. Similarly,Throwables signaled by source(s) after the returnedFlowable has been cancelled or terminated with a (composite) error will be sent to the same global error handler. UsemergeDelayError(SingleSource, SingleSource) to merge sources and terminate only when all sourceSingleSources have completed or failed with an error.T - the common value typesource1 - a SingleSource to be mergedsource2 - a SingleSource to be mergedmergeDelayError(SingleSource, SingleSource)@CheckReturnValue@NonNull@BackpressureSupport(value=FULL)@SchedulerSupport(value="none")public static <T> Flowable<T> merge(SingleSource<? extends T> source1,SingleSource<? extends T> source2,SingleSource<? extends T> source3)

You can combine items emitted by multiple Singles so that they appear as a single Flowable, by using themerge method.
Flowable honors the backpressure of the downstream consumer.merge does not operate by default on a particularScheduler.SingleSources signal aThrowable viaonError, the resultingFlowable terminates with thatThrowable and all other sourceSingleSources are disposed. If more than oneSingleSource signals an error, the resultingFlowable may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeException containing two or more of the various error signals.Throwables that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable) method asUndeliverableException errors. Similarly,Throwables signaled by source(s) after the returnedFlowable has been cancelled or terminated with a (composite) error will be sent to the same global error handler. UsemergeDelayError(SingleSource, SingleSource, SingleSource) to merge sources and terminate only when all sourceSingleSources have completed or failed with an error.T - the common value typesource1 - a SingleSource to be mergedsource2 - a SingleSource to be mergedsource3 - a SingleSource to be mergedmergeDelayError(SingleSource, SingleSource, SingleSource)@CheckReturnValue@NonNull@BackpressureSupport(value=FULL)@SchedulerSupport(value="none")public static <T> Flowable<T> merge(SingleSource<? extends T> source1,SingleSource<? extends T> source2,SingleSource<? extends T> source3,SingleSource<? extends T> source4)

You can combine items emitted by multiple Singles so that they appear as a single Flowable, by using themerge method.
Flowable honors the backpressure of the downstream consumer.merge does not operate by default on a particularScheduler.SingleSources signal aThrowable viaonError, the resultingFlowable terminates with thatThrowable and all other sourceSingleSources are disposed. If more than oneSingleSource signals an error, the resultingFlowable may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeException containing two or more of the various error signals.Throwables that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable) method asUndeliverableException errors. Similarly,Throwables signaled by source(s) after the returnedFlowable has been cancelled or terminated with a (composite) error will be sent to the same global error handler. UsemergeDelayError(SingleSource, SingleSource, SingleSource, SingleSource) to merge sources and terminate only when all sourceSingleSources have completed or failed with an error.T - the common value typesource1 - a SingleSource to be mergedsource2 - a SingleSource to be mergedsource3 - a SingleSource to be mergedsource4 - a SingleSource to be mergedmergeDelayError(SingleSource, SingleSource, SingleSource, SingleSource)@CheckReturnValue@NonNull@BackpressureSupport(value=FULL)@SchedulerSupport(value="none")public static <T> Flowable<T> mergeDelayError(Iterable<? extendsSingleSource<? extends T>> sources)

Flowable honors the backpressure of the downstream consumer.mergeDelayError does not operate by default on a particularScheduler.History: 2.1.9 - experimental
T - the common and resulting value typesources - the Iterable sequence of SingleSource sourcesmerge(Iterable)@CheckReturnValue@NonNull@BackpressureSupport(value=FULL)@SchedulerSupport(value="none")public static <T> Flowable<T> mergeDelayError(Publisher<? extendsSingleSource<? extends T>> sources)

Flowable honors the backpressure of the downstream consumer.mergeDelayError does not operate by default on a particularScheduler.History: 2.1.9 - experimental
T - the common and resulting value typesources - the Flowable sequence of SingleSource sourcesmerge(Publisher)@CheckReturnValue@NonNull@BackpressureSupport(value=FULL)@SchedulerSupport(value="none")public static <T> Flowable<T> mergeDelayError(SingleSource<? extends T> source1,SingleSource<? extends T> source2)

You can combine items emitted by multiple Singles so that they appear as a single Flowable, by using themergeDelayError method.
Flowable honors the backpressure of the downstream consumer.mergeDelayError does not operate by default on a particularScheduler.History: 2.1.9 - experimental
T - the common value typesource1 - a SingleSource to be mergedsource2 - a SingleSource to be mergedmerge(SingleSource, SingleSource)@CheckReturnValue@NonNull@BackpressureSupport(value=FULL)@SchedulerSupport(value="none")public static <T> Flowable<T> mergeDelayError(SingleSource<? extends T> source1,SingleSource<? extends T> source2,SingleSource<? extends T> source3)

You can combine items emitted by multiple Singles so that they appear as a single Flowable, by using themergeDelayError method.
Flowable honors the backpressure of the downstream consumer.mergeDelayError does not operate by default on a particularScheduler.History: 2.1.9 - experimental
T - the common value typesource1 - a SingleSource to be mergedsource2 - a SingleSource to be mergedsource3 - a SingleSource to be mergedmerge(SingleSource, SingleSource, SingleSource)@CheckReturnValue@NonNull@BackpressureSupport(value=FULL)@SchedulerSupport(value="none")public static <T> Flowable<T> mergeDelayError(SingleSource<? extends T> source1,SingleSource<? extends T> source2,SingleSource<? extends T> source3,SingleSource<? extends T> source4)

You can combine items emitted by multiple Singles so that they appear as a single Flowable, by using themergeDelayError method.
Flowable honors the backpressure of the downstream consumer.mergeDelayError does not operate by default on a particularScheduler.History: 2.1.9 - experimental
T - the common value typesource1 - a SingleSource to be mergedsource2 - a SingleSource to be mergedsource3 - a SingleSource to be mergedsource4 - a SingleSource to be mergedmerge(SingleSource, SingleSource, SingleSource, SingleSource)@CheckReturnValue@SchedulerSupport(value="none")public static <T> Single<T> never()

never does not operate by default on a particularScheduler.T - the target value type@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")public static Single<Long> timer(long delay,TimeUnit unit)

timer operates by default on thecomputationScheduler.delay - the delay amountunit - the time unit of the delay@CheckReturnValue@NonNull@SchedulerSupport(value="custom")public static Single<Long> timer(long delay,TimeUnit unit,Scheduler scheduler)

Scheduler to signal on.delay - the delay amountunit - the time unit of the delayscheduler - the scheduler where the single 0L will be emittedNullPointerException - if unit is null, or if scheduler is null@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Single<Boolean> equals(SingleSource<? extends T> first,SingleSource<? extends T> second)

equals does not operate by default on a particularScheduler.T - the common value typefirst - the first SingleSource instancesecond - the second SingleSource instance@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Single<T> unsafeCreate(SingleSource<T> onSubscribe)

unsafeCreate does not operate by default on a particularScheduler.T - the value typeonSubscribe - the function that is called with the subscribing SingleObserverIllegalArgumentException - ifsource is a subclass ofSingle; such instances don't need conversion and is possibly a port remnant from 1.x or one should usehide() instead.@CheckReturnValue@SchedulerSupport(value="none")public static <T,U> Single<T> using(Callable<U> resourceSupplier,Function<? super U,? extendsSingleSource<? extends T>> singleFunction,Consumer<? super U> disposer)

using does not operate by default on a particularScheduler.T - the value type of the SingleSource generatedU - the resource typeresourceSupplier - the Callable called for each SingleObserver to generate a resource ObjectsingleFunction - the function called with the returned resource Object fromresourceSupplier and should return a SingleSource instance to be run by the operatordisposer - the consumer of the generated resource that is called exactly once for that particular resource when the generated SingleSource terminates (successfully or with an error) or gets disposed.@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T,U> Single<T> using(Callable<U> resourceSupplier,Function<? super U,? extendsSingleSource<? extends T>> singleFunction,Consumer<? super U> disposer, boolean eager)

using does not operate by default on a particularScheduler.T - the value type of the SingleSource generatedU - the resource typeresourceSupplier - the Callable called for each SingleObserver to generate a resource ObjectsingleFunction - the function called with the returned resource Object fromresourceSupplier and should return a SingleSource instance to be run by the operatordisposer - the consumer of the generated resource that is called exactly once for that particular resource when the generated SingleSource terminates (successfully or with an error) or gets disposed.eager - if true, the disposer is called before the terminal event is signalled if false, the disposer is called after the terminal event is delivered to downstream@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> Single<T> wrap(SingleSource<T> source)

wrap does not operate by default on a particularScheduler.T - the value typesource - the source to wrap@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T,R> Single<R> zip(Iterable<? extendsSingleSource<? extends T>> sources,Function<? superObject[],? extends R> zipper)
If theIterable ofSingleSources is empty aNoSuchElementException error is signalled after subscription.
Note on method signature: since Java doesn't allow creating a generic array withnew T[], the implementation of this operator has to create anObject[] instead. Unfortunately, aFunction<Integer[], R> passed to the method would trigger aClassCastException.

If any of the SingleSources signal an error, all other SingleSources get disposed and the error emitted to downstream immediately.
zip does not operate by default on a particularScheduler.T - the common value typeR - the result value typesources - the Iterable sequence of SingleSource instances. An empty sequence will result in anonError signal ofNoSuchElementException.zipper - the function that receives an array with values from each SingleSource and should return a value to be emitted to downstream@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T1,T2,R> Single<R> zip(SingleSource<? extends T1> source1,SingleSource<? extends T2> source2,BiFunction<? super T1,? super T2,? extends R> zipper)

zip does not operate by default on a particularScheduler.T1 - the first source Single's value typeT2 - the second source Single's value typeR - the result value typesource1 - the first source Singlesource2 - a second source Singlezipper - a function that, when applied to the item emitted by each of the source Singles, results in an item that will be emitted by the resulting Single@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T1,T2,T3,R> Single<R> zip(SingleSource<? extends T1> source1,SingleSource<? extends T2> source2,SingleSource<? extends T3> source3,Function3<? super T1,? super T2,? super T3,? extends R> zipper)

zip does not operate by default on a particularScheduler.T1 - the first source Single's value typeT2 - the second source Single's value typeT3 - the third source Single's value typeR - the result value typesource1 - the first source Singlesource2 - a second source Singlesource3 - a third source Singlezipper - a function that, when applied to the item emitted by each of the source Singles, results in an item that will be emitted by the resulting Single@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T1,T2,T3,T4,R> Single<R> zip(SingleSource<? extends T1> source1,SingleSource<? extends T2> source2,SingleSource<? extends T3> source3,SingleSource<? extends T4> source4,Function4<? super T1,? super T2,? super T3,? super T4,? extends R> zipper)

zip does not operate by default on a particularScheduler.T1 - the first source Single's value typeT2 - the second source Single's value typeT3 - the third source Single's value typeT4 - the fourth source Single's value typeR - the result value typesource1 - the first source Singlesource2 - a second source Singlesource3 - a third source Singlesource4 - a fourth source Singlezipper - a function that, when applied to the item emitted by each of the source Singles, results in an item that will be emitted by the resulting Single@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T1,T2,T3,T4,T5,R> Single<R> zip(SingleSource<? extends T1> source1,SingleSource<? extends T2> source2,SingleSource<? extends T3> source3,SingleSource<? extends T4> source4,SingleSource<? extends T5> source5,Function5<? super T1,? super T2,? super T3,? super T4,? super T5,? extends R> zipper)

zip does not operate by default on a particularScheduler.T1 - the first source Single's value typeT2 - the second source Single's value typeT3 - the third source Single's value typeT4 - the fourth source Single's value typeT5 - the fifth source Single's value typeR - the result value typesource1 - the first source Singlesource2 - a second source Singlesource3 - a third source Singlesource4 - a fourth source Singlesource5 - a fifth source Singlezipper - a function that, when applied to the item emitted by each of the source Singles, results in an item that will be emitted by the resulting Single@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T1,T2,T3,T4,T5,T6,R> Single<R> zip(SingleSource<? extends T1> source1,SingleSource<? extends T2> source2,SingleSource<? extends T3> source3,SingleSource<? extends T4> source4,SingleSource<? extends T5> source5,SingleSource<? extends T6> source6,Function6<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? extends R> zipper)

zip does not operate by default on a particularScheduler.T1 - the first source Single's value typeT2 - the second source Single's value typeT3 - the third source Single's value typeT4 - the fourth source Single's value typeT5 - the fifth source Single's value typeT6 - the sixth source Single's value typeR - the result value typesource1 - the first source Singlesource2 - a second source Singlesource3 - a third source Singlesource4 - a fourth source Singlesource5 - a fifth source Singlesource6 - a sixth source Singlezipper - a function that, when applied to the item emitted by each of the source Singles, results in an item that will be emitted by the resulting Single@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T1,T2,T3,T4,T5,T6,T7,R> Single<R> zip(SingleSource<? extends T1> source1,SingleSource<? extends T2> source2,SingleSource<? extends T3> source3,SingleSource<? extends T4> source4,SingleSource<? extends T5> source5,SingleSource<? extends T6> source6,SingleSource<? extends T7> source7,Function7<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? extends R> zipper)

zip does not operate by default on a particularScheduler.T1 - the first source Single's value typeT2 - the second source Single's value typeT3 - the third source Single's value typeT4 - the fourth source Single's value typeT5 - the fifth source Single's value typeT6 - the sixth source Single's value typeT7 - the seventh source Single's value typeR - the result value typesource1 - the first source Singlesource2 - a second source Singlesource3 - a third source Singlesource4 - a fourth source Singlesource5 - a fifth source Singlesource6 - a sixth source Singlesource7 - a seventh source Singlezipper - a function that, when applied to the item emitted by each of the source Singles, results in an item that will be emitted by the resulting Single@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T1,T2,T3,T4,T5,T6,T7,T8,R> Single<R> zip(SingleSource<? extends T1> source1,SingleSource<? extends T2> source2,SingleSource<? extends T3> source3,SingleSource<? extends T4> source4,SingleSource<? extends T5> source5,SingleSource<? extends T6> source6,SingleSource<? extends T7> source7,SingleSource<? extends T8> source8,Function8<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? super T8,? extends R> zipper)

zip does not operate by default on a particularScheduler.T1 - the first source Single's value typeT2 - the second source Single's value typeT3 - the third source Single's value typeT4 - the fourth source Single's value typeT5 - the fifth source Single's value typeT6 - the sixth source Single's value typeT7 - the seventh source Single's value typeT8 - the eighth source Single's value typeR - the result value typesource1 - the first source Singlesource2 - a second source Singlesource3 - a third source Singlesource4 - a fourth source Singlesource5 - a fifth source Singlesource6 - a sixth source Singlesource7 - a seventh source Singlesource8 - an eighth source Singlezipper - a function that, when applied to the item emitted by each of the source Singles, results in an item that will be emitted by the resulting Single@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T1,T2,T3,T4,T5,T6,T7,T8,T9,R> Single<R> zip(SingleSource<? extends T1> source1,SingleSource<? extends T2> source2,SingleSource<? extends T3> source3,SingleSource<? extends T4> source4,SingleSource<? extends T5> source5,SingleSource<? extends T6> source6,SingleSource<? extends T7> source7,SingleSource<? extends T8> source8,SingleSource<? extends T9> source9,Function9<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? super T8,? super T9,? extends R> zipper)

zip does not operate by default on a particularScheduler.T1 - the first source Single's value typeT2 - the second source Single's value typeT3 - the third source Single's value typeT4 - the fourth source Single's value typeT5 - the fifth source Single's value typeT6 - the sixth source Single's value typeT7 - the seventh source Single's value typeT8 - the eighth source Single's value typeT9 - the ninth source Single's value typeR - the result value typesource1 - the first source Singlesource2 - a second source Singlesource3 - a third source Singlesource4 - a fourth source Singlesource5 - a fifth source Singlesource6 - a sixth source Singlesource7 - a seventh source Singlesource8 - an eighth source Singlesource9 - a ninth source Singlezipper - a function that, when applied to the item emitted by each of the source Singles, results in an item that will be emitted by the resulting Single@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T,R> Single<R> zipArray(Function<? superObject[],? extends R> zipper,SingleSource<? extends T>... sources)
If the array ofSingleSources is empty aNoSuchElementException error is signalled immediately.
Note on method signature: since Java doesn't allow creating a generic array withnew T[], the implementation of this operator has to create anObject[] instead. Unfortunately, aFunction<Integer[], R> passed to the method would trigger aClassCastException.

If any of the SingleSources signal an error, all other SingleSources get disposed and the error emitted to downstream immediately.
zipArray does not operate by default on a particularScheduler.T - the common value typeR - the result value typesources - the array of SingleSource instances. An empty sequence will result in anonError signal ofNoSuchElementException.zipper - the function that receives an array with values from each SingleSource and should return a value to be emitted to downstream@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final Single<T> ambWith(SingleSource<? extendsT> other)

ambWith does not operate by default on a particularScheduler.other - the other SingleSource to race for the first emission of success or error@CheckReturnValue@SchedulerSupport(value="none")public final <R> R as(@NonNullSingleConverter<T,? extends R> converter)

This allows fluent conversion to any other type.
as does not operate by default on a particularScheduler.History: 2.1.7 - experimental
R - the resulting object typeconverter - the function that receives the current Single instance and returns a valueNullPointerException - if converter is null@CheckReturnValue@SchedulerSupport(value="none")public final Single<T> hide()
onSubscribe().
hide does not operate by default on a particularScheduler.@CheckReturnValue@SchedulerSupport(value="none")public final <R> Single<R> compose(SingleTransformer<? superT,? extends R> transformer)

This method operates on the Single itself whereaslift(io.reactivex.SingleOperator<? extends R, ? super T>) operates on the Single's SingleObservers.
If the operator you are creating is designed to act on the individual item emitted by a Single, uselift(io.reactivex.SingleOperator<? extends R, ? super T>). 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) usecompose.
compose does not operate by default on a particularScheduler.R - the value type of the single returned by the transformer functiontransformer - the transformer function, not null@CheckReturnValue@SchedulerSupport(value="none")public final Single<T> cache()
The returned Single subscribes to the current Single when the first SingleObserver subscribes.
cache does not operate by default on a particularScheduler.@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <U> Single<U> cast(Class<? extends U> clazz)

cast does not operate by default on a particularScheduler.U - the target typeclazz - the type token to use for casting the success result from the current Single@BackpressureSupport(value=FULL)@CheckReturnValue@SchedulerSupport(value="none")public final Flowable<T> concatWith(SingleSource<? extendsT> other)

Flowable honors the backpressure of the downstream consumer.concatWith does not operate by default on a particularScheduler.other - a Single to be concatenated after the currentt1@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")public final Single<T> delay(long time,TimeUnit unit)

delay operates by default on thecomputationScheduler.time - the amount of time the success signal should be delayed forunit - the time unit@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")public final Single<T> delay(long time,TimeUnit unit, boolean delayError)

delay operates by default on thecomputationScheduler.History: 2.1.5 - experimental
time - the amount of time the success or error signal should be delayed forunit - the time unitdelayError - if true, both success and error signals are delayed. if false, only success signals are delayed.@CheckReturnValue@SchedulerSupport(value="custom")public final Single<T> delay(long time,TimeUnit unit,Scheduler scheduler)

Scheduler where the non-blocking wait and emission happenstime - the amount of time the success signal should be delayed forunit - the time unitscheduler - the target scheduler to use for the non-blocking wait and emissionNullPointerException - if unit is null, or if scheduler is null@CheckReturnValue@NonNull@SchedulerSupport(value="custom")public final Single<T> delay(long time,TimeUnit unit,Scheduler scheduler, boolean delayError)

Scheduler where the non-blocking wait and emission happensHistory: 2.1.5 - experimental
time - the amount of time the success or error signal should be delayed forunit - the time unitscheduler - the target scheduler to use for the non-blocking wait and emissiondelayError - if true, both success and error signals are delayed. if false, only success signals are delayed.NullPointerException - if unit is null, or if scheduler is null@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final Single<T> delaySubscription(CompletableSource other)

If the delaying source signals an error, that error is re-emitted and no subscription to the current Single happens.
delaySubscription does not operate by default on a particularScheduler.other - the CompletableSource that has to complete before the subscription to the current Single happens@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <U> Single<T> delaySubscription(SingleSource<U> other)

If the delaying source signals an error, that error is re-emitted and no subscription to the current Single happens.
delaySubscription does not operate by default on a particularScheduler.U - the element type of the other sourceother - the SingleSource that has to complete before the subscription to the current Single happens@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <U> Single<T> delaySubscription(ObservableSource<U> other)

If the delaying source signals an error, that error is re-emitted and no subscription to the current Single happens.
delaySubscription does not operate by default on a particularScheduler.U - the element type of the other sourceother - the ObservableSource that has to signal a value or complete before the subscription to the current Single happens@BackpressureSupport(value=FULL)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <U> Single<T> delaySubscription(Publisher<U> other)

If the delaying source signals an error, that error is re-emitted and no subscription to the current Single happens.
The other source is consumed in an unbounded manner (requesting Long.MAX_VALUE from it).
other publisher is consumed in an unbounded fashion but will be cancelled after the first item it produced.delaySubscription does not operate by default on a particularScheduler.U - the element type of the other sourceother - the Publisher that has to signal a value or complete before the subscription to the current Single happens@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")public final Single<T> delaySubscription(long time,TimeUnit unit)

delaySubscription does by default subscribe to the current Single on thecomputationScheduler after the delay.time - the time amount to wait with the subscriptionunit - the time unit of the waiting@CheckReturnValue@SchedulerSupport(value="custom")public final Single<T> delaySubscription(long time,TimeUnit unit,Scheduler scheduler)

delaySubscription does by default subscribe to the current Single on theScheduler you provided, after the delay.time - the time amount to wait with the subscriptionunit - the time unit of the waitingscheduler - the scheduler to wait on and subscribe on to the current Single@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <R> Maybe<R> dematerialize(Function<? superT,Notification<R>> selector)
Notification success value of this Single back into normalonSuccess,onError oronComplete signals as aMaybe source.
The intended use of theselector function is to perform a type-safe identity mapping (see example) on a source that is already of typeNotification<T>. The Java language doesn't allow limiting instance methods to a certain generic argument shape, therefore, a function is used to ensure the conversion remains type safe.
dematerialize does not operate by default on a particularScheduler.Example:
Single.just(Notification.createOnNext(1)) .dematerialize(notification -> notification) .test() .assertResult(1);R - the result typeselector - the function called with the success item and should return aNotification instance.materialize()@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final Single<T> doAfterSuccess(Consumer<? superT> onAfterSuccess)

Note that thedoAfterSuccess action is shared between subscriptions and as such should be thread-safe.
doAfterSuccess does not operate by default on a particularScheduler.History: 2.0.1 - experimental
onAfterSuccess - the Consumer that will be called after emitting an item from upstream to the downstream@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final Single<T> doAfterTerminate(Action onAfterTerminate)
Action to be called after this Single invokes either onSuccess or onError.
Note that thedoAfterTerminate action is shared between subscriptions and as such should be thread-safe.
doAfterTerminate does not operate by default on a particularScheduler.History: 2.0.6 - experimental
onAfterTerminate - anAction to be invoked when the source Single finishesAction@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final Single<T> doFinally(Action onFinally)
In case of a race between a terminal event and a dispose call, the providedonFinally action is executed once per subscription.
Note that theonFinally action is shared between subscriptions and as such should be thread-safe.

doFinally does not operate by default on a particularScheduler.History: 2.0.1 - experimental
onFinally - the action called when this Single terminates or gets disposed@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final Single<T> doOnSubscribe(Consumer<? superDisposable> onSubscribe)

doOnSubscribe does not operate by default on a particularScheduler.onSubscribe - the consumer called with the Disposable sent via onSubscribe@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final Single<T> doOnTerminate(Action onTerminate)

This differs fromdoAfterTerminate in that this happensbefore theonSuccess oronError notification.
doOnTerminate does not operate by default on a particularScheduler.onTerminate - the action to invoke when the consumer callsonSuccess oronErrordoOnTerminate(Action)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final Single<T> doOnSuccess(Consumer<? superT> onSuccess)

doOnSuccess does not operate by default on a particularScheduler.onSuccess - the consumer called with the success value of onSuccess@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final Single<T> doOnEvent(BiConsumer<? superT,? superThrowable> onEvent)

doOnEvent does not operate by default on a particularScheduler.onEvent - the consumer called with the success value of onEvent@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final Single<T> doOnError(Consumer<? superThrowable> onError)

doOnError does not operate by default on a particularScheduler.onError - the consumer called with the success value of onError@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final Single<T> doOnDispose(Action onDispose)
Action if a SingleObserver subscribed to the current Single disposes the common Disposable it received via onSubscribe.
doOnDispose does not operate by default on a particularScheduler.onDispose - the action called when the subscription is disposedNullPointerException - if onDispose is null@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final Maybe<T> filter(Predicate<? superT> predicate)

filter does not operate by default on a particularScheduler.predicate - a function that evaluates the item emitted by the source Maybe, returningtrue if it passes the filtertrue@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <R> Single<R> flatMap(Function<? superT,? extendsSingleSource<? extends R>> mapper)

flatMap does not operate by default on a particularScheduler.R - the result value typemapper - a function that, when applied to the item emitted by the source Single, returns a SingleSourcemapper when applied to the item emitted by the source Single@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <R> Maybe<R> flatMapMaybe(Function<? superT,? extendsMaybeSource<? extends R>> mapper)

flatMapMaybe does not operate by default on a particularScheduler.R - the result value typemapper - a function that, when applied to the item emitted by the source Single, returns a MaybeSourcemapper when applied to the item emitted by the source Single@BackpressureSupport(value=FULL)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <R> Flowable<R> flatMapPublisher(Function<? superT,? extendsPublisher<? extends R>> mapper)

Flowable honors the backpressure of the downstream consumer and thePublisher returned by the mapper function is expected to honor it as well.flatMapPublisher does not operate by default on a particularScheduler.R - the result value typemapper - a function that, when applied to the item emitted by the source Single, returns a Flowablefunc when applied to the item emitted by the source Single@BackpressureSupport(value=FULL)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <U> Flowable<U> flattenAsFlowable(Function<? superT,? extendsIterable<? extends U>> mapper)
Single into anIterable and emits its items as aFlowable sequence.
flattenAsFlowable does not operate by default on a particularScheduler.U - the type of item emitted by the resulting Iterablemapper - a function that returns an Iterable sequence of values for when given an item emitted by the source Single@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <U> Observable<U> flattenAsObservable(Function<? superT,? extendsIterable<? extends U>> mapper)
Single into anIterable and emits its items as anObservable sequence.
flattenAsObservable does not operate by default on a particularScheduler.U - the type of item emitted by the resulting Iterablemapper - a function that returns an Iterable sequence of values for when given an item emitted by the source Single@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <R> Observable<R> flatMapObservable(Function<? superT,? extendsObservableSource<? extends R>> mapper)

flatMapObservable does not operate by default on a particularScheduler.R - the result value typemapper - a function that, when applied to the item emitted by the source Single, returns an ObservableSourcefunc when applied to the item emitted by the source Single@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final Completable flatMapCompletable(Function<? superT,? extendsCompletableSource> mapper)
Completable that completes based on applying a specified function to the item emitted by the sourceSingle, where that function returns aCompletable.
flatMapCompletable does not operate by default on a particularScheduler.mapper - a function that, when applied to the item emitted by the source Single, returns a Completablefunc when applied to the item emitted by the source Single@CheckReturnValue@SchedulerSupport(value="none")public final T blockingGet()

blockingGet does not operate by default on a particularScheduler.Exception intoRuntimeException and throws that. Otherwise,RuntimeExceptions andErrors are rethrown as they are.@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <R> Single<R> lift(SingleOperator<? extends R,? superT> lift)
Single which, when subscribed to, invokes theapply(SingleObserver) method of the providedSingleOperator for each individual downstreamSingle and allows the insertion of a custom operator by accessing the downstream'sSingleObserver during this subscription phase and providing a newSingleObserver, containing the custom operator's intended business logic, that will be used in the subscription process going further upstream.
Generally, such a newSingleObserver will wrap the downstream'sSingleObserver and forwards theonSuccess andonError 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 ofdispose andisDisposed that would have traveled upstream and perform additional actions depending on the same business logic requirements.
Example:
// Step 1: Create the consumer type that will be returned by the SingleOperator.apply(): public final class CustomSingleObserver<T> implements SingleObserver<T>, Disposable { // The downstream's SingleObserver that will receive the onXXX events final SingleObserver<? super String> downstream; // The connection to the upstream source that will call this class' onXXX methods Disposable upstream; // The constructor takes the downstream subscriber and usually any other parameters public CustomSingleObserver(SingleObserver<? super String> downstream) { this.downstream = downstream; } // In the subscription phase, the upstream sends a Disposable to this class // and subsequently this class has to send a Disposable to the downstream. // Note that relaying the upstream's Disposable directly is not allowed in RxJava @Override public void onSubscribe(Disposable d) { if (upstream != null) { d.dispose(); } else { upstream = d; downstream.onSubscribe(this); } } // The upstream calls this with the next item and the implementation's // responsibility is to emit an item to the downstream based on the intended // business logic, or if it can't do so for the particular item, // request more from the upstream @Override public void onSuccess(T item) { String str = item.toString(); if (str.length() < 2) { downstream.onSuccess(str); } else { // Single is usually expected to produce one of the onXXX events downstream.onError(new NoSuchElementException()); } } // Some operators may handle the upstream's error while others // could just forward it to the downstream. @Override public void onError(Throwable throwable) { downstream.onError(throwable); } // Some operators may use their own resources which should be cleaned up if // the downstream disposes the flow before it completed. Operators without // resources can simply forward the dispose to the upstream. // In some cases, a disposed flag may be set by this method so that other parts // of this class may detect the dispose and stop sending events // to the downstream. @Override public void dispose() { upstream.dispose(); } // Some operators may simply forward the call to the upstream while others // can return the disposed flag set in dispose(). @Override public boolean isDisposed() { return upstream.isDisposed(); } } // Step 2: Create a class that implements the SingleOperator interface and // returns the custom consumer type from above in its apply() method. // Such class may define additional parameters to be submitted to // the custom consumer type. final class CustomSingleOperator<T> implements SingleOperator<String> { @Override public SingleObserver<? super String> apply(SingleObserver<? super T> upstream) { return new CustomSingleObserver<T>(upstream); } } // Step 3: Apply the custom operator via lift() in a flow by creating an instance of it // or reusing an existing one. Single.just(5) .lift(new CustomSingleOperator<Integer>()) .test() .assertResult("5"); Single.just(15) .lift(new CustomSingleOperator<Integer>()) .test() .assertFailure(NoSuchElementException.class);Creating custom operators can be complicated and it is recommended one consults theRxJava wiki: Writing operators page about the tools, requirements, rules, considerations and pitfalls of implementing them.
Note that implementing custom operators via thislift() method adds slightly more overhead by requiring an additional allocation and indirection per assembled flows. Instead, extending the abstractSingle class and creating aSingleTransformer with it is recommended.
Note also that it is not possible to stop the subscription phase inlift() as theapply() method requires a non-nullSingleObserver instance to be returned, which is then unconditionally subscribed to the upstreamSingle. For example, if the operator decided there is no reason to subscribe to the upstream source because of some optimization possibility or a failure to prepare the operator, it still has to return aSingleObserver that should immediately dispose the upstream'sDisposable in itsonSubscribe method. Again, using aSingleTransformer and extending theSingle is a better option assubscribeActual(io.reactivex.SingleObserver<? super T>) can decide to not subscribe to its upstream after all.
lift does not operate by default on a particularScheduler, however, theSingleOperator may use aScheduler to support its own asynchronous behavior.R - the output value typelift - theSingleOperator that receives the downstream'sSingleObserver and should return aSingleObserver with custom behavior to be used as the consumer for the currentSingle.compose(SingleTransformer)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <R> Single<R> map(Function<? superT,? extends R> mapper)

map does not operate by default on a particularScheduler.R - the result value typemapper - a function to apply to the item emitted by the Single@CheckReturnValue@SchedulerSupport(value="none")public final Single<Notification<T>> materialize()
Notification of the same kind and emits it as a single success value to downstream.
materialize does not operate by default on a particularScheduler.dematerialize(Function)@CheckReturnValue@SchedulerSupport(value="none")public final Single<Boolean> contains(Object value)

contains does not operate by default on a particularScheduler.value - the value to compare against the success value of this Single@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final Single<Boolean> contains(Object value,BiPredicate<Object,Object> comparer)

contains does not operate by default on a particularScheduler.value - the value to compare against the success value of this Singlecomparer - the function that receives the success value of this Single, the value provided and should return true if they are considered equal@BackpressureSupport(value=FULL)@CheckReturnValue@SchedulerSupport(value="none")public final Flowable<T> mergeWith(SingleSource<? extendsT> other)

You can combine items emitted by multiple Singles so that they appear as a single Flowable, by using themergeWith method.
Flowable honors the backpressure of the downstream consumer.mergeWith does not operate by default on a particularScheduler.other - a SingleSource to be merged@CheckReturnValue@NonNull@SchedulerSupport(value="custom")public final Single<T> observeOn(Scheduler scheduler)
Scheduler, asynchronously.
Scheduler this operator will use.scheduler - theScheduler to notify subscribers onSchedulerNullPointerException - if scheduler is nullsubscribeOn(io.reactivex.Scheduler)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final Single<T> onErrorReturn(Function<Throwable,? extendsT> resumeFunction)
onError if it encounters an error.
By default, when a Single encounters an error that prevents it from emitting the expected item to its subscriber, the Single invokes its subscriber'sSingleObserver.onError(java.lang.Throwable) method, and then quits without invoking any more of its subscriber's methods. TheonErrorReturn method changes this behavior. If you pass a function (resumeFunction) to a Single'sonErrorReturn method, if the original Single encounters an error, instead of invoking its subscriber'sSingleObserver.onError(java.lang.Throwable) method, it will instead emit the return value ofresumeFunction.
You can use this to prevent errors from propagating or to supply fallback data should errors be encountered.
onErrorReturn does not operate by default on a particularScheduler.resumeFunction - a function that returns an item that the new Single will emit if the source Single encounters an error@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final Single<T> onErrorReturnItem(T value)

onErrorReturnItem does not operate by default on a particularScheduler.value - the value to signal if the current Single fails@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final Single<T> onErrorResumeNext(Single<? extendsT> resumeSingleInCaseOfError)
SingleObserver.onError(Throwable) if it encounters an error.
By default, when a Single encounters an error that prevents it from emitting the expected item to itsSingleObserver, the Single invokes its SingleObserver'sonError method, and then quits without invoking any more of its SingleObserver's methods. TheonErrorResumeNext method changes this behavior. If you pass another Single (resumeSingleInCaseOfError) to a Single'sonErrorResumeNext method, if the original Single encounters an error, instead of invoking its SingleObserver'sonError method, it will instead relinquish control toresumeSingleInCaseOfError which will invoke the SingleObserver'sonSuccess method if it is able to do so. In such a case, because no Single necessarily invokesonError, the SingleObserver may never know that an error happened.
You can use this to prevent errors from propagating or to supply fallback data should errors be encountered.
onErrorResumeNext does not operate by default on a particularScheduler.resumeSingleInCaseOfError - a Single that will take control if source Single encounters an error.@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final Single<T> onErrorResumeNext(Function<? superThrowable,? extendsSingleSource<? extendsT>> resumeFunctionInCaseOfError)
SingleObserver.onError(Throwable) if it encounters an error.
By default, when a Single encounters an error that prevents it from emitting the expected item to itsSingleObserver, the Single invokes its SingleObserver'sonError method, and then quits without invoking any more of its SingleObserver's methods. TheonErrorResumeNext method changes this behavior. If you pass a function that will return another Single (resumeFunctionInCaseOfError) to a Single'sonErrorResumeNext method, if the original Single encounters an error, instead of invoking its SingleObserver'sonError method, it will instead relinquish control toresumeSingleInCaseOfError which will invoke the SingleObserver'sonSuccess method if it is able to do so. In such a case, because no Single necessarily invokesonError, the SingleObserver may never know that an error happened.
You can use this to prevent errors from propagating or to supply fallback data should errors be encountered.
onErrorResumeNext does not operate by default on a particularScheduler.resumeFunctionInCaseOfError - a function that returns a Single that will take control if source Single encounters an error.@CheckReturnValue@SchedulerSupport(value="none")public final Single<T> onTerminateDetach()

onTerminateDetach does not operate by default on a particularScheduler.History: 2.1.5 - experimental
@BackpressureSupport(value=FULL)@CheckReturnValue@SchedulerSupport(value="none")public final Flowable<T> repeat()

Flowable honors the backpressure of the downstream consumer.repeat does not operate by default on a particularScheduler.@BackpressureSupport(value=FULL)@CheckReturnValue@SchedulerSupport(value="none")public final Flowable<T> repeat(long times)

Flowable honors the backpressure of the downstream consumer.repeat does not operate by default on a particularScheduler.times - the number of times to re-subscribe to the current Single@BackpressureSupport(value=FULL)@CheckReturnValue@SchedulerSupport(value="none")public final Flowable<T> repeatWhen(Function<? superFlowable<Object>,? extendsPublisher<?>> handler)

Flowable honors the backpressure of the downstream consumer. ThePublisher returned by the handler function is expected to honor backpressure as well.repeatWhen does not operate by default on a particularScheduler.handler - the function that is called with a Flowable that signals a value when the Single signalled a success value and returns a Publisher that has to signal a value to trigger a resubscription to the current Single, otherwise the terminal signal of the Publisher will be the terminal signal of the sequence as well.@BackpressureSupport(value=FULL)@CheckReturnValue@SchedulerSupport(value="none")public final Flowable<T> repeatUntil(BooleanSupplier stop)

Flowable honors the backpressure of the downstream consumer.repeatUntil does not operate by default on a particularScheduler.stop - the BooleanSupplier called after the current Single succeeds and if returns false, the Single is re-subscribed; otherwise the sequence completes.@CheckReturnValue@SchedulerSupport(value="none")public final Single<T> retry()

retry does not operate by default on a particularScheduler.@CheckReturnValue@SchedulerSupport(value="none")public final Single<T> retry(long times)

retry does not operate by default on a particularScheduler.times - the number of times to resubscribe if the current Single fails@CheckReturnValue@SchedulerSupport(value="none")public final Single<T> retry(BiPredicate<? superInteger,? superThrowable> predicate)

retry does not operate by default on a particularScheduler.predicate - the predicate called with the resubscription count and the failure Throwable and should return true if a resubscription should happen@CheckReturnValue@SchedulerSupport(value="none")public final Single<T> retry(long times,Predicate<? superThrowable> predicate)

retry does not operate by default on a particularScheduler.History: 2.1.8 - experimental
times - the number of times to resubscribe if the current Single failspredicate - the predicate called with the failure Throwable and should return true if a resubscription should happen@CheckReturnValue@SchedulerSupport(value="none")public final Single<T> retry(Predicate<? superThrowable> predicate)

retry does not operate by default on a particularScheduler.predicate - the predicate called with the failure Throwable and should return true if a resubscription should happen@CheckReturnValue@SchedulerSupport(value="none")public final Single<T> retryWhen(Function<? superFlowable<Throwable>,? extendsPublisher<?>> handler)

If the Publisher signals an onComplete, the resulting Single will signal a NoSuchElementException.
Note that the innerPublisher returned by the handler function should signal eitheronNext,onError oronComplete in response to the receivedThrowable 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 innerPublisher signalsonError oronComplete while the upstream is active, the sequence is terminated with the same signal immediately.
The following example demonstrates how to retry an asynchronous source with a delay:
Single.timer(1, TimeUnit.SECONDS) .doOnSubscribe(s -> System.out.println("subscribing")) .map(v -> { throw new RuntimeException(); }) .retryWhen(errors -> { AtomicInteger counter = new AtomicInteger(); return errors .takeWhile(e -> counter.getAndIncrement() != 3) .flatMap(e -> { System.out.println("delay retry by " + counter.get() + " second(s)"); return Flowable.timer(counter.get(), TimeUnit.SECONDS); }); }) .blockingGet();retryWhen does not operate by default on a particularScheduler.handler - the function that receives a Flowable of the error the Single emits and should return a Publisher that should signal a normal value (in response to the throwable the Flowable emits) to trigger a resubscription or signal an error to be the output of the resulting Single@SchedulerSupport(value="none")public final Disposable subscribe()

If the Single emits an error, it is wrapped into anOnErrorNotImplementedException and routed to the RxJavaPlugins.onError handler.
subscribe does not operate by default on a particularScheduler.Disposable reference can request theSingle stop work.@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final Disposable subscribe(BiConsumer<? superT,? superThrowable> onCallback)

subscribe does not operate by default on a particularScheduler.onCallback - the callback that receives either the success value or the failure Throwable (whichever is not null)Disposable reference can request theSingle stop work.NullPointerException - ifonCallback is null@CheckReturnValue@SchedulerSupport(value="none")public final Disposable subscribe(Consumer<? superT> onSuccess)

If the Single emits an error, it is wrapped into anOnErrorNotImplementedException and routed to the RxJavaPlugins.onError handler.
subscribe does not operate by default on a particularScheduler.onSuccess - theConsumer<T> you have designed to accept the emission from the SingleDisposable reference can request theSingle stop work.NullPointerException - ifonSuccess is null@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final Disposable subscribe(Consumer<? superT> onSuccess,Consumer<? superThrowable> onError)

subscribe does not operate by default on a particularScheduler.onSuccess - theConsumer<T> you have designed to accept the emission from the SingleonError - theConsumer<Throwable> you have designed to accept any error notification from the SingleDisposable reference can request theSingle stop work.NullPointerException - ifonSuccess is null, or ifonError is null@SchedulerSupport(value="none")public final void subscribe(SingleObserver<? superT> observer)
SingleSourcesubscribe in interface SingleSource<T>observer - the SingleObserver, not nullprotected abstract void subscribeActual(@NonNullSingleObserver<? superT> observer)
SingleObservers.There is no need to call any of the plugin hooks on the currentSingle instance or theSingleObserver; all hooks and basic safeguards have been applied bysubscribe(SingleObserver) before this method gets called.
observer - the SingleObserver to handle, not null@CheckReturnValue@SchedulerSupport(value="none")public final <E extendsSingleObserver<? superT>> E subscribeWith(E observer)

Usage example:
Single<Integer> source = Single.just(1); CompositeDisposable composite = new CompositeDisposable(); DisposableSingleObserver<Integer> ds = new DisposableSingleObserver<>() { // ... }; composite.add(source.subscribeWith(ds));subscribeWith does not operate by default on a particularScheduler.E - the type of the SingleObserver to use and returnobserver - the SingleObserver (subclass) to use and return, not nullobserverNullPointerException - ifobserver is null@CheckReturnValue@NonNull@SchedulerSupport(value="custom")public final Single<T> subscribeOn(Scheduler scheduler)
Scheduler.
Scheduler this operator will use.scheduler - theScheduler to perform subscription actions onSchedulerobserveOn(io.reactivex.Scheduler)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final Single<T> takeUntil(CompletableSource other)
other, this will emit aCancellationException rather than go toSingleObserver.onSuccess(Object).
takeUntil does not operate by default on a particularScheduler.other - the Completable whose termination will causetakeUntil to emit the item from the source Singleother terminates.@BackpressureSupport(value=FULL)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <E> Single<T> takeUntil(Publisher<E> other)
other, this will emit aCancellationException rather than go toSingleObserver.onSuccess(Object).
other publisher is consumed in an unbounded fashion but will be cancelled after the first item it produced.takeUntil does not operate by default on a particularScheduler.E - the type of items emitted byotherother - the Publisher whose first emitted item will causetakeUntil to emit the item from the source Singleother emits its first item@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <E> Single<T> takeUntil(SingleSource<? extends E> other)
other, this will emit aCancellationException rather than go toSingleObserver.onSuccess(Object).
takeUntil does not operate by default on a particularScheduler.E - the type of item emitted byotherother - the Single whose emitted item will causetakeUntil to emit the item from the source Singleother emits its item@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")public final Single<T> timeout(long timeout,TimeUnit unit)

timeout signals the TimeoutException on thecomputationScheduler.timeout - the timeout amountunit - the time unit@CheckReturnValue@SchedulerSupport(value="custom")public final Single<T> timeout(long timeout,TimeUnit unit,Scheduler scheduler)

timeout signals the TimeoutException on theScheduler you specify.timeout - the timeout amountunit - the time unitscheduler - the target scheduler where the timeout is awaited and the TimeoutException signalled@CheckReturnValue@NonNull@SchedulerSupport(value="custom")public final Single<T> timeout(long timeout,TimeUnit unit,Scheduler scheduler,SingleSource<? extendsT> other)

timeout subscribes to the other SingleSource on theScheduler you specify.timeout - the timeout amountunit - the time unitscheduler - the scheduler where the timeout is awaited and the subscription to other happensother - the other SingleSource that gets subscribed to if the current Single times out@CheckReturnValue@NonNull@SchedulerSupport(value="io.reactivex:computation")public final Single<T> timeout(long timeout,TimeUnit unit,SingleSource<? extendsT> other)

timeout subscribes to the other SingleSource on thecomputationScheduler.timeout - the timeout amountunit - the time unitother - the other SingleSource that gets subscribed to if the current Single times outNullPointerException - if other is null, or if unit is null, or if scheduler is null@CheckReturnValue@SchedulerSupport(value="none")public final <R> R to(Function<? superSingle<T>,R> convert)

to does not operate by default on a particularScheduler.R - the result typeconvert - the function that is called with the current Single instance during assembly time that should return some value to be the result@CheckReturnValue@SchedulerSupport(value="none")@Deprecatedpublic final Completable toCompletable()
ignoreElement() instead, will be removed in 3.0Completable that discards result of theSingle and callsonComplete when this sourceSingle callsonSuccess. Error terminal event is propagated.
toCompletable does not operate by default on a particularScheduler.Completable that callsonComplete on it's subscriber when the sourceSingle callsonSuccess.@CheckReturnValue@SchedulerSupport(value="none")public final Completable ignoreElement()
Completable that ignores the success value of thisSingle and callsonComplete instead on the returnedCompletable.
ignoreElement does not operate by default on a particularScheduler.Completable that callsonComplete on it's observer when the sourceSingle callsonSuccess.@BackpressureSupport(value=FULL)@CheckReturnValue@SchedulerSupport(value="none")public final Flowable<T> toFlowable()
Flowable.
Flowable honors the backpressure of the downstream consumer.toFlowable does not operate by default on a particularScheduler.Flowable that emits a single item T or an error.@CheckReturnValue@SchedulerSupport(value="none")public final Future<T> toFuture()
Future representing the single value emitted by thisSingle.
toFuture does not operate by default on a particularScheduler.Future that expects a single item to be emitted by thisSingle@CheckReturnValue@SchedulerSupport(value="none")public final Maybe<T> toMaybe()
Maybe.
toMaybe does not operate by default on a particularScheduler.Maybe that emits a single item T or an error.@CheckReturnValue@SchedulerSupport(value="none")public final Observable<T> toObservable()
Observable.
toObservable does not operate by default on a particularScheduler.Observable that emits a single item T or an error.@CheckReturnValue@NonNull@SchedulerSupport(value="custom")public final Single<T> unsubscribeOn(Scheduler scheduler)

unsubscribeOn calls dispose() of the upstream on theScheduler you specify.History: 2.0.9 - experimental
scheduler - the target scheduler where to execute the disposalNullPointerException - if scheduler is null@CheckReturnValue@SchedulerSupport(value="none")public final <U,R> Single<R> zipWith(SingleSource<U> other,BiFunction<? superT,? super U,? extends R> zipper)

zipWith does not operate by default on a particularScheduler.U - the type of items emitted by theother SingleR - the type of items emitted by the resulting Singleother - the other SingleSourcezipper - a function that combines the pairs of items from the two SingleSources to generate the items to be emitted by the resulting Singleother SingleSource and emits the results ofzipFunction applied to these pairs@CheckReturnValue@SchedulerSupport(value="none")public final TestObserver<T> test()

test does not operate by default on a particularScheduler.@CheckReturnValue@SchedulerSupport(value="none")public final TestObserver<T> test(boolean cancelled)

test does not operate by default on a particularScheduler.cancelled - if true, the TestObserver will be cancelled before subscribing to this Single.