KEMBAR78
Single (RxJava Javadoc 2.0.8)
io.reactivex

Class Single<T>

  • Type Parameters:
    T - the type of the item emitted by the Single
    All Implemented Interfaces:
    SingleSource<T>
    Direct Known Subclasses:
    SingleSubject


    public abstract class Single<T>
    extends java.lang.Object
    implements SingleSource<T>
    The Single class implements the Reactive Pattern for a single value response. See Flowable or Observable for the implementation of the Reactive Pattern for a stream or vector of values.

    Single behaves the same as Observable except that it can only emit either a single successful value, or an error (there is no "onComplete" notification as there is for Observable)

    Like an Observable, a Single is lazy, can be either "hot" or "cold", synchronous or asynchronous.

    The documentation for this class makes use of marble diagrams. The following legend explains these diagrams:

    For more information see the ReactiveX documentation.

    Since:
    2.0
    • Constructor Summary

      Constructors 
      Constructor and Description
      Single() 
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      static <T> Single<T> amb(java.lang.Iterable<? extends SingleSource<? extends T>> sources)
      Runs multiple Single sources and signals the events of the first one that signals (cancelling the rest).
      static <T> Single<T> ambArray(SingleSource<? extends T>... sources)
      Runs multiple Single sources and signals the events of the first one that signals (cancelling the rest).
      Single<T> ambWith(SingleSource<? extends T> other)
      Signals the event of this or the other SingleSource whichever signals first.
      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(java.lang.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<? super T,? extends R> transformer)
      Transform a Single by applying a particular Transformer function to it.
      static <T> Flowable<T> concat(java.lang.Iterable<? extends SingleSource<? extends T>> sources)
      Concatenate the single values, in a non-overlapping fashion, of the Single sources provided by an Iterable sequence.
      static <T> Observable<T> concat(ObservableSource<? extends SingleSource<? extends T>> sources)
      Concatenate the single values, in a non-overlapping fashion, of the Single sources provided by an Observable sequence.
      static <T> Flowable<T> concat(org.reactivestreams.Publisher<? extends SingleSource<? extends T>> sources)
      Concatenate the single values, in a non-overlapping fashion, of the Single sources provided by a Publisher sequence.
      static <T> Flowable<T> concat(org.reactivestreams.Publisher<? extends SingleSource<? extends T>> sources, int prefetch)
      Concatenate the single values, in a non-overlapping fashion, of the Single sources 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 Single sources provided in an array.
      Flowable<T> concatWith(SingleSource<? extends T> other)
      Returns a Flowable that emits the item emitted by the source Single, then the item emitted by the specified Single.
      Single<java.lang.Boolean> contains(java.lang.Object value)
      Signals true if the current Single signals a success value that is Object-equals with the value provided.
      Single<java.lang.Boolean> contains(java.lang.Object value, BiPredicate<java.lang.Object,java.lang.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 Completable) that bridges the reactive world with the callback-style world.
      static <T> Single<T> defer(java.util.concurrent.Callable<? extends SingleSource<? extends T>> singleSupplier)
      Calls a Callable for each individual SingleObserver to return the actual Single source to be subscribed to.
      Single<T> delay(long time, java.util.concurrent.TimeUnit unit)
      Delays the emission of the success or error signal from the current Single by the specified amount.
      Single<T> delay(long time, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
      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.
      <U> Single<T> delaySubscription(long time, java.util.concurrent.TimeUnit unit)
      Delays the actual subscription to the current Single until the given time delay elapsed.
      <U> Single<T> delaySubscription(long time, java.util.concurrent.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(org.reactivestreams.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.
      Single<T> doAfterSuccess(Consumer<? super T> 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 runnable if a SingleObserver subscribed to the current Single disposes the common Disposable it received via onSubscribe.
      Single<T> doOnError(Consumer<? super java.lang.Throwable> onError)
      Calls the shared consumer with the error sent via onError for each SingleObserver that subscribes to the current Single.
      Single<T> doOnEvent(BiConsumer<? super T,? super java.lang.Throwable> 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<? super Disposable> 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<? super T> onSuccess)
      Calls the shared consumer with the success value sent via onSuccess for each SingleObserver that subscribes to the current Single.
      static <T> Single<java.lang.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(java.util.concurrent.Callable<? extends java.lang.Throwable> errorSupplier)
      Signals a Throwable returned by the callback function for each individual SingleObserver.
      static <T> Single<T> error(java.lang.Throwable exception)
      Returns a Single that invokes a subscriber's onError method when the subscriber subscribes to it.
      Maybe<T> filter(Predicate<? super T> 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<? super T,? extends SingleSource<? 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<? super T,? extends CompletableSource> mapper)
      Returns a Completable that completes based on applying a specified function to the item emitted by the source Single, where that function returns a Completable.
      <R> Maybe<R> flatMapMaybe(Function<? super T,? extends MaybeSource<? 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<? super T,? extends ObservableSource<? 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 a SingleSource.
      <R> Flowable<R> flatMapPublisher(Function<? super T,? extends org.reactivestreams.Publisher<? 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<? super T,? extends java.lang.Iterable<? extends U>> mapper)
      Returns a Flowable that merges each item emitted by the source Single with the values in an Iterable corresponding to that item that is generated by a selector.
      <U> Observable<U> flattenAsObservable(Function<? super T,? extends java.lang.Iterable<? extends U>> mapper)
      Returns an Observable that maps a success value into an Iterable and emits its items.
      static <T> Single<T> fromCallable(java.util.concurrent.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(java.util.concurrent.Future<? extends T> future)
      Converts a Future into a Single.
      static <T> Single<T> fromFuture(java.util.concurrent.Future<? extends T> future, long timeout, java.util.concurrent.TimeUnit unit)
      Converts a Future into a Single, with a timeout on the Future.
      static <T> Single<T> fromFuture(java.util.concurrent.Future<? extends T> future, long timeout, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
      Converts a Future into a Single, with a timeout on the Future.
      static <T> Single<T> fromFuture(java.util.concurrent.Future<? extends T> future, Scheduler scheduler)
      Converts a Future, operating on a specified Scheduler, into a Single.
      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(org.reactivestreams.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().
      static <T> Single<T> just(T item)
      Returns a Single that emits a specified item.
      <R> Single<R> lift(SingleOperator<? extends R,? super T> lift)
      Lifts a function to the current Single and returns a new Single that when subscribed to will pass the values of the current Single through the Operator function.
      <R> Single<R> map(Function<? super T,? 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.
      static <T> Flowable<T> merge(java.lang.Iterable<? extends SingleSource<? 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(org.reactivestreams.Publisher<? extends SingleSource<? 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<? extends SingleSource<? extends T>> source)
      Flattens a Single that emits a Single into a single Single that emits the item emitted by the nested Single, 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.
      Flowable<T> mergeWith(SingleSource<? extends T> 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<? super java.lang.Throwable,? extends SingleSource<? extends T>> 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<? extends T> 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<java.lang.Throwable,? extends T> 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.
      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<? super Flowable<java.lang.Object>,? extends org.reactivestreams.Publisher<?>> 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<? super java.lang.Integer,? super java.lang.Throwable> 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(Predicate<? super java.lang.Throwable> predicate)
      Re-subscribe to the current Single if the given predicate returns true when the Single fails with an onError.
      Single<T> retryWhen(Function<? super Flowable<java.lang.Throwable>,? extends org.reactivestreams.Publisher<?>> 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<? super T,? super java.lang.Throwable> 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<? super T> onSuccess)
      Subscribes to a Single and provides a callback to handle the item it emits.
      Disposable subscribe(Consumer<? super T> onSuccess, Consumer<? super java.lang.Throwable> onError)
      Subscribes to a Single and provides callbacks to handle the item it emits or any error notification it issues.
      void subscribe(SingleObserver<? super T> subscriber)
      Subscribes the given SingleObserver to this SingleSource instance.
      protected abstract void subscribeActual(SingleObserver<? super T> observer)
      Override 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 extends SingleObserver<? super T>> 
      E
      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(org.reactivestreams.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, java.util.concurrent.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, java.util.concurrent.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, java.util.concurrent.TimeUnit unit, Scheduler scheduler, SingleSource<? extends T> other)
      Runs the current Single and if it doesn't signal within the specified timeout window, it is cancelled and the other SingleSource subscribed to.
      Single<T> timeout(long timeout, java.util.concurrent.TimeUnit unit, SingleSource<? extends T> other)
      Runs the current Single and if it doesn't signal within the specified timeout window, it is cancelled and the other SingleSource subscribed to.
      static Single<java.lang.Long> timer(long delay, java.util.concurrent.TimeUnit unit)
      Signals success with 0L value after the given delay for each SingleObserver.
      static Single<java.lang.Long> timer(long delay, java.util.concurrent.TimeUnit unit, Scheduler scheduler)
      Signals success with 0L value after the given delay for each SingleObserver.
      <R> R to(Function<? super Single<T>,R> convert)
      Calls the specified converter function with the current Single instance during assembly time and returns its result.
      Completable toCompletable()
      Returns a Completable that discards result of the Single and calls onComplete when this source Single calls onSuccess.
      Flowable<T> toFlowable()
      Converts this Single into a Flowable.
      java.util.concurrent.Future<T> toFuture()
      Returns a Future representing the single value emitted by this Single.
      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.
      static <T,U> Single<T> using(java.util.concurrent.Callable<U> resourceSupplier, Function<? super U,? extends SingleSource<? 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(java.util.concurrent.Callable<U> resourceSupplier, Function<? super U,? extends SingleSource<? 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(java.lang.Iterable<? extends SingleSource<? extends T>> sources, Function<? super java.lang.Object[],? 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> 
      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)
      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> 
      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)
      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> 
      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)
      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> 
      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)
      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> 
      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)
      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> 
      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)
      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> 
      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)
      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<? super java.lang.Object[],? 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<? super T,? 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Single

        public Single()
    • Method Detail

      • amb

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public static <T> Single<T> amb(java.lang.Iterable<? extends SingleSource<? extends T>> sources)
        Runs multiple Single sources and signals the events of the first one that signals (cancelling the rest).
        Scheduler:
        amb does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the value type
        Parameters:
        sources - the Iterable sequence of sources. A subscription to each source will occur in the same order as in this Iterable.
        Returns:
        the new Single instance
        Since:
        2.0
      • ambArray

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public static <T> Single<T> ambArray(SingleSource<? extends T>... sources)
        Runs multiple Single sources and signals the events of the first one that signals (cancelling the rest).
        Scheduler:
        ambArray does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the value type
        Parameters:
        sources - the array of sources. A subscription to each source will occur in the same order as in this array.
        Returns:
        the new Single instance
        Since:
        2.0
      • concat

        @CheckReturnValue
        @SchedulerSupport(value="none")
        @BackpressureSupport(value=FULL)
        public static <T> Flowable<T> concat(java.lang.Iterable<? extends SingleSource<? extends T>> sources)
        Concatenate the single values, in a non-overlapping fashion, of the Single sources provided by an Iterable sequence.
        Backpressure:
        The returned Flowable honors the backpressure of the downstream consumer.
        Scheduler:
        concat does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the value type
        Parameters:
        sources - the Iterable sequence of SingleSource instances
        Returns:
        the new Flowable instance
        Since:
        2.0
      • concat

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public static <T> Observable<T> concat(ObservableSource<? extends SingleSource<? extends T>> sources)
        Concatenate the single values, in a non-overlapping fashion, of the Single sources provided by an Observable sequence.
        Scheduler:
        concat does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the value type
        Parameters:
        sources - the ObservableSource of SingleSource instances
        Returns:
        the new Observable instance
        Since:
        2.0
      • concat

        @CheckReturnValue
        @BackpressureSupport(value=FULL)
        @SchedulerSupport(value="none")
        public static <T> Flowable<T> concat(org.reactivestreams.Publisher<? extends SingleSource<? extends T>> sources)
        Concatenate the single values, in a non-overlapping fashion, of the Single sources provided by a Publisher sequence.
        Backpressure:
        The returned Flowable honors the backpressure of the downstream consumer and the sources Publisher is expected to honor it as well.
        Scheduler:
        concat does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the value type
        Parameters:
        sources - the Publisher of SingleSource instances
        Returns:
        the new Flowable instance
        Since:
        2.0
      • concat

        @CheckReturnValue
        @BackpressureSupport(value=FULL)
        @SchedulerSupport(value="none")
        public static <T> Flowable<T> concat(org.reactivestreams.Publisher<? extends SingleSource<? extends T>> sources,
                                                                                                 int prefetch)
        Concatenate the single values, in a non-overlapping fashion, of the Single sources provided by a Publisher sequence and prefetched by the specified amount.
        Backpressure:
        The returned Flowable honors the backpressure of the downstream consumer and the sources Publisher is expected to honor it as well.
        Scheduler:
        concat does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the value type
        Parameters:
        sources - the Publisher of SingleSource instances
        prefetch - the number of SingleSources to prefetch from the Publisher
        Returns:
        the new Flowable instance
        Since:
        2.0
      • concatArray

        @CheckReturnValue
        @BackpressureSupport(value=FULL)
        @SchedulerSupport(value="none")
        public static <T> Flowable<T> concatArray(SingleSource<? extends T>... sources)
        Concatenate the single values, in a non-overlapping fashion, of the Single sources provided in an array.
        Backpressure:
        The returned Flowable honors the backpressure of the downstream consumer.
        Scheduler:
        concatArray does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the value type
        Parameters:
        sources - the array of SingleSource instances
        Returns:
        the new Flowable instance
        Since:
        2.0
      • create

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public static <T> Single<T> create(SingleOnSubscribe<T> source)
        Provides an API (via a cold Completable) that bridges the reactive world with the callback-style world.

        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);
        
         });
         

        Scheduler:
        create does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the value type
        Parameters:
        source - the emitter that is called when a SingleObserver subscribes to the returned Single
        Returns:
        the new Single instance
        See Also:
        SingleOnSubscribe, Cancellable
      • defer

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public static <T> Single<T> defer(java.util.concurrent.Callable<? extends SingleSource<? extends T>> singleSupplier)
        Calls a Callable for each individual SingleObserver to return the actual Single source to be subscribed to.
        Scheduler:
        defer does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the value type
        Parameters:
        singleSupplier - the Callable that is called for each individual SingleObserver and returns a SingleSource instance to subscribe to
        Returns:
        the new Single instance
      • error

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public static <T> Single<T> error(java.util.concurrent.Callable<? extends java.lang.Throwable> errorSupplier)
        Signals a Throwable returned by the callback function for each individual SingleObserver.
        Scheduler:
        error does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the value type
        Parameters:
        errorSupplier - the callable that is called for each individual SingleObserver and returns a Throwable instance to be emitted.
        Returns:
        the new Single instance
      • error

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public static <T> Single<T> error(java.lang.Throwable exception)
        Returns a Single that invokes a subscriber's onError method when the subscriber subscribes to it.

        Scheduler:
        error does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the type of the item (ostensibly) emitted by the Single
        Parameters:
        exception - the particular Throwable to pass to onError
        Returns:
        a Single that invokes the subscriber's onError method when the subscriber subscribes to it
        See Also:
        ReactiveX operators documentation: Throw
      • fromCallable

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public static <T> Single<T> fromCallable(java.util.concurrent.Callable<? extends T> callable)
        Returns a 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 the Single. It makes passed function "lazy". Result of the function invocation will be emitted by the Single.

        Scheduler:
        fromCallable does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the type of the item emitted by the Single.
        Parameters:
        callable - function which execution should be deferred, it will be invoked when SingleObserver will subscribe to the Single.
        Returns:
        a Single whose SingleObservers' subscriptions trigger an invocation of the given function.
      • fromFuture

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public static <T> Single<T> fromFuture(java.util.concurrent.Future<? extends T> future)
        Converts a Future into a Single.

        You can convert any object that supports the Future interface into a Single that emits the return value of the Future.get() method of that object, by passing the object into the from method.

        Important note: This Single is blocking; you cannot dispose it.

        Scheduler:
        fromFuture does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the type of object that the Future returns, and also the type of item to be emitted by the resulting Single
        Parameters:
        future - the source Future
        Returns:
        a Single that emits the item from the source Future
        See Also:
        ReactiveX operators documentation: From
      • fromFuture

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public static <T> Single<T> fromFuture(java.util.concurrent.Future<? extends T> future,
                                                                      long timeout,
                                                                      java.util.concurrent.TimeUnit unit)
        Converts a Future into a Single, with a timeout on the Future.

        You can convert any object that supports the Future interface into a Single that emits the return value of the Future.get() method of that object, by passing the object into the from method.

        Important note: This Single is blocking; you cannot dispose it.

        Scheduler:
        fromFuture does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the type of object that the Future returns, and also the type of item to be emitted by the resulting Single
        Parameters:
        future - the source Future
        timeout - the maximum time to wait before calling get
        unit - the TimeUnit of the timeout argument
        Returns:
        a Single that emits the item from the source Future
        See Also:
        ReactiveX operators documentation: From
      • fromFuture

        @CheckReturnValue
        @SchedulerSupport(value="custom")
        public static <T> Single<T> fromFuture(java.util.concurrent.Future<? extends T> future,
                                                                      long timeout,
                                                                      java.util.concurrent.TimeUnit unit,
                                                                      Scheduler scheduler)
        Converts a Future into a Single, with a timeout on the Future.

        You can convert any object that supports the Future interface into a Single that emits the return value of the Future.get() method of that object, by passing the object into the from method.

        Important note: This Single is blocking; you cannot dispose it.

        Scheduler:
        You specify the Scheduler where the blocking wait will happen.
        Type Parameters:
        T - the type of object that the Future returns, and also the type of item to be emitted by the resulting Single
        Parameters:
        future - the source Future
        timeout - the maximum time to wait before calling get
        unit - the TimeUnit of the timeout argument
        scheduler - the Scheduler to use for the blocking wait
        Returns:
        a Single that emits the item from the source Future
        See Also:
        ReactiveX operators documentation: From
      • fromFuture

        @CheckReturnValue
        @SchedulerSupport(value="custom")
        public static <T> Single<T> fromFuture(java.util.concurrent.Future<? extends T> future,
                                                                      Scheduler scheduler)
        Converts a Future, operating on a specified Scheduler, into a Single.

        You can convert any object that supports the Future interface into a Single that emits the return value of the Future.get() method of that object, by passing the object into the from method.

        Scheduler:
        You specify which Scheduler this operator will use
        Type Parameters:
        T - the type of object that the Future returns, and also the type of item to be emitted by the resulting Single
        Parameters:
        future - the source Future
        scheduler - the Scheduler to wait for the Future on. Use a Scheduler such as Schedulers.io() that can block and wait on the Future
        Returns:
        a Single that emits the item from the source Future
        See Also:
        ReactiveX operators documentation: From
      • fromPublisher

        @BackpressureSupport(value=UNBOUNDED_IN)
        @CheckReturnValue
        @SchedulerSupport(value="none")
        public static <T> Single<T> fromPublisher(org.reactivestreams.Publisher<? extends T> publisher)
        Wraps a specific Publisher into a Single and signals its single element or error.

        If the source Publisher is empty, a NoSuchElementException is signalled. If the source has more than one element, an IndexOutOfBoundsException is signalled.

        Backpressure:
        The publisher is consumed in an unbounded fashion but will be cancelled if it produced more than one item.
        Scheduler:
        fromPublisher does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the value type
        Parameters:
        publisher - the source Publisher instance, not null
        Returns:
        the new Single instance
      • fromObservable

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public static <T> Single<T> fromObservable(ObservableSource<? extends T> observableSource)
        Wraps a specific ObservableSource into a Single and signals its single element or error.

        If the ObservableSource is empty, a NoSuchElementException is signalled. If the source has more than one element, an IndexOutOfBoundsException is signalled.

        Scheduler:
        fromObservable does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the type of the item emitted by the Single.
        Parameters:
        observableSource - the source Observable, not null
        Returns:
        the new Single instance
      • just

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public static <T> Single<T> just(T item)
        Returns a Single that emits a specified item.

        To convert any object into a Single that emits that object, pass that object into the just method.

        Scheduler:
        just does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the type of that item
        Parameters:
        item - the item to emit
        Returns:
        a Single that emits item
        See Also:
        ReactiveX operators documentation: Just
      • merge

        @CheckReturnValue
        @BackpressureSupport(value=FULL)
        @SchedulerSupport(value="none")
        public static <T> Flowable<T> merge(java.lang.Iterable<? extends SingleSource<? extends T>> sources)
        Merges an Iterable sequence of SingleSource instances into a single Flowable sequence, running all SingleSources at once.
        Backpressure:
        The returned Flowable honors the backpressure of the downstream consumer.
        Scheduler:
        merge does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the common and resulting value type
        Parameters:
        sources - the Iterable sequence of SingleSource sources
        Returns:
        the new Flowable instance
        Since:
        2.0
      • merge

        @CheckReturnValue
        @BackpressureSupport(value=FULL)
        @SchedulerSupport(value="none")
        public static <T> Flowable<T> merge(org.reactivestreams.Publisher<? extends SingleSource<? extends T>> sources)
        Merges a Flowable sequence of SingleSource instances into a single Flowable sequence, running all SingleSources at once.
        Backpressure:
        The returned Flowable honors the backpressure of the downstream consumer.
        Scheduler:
        merge does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the common and resulting value type
        Parameters:
        sources - the Flowable sequence of SingleSource sources
        Returns:
        the new Flowable instance
        Since:
        2.0
      • merge

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public static <T> Single<T> merge(SingleSource<? extends SingleSource<? extends T>> source)
        Flattens a Single that emits a Single into a single Single that emits the item emitted by the nested Single, without any transformation.

        Scheduler:
        merge does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the value type of the sources and the output
        Parameters:
        source - a Single that emits a Single
        Returns:
        a Single that emits the item that is the result of flattening the Single emitted by source
        See Also:
        ReactiveX operators documentation: Merge
      • merge

        @CheckReturnValue
        @BackpressureSupport(value=FULL)
        @SchedulerSupport(value="none")
        public static <T> Flowable<T> merge(SingleSource<? extends T> source1,
                                                                                                SingleSource<? extends T> source2)
        Flattens two Singles into a single Flowable, without any transformation.

        You can combine items emitted by multiple Singles so that they appear as a single Flowable, by using the merge method.

        Backpressure:
        The returned Flowable honors the backpressure of the downstream consumer.
        Scheduler:
        merge does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the common value type
        Parameters:
        source1 - a Single to be merged
        source2 - a Single to be merged
        Returns:
        a Flowable that emits all of the items emitted by the source Singles
        See Also:
        ReactiveX operators documentation: Merge
      • merge

        @CheckReturnValue
        @BackpressureSupport(value=FULL)
        @SchedulerSupport(value="none")
        public 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.

        You can combine items emitted by multiple Singles so that they appear as a single Flowable, by using the merge method.

        Backpressure:
        The returned Flowable honors the backpressure of the downstream consumer.
        Scheduler:
        merge does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the common value type
        Parameters:
        source1 - a Single to be merged
        source2 - a Single to be merged
        source3 - a Single to be merged
        Returns:
        a Flowable that emits all of the items emitted by the source Singles
        See Also:
        ReactiveX operators documentation: Merge
      • merge

        @CheckReturnValue
        @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)
        Flattens four Singles into a single Flowable, without any transformation.

        You can combine items emitted by multiple Singles so that they appear as a single Flowable, by using the merge method.

        Backpressure:
        The returned Flowable honors the backpressure of the downstream consumer.
        Scheduler:
        merge does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the common value type
        Parameters:
        source1 - a Single to be merged
        source2 - a Single to be merged
        source3 - a Single to be merged
        source4 - a Single to be merged
        Returns:
        a Flowable that emits all of the items emitted by the source Singles
        See Also:
        ReactiveX operators documentation: Merge
      • never

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public static <T> Single<T> never()
        Returns a singleton instance of a never-signalling Single (only calls onSubscribe).
        Scheduler:
        never does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the target value type
        Returns:
        the singleton never instance
        Since:
        2.0
      • timer

        @CheckReturnValue
        @SchedulerSupport(value="io.reactivex:computation")
        public static Single<java.lang.Long> timer(long delay,
                                                                          java.util.concurrent.TimeUnit unit)
        Signals success with 0L value after the given delay for each SingleObserver.
        Scheduler:
        timer operates by default on the computation Scheduler.
        Parameters:
        delay - the delay amount
        unit - the time unit of the delay
        Returns:
        the new Single instance
        Since:
        2.0
      • timer

        @CheckReturnValue
        @SchedulerSupport(value="custom")
        public static Single<java.lang.Long> timer(long delay,
                                                                          java.util.concurrent.TimeUnit unit,
                                                                          Scheduler scheduler)
        Signals success with 0L value after the given delay for each SingleObserver.
        Scheduler:
        you specify the Scheduler to signal on.
        Parameters:
        delay - the delay amount
        unit - the time unit of the delay
        scheduler - the scheduler where the single 0L will be emitted
        Returns:
        the new Single instance
        Since:
        2.0
      • equals

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public static <T> Single<java.lang.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).
        Scheduler:
        equals does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the common value type
        Parameters:
        first - the first SingleSource instance
        second - the second SingleSource instance
        Returns:
        the new Single instance
        Since:
        2.0
      • unsafeCreate

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public 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.
        Scheduler:
        unsafeCreate does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the value type
        Parameters:
        onSubscribe - the function that is called with the subscribing SingleObserver
        Returns:
        the new Single instance
        Throws:
        java.lang.IllegalArgumentException - if source is a subclass of Single; such instances don't need conversion and is possibly a port remnant from 1.x or one should use hide() instead.
        Since:
        2.0
      • using

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public static <T,U> Single<T> using(java.util.concurrent.Callable<U> resourceSupplier,
                                                                   Function<? super U,? extends SingleSource<? 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).
        Scheduler:
        using does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the value type of the SingleSource generated
        U - the resource type
        Parameters:
        resourceSupplier - the Callable called for each SingleObserver to generate a resource Object
        singleFunction - the function called with the returned resource Object from resourceSupplier and should return a SingleSource instance to be run by the operator
        disposer - 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 cancelled.
        Returns:
        the new Single instance
        Since:
        2.0
      • using

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public static <T,U> Single<T> using(java.util.concurrent.Callable<U> resourceSupplier,
                                                                   Function<? super U,? extends SingleSource<? 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).
        Scheduler:
        using does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the value type of the SingleSource generated
        U - the resource type
        Parameters:
        resourceSupplier - the Callable called for each SingleObserver to generate a resource Object
        singleFunction - the function called with the returned resource Object from resourceSupplier and should return a SingleSource instance to be run by the operator
        disposer - 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 cancelled.
        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
        Returns:
        the new Single instance
        Since:
        2.0
      • wrap

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public static <T> Single<T> wrap(SingleSource<T> source)
        Wraps a SingleSource instance into a new Single instance if not already a Single instance.
        Scheduler:
        wrap does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the value type
        Parameters:
        source - the source to wrap
        Returns:
        the Single wrapper or the source cast to Single (if possible)
      • zip

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public static <T,R> Single<R> zip(java.lang.Iterable<? extends SingleSource<? extends T>> sources,
                                                                 Function<? super java.lang.Object[],? 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.

        Note on method signature: since Java doesn't allow creating a generic array with new T[], the implementation of this operator has to create an Object[] instead. Unfortunately, a Function<Integer[], R> passed to the method would trigger a ClassCastException.

        If any of the SingleSources signal an error, all other SingleSources get cancelled and the error emitted to downstream immediately.

        Scheduler:
        zip does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the common value type
        R - the result value type
        Parameters:
        sources - the Iterable sequence of SingleSource instances
        zipper - the function that receives an array with values from each SingleSource and should return a value to be emitted to downstream
        Returns:
        the new Single instance
        Since:
        2.0
      • zip

        @CheckReturnValue
        @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)
        Returns a Single that emits the results of a specified combiner function applied to two items emitted by two other Singles.

        Scheduler:
        zip does not operate by default on a particular Scheduler.
        Type Parameters:
        T1 - the first source Single's value type
        T2 - the second source Single's value type
        R - the result value type
        Parameters:
        source1 - the first source Single
        source2 - a second source Single
        zipper - 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
        Returns:
        a Single that emits the zipped results
        See Also:
        ReactiveX operators documentation: Zip
      • zip

        @CheckReturnValue
        @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)
        Returns a Single that emits the results of a specified combiner function applied to three items emitted by three other Singles.

        Scheduler:
        zip does not operate by default on a particular Scheduler.
        Type Parameters:
        T1 - the first source Single's value type
        T2 - the second source Single's value type
        T3 - the third source Single's value type
        R - the result value type
        Parameters:
        source1 - the first source Single
        source2 - a second source Single
        source3 - a third source Single
        zipper - 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
        Returns:
        a Single that emits the zipped results
        See Also:
        ReactiveX operators documentation: Zip
      • zip

        @CheckReturnValue
        @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)
        Returns a Single that emits the results of a specified combiner function applied to four items emitted by four other Singles.

        Scheduler:
        zip does not operate by default on a particular Scheduler.
        Type Parameters:
        T1 - the first source Single's value type
        T2 - the second source Single's value type
        T3 - the third source Single's value type
        T4 - the fourth source Single's value type
        R - the result value type
        Parameters:
        source1 - the first source Single
        source2 - a second source Single
        source3 - a third source Single
        source4 - a fourth source Single
        zipper - 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
        Returns:
        a Single that emits the zipped results
        See Also:
        ReactiveX operators documentation: Zip
      • zip

        @CheckReturnValue
        @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)
        Returns a Single that emits the results of a specified combiner function applied to five items emitted by five other Singles.

        Scheduler:
        zip does not operate by default on a particular Scheduler.
        Type Parameters:
        T1 - the first source Single's value type
        T2 - the second source Single's value type
        T3 - the third source Single's value type
        T4 - the fourth source Single's value type
        T5 - the fifth source Single's value type
        R - the result value type
        Parameters:
        source1 - the first source Single
        source2 - a second source Single
        source3 - a third source Single
        source4 - a fourth source Single
        source5 - a fifth source Single
        zipper - 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
        Returns:
        a Single that emits the zipped results
        See Also:
        ReactiveX operators documentation: Zip
      • zip

        @CheckReturnValue
        @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)
        Returns a Single that emits the results of a specified combiner function applied to six items emitted by six other Singles.

        Scheduler:
        zip does not operate by default on a particular Scheduler.
        Type Parameters:
        T1 - the first source Single's value type
        T2 - the second source Single's value type
        T3 - the third source Single's value type
        T4 - the fourth source Single's value type
        T5 - the fifth source Single's value type
        T6 - the sixth source Single's value type
        R - the result value type
        Parameters:
        source1 - the first source Single
        source2 - a second source Single
        source3 - a third source Single
        source4 - a fourth source Single
        source5 - a fifth source Single
        source6 - a sixth source Single
        zipper - 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
        Returns:
        a Single that emits the zipped results
        See Also:
        ReactiveX operators documentation: Zip
      • zip

        @CheckReturnValue
        @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)
        Returns a Single that emits the results of a specified combiner function applied to seven items emitted by seven other Singles.

        Scheduler:
        zip does not operate by default on a particular Scheduler.
        Type Parameters:
        T1 - the first source Single's value type
        T2 - the second source Single's value type
        T3 - the third source Single's value type
        T4 - the fourth source Single's value type
        T5 - the fifth source Single's value type
        T6 - the sixth source Single's value type
        T7 - the seventh source Single's value type
        R - the result value type
        Parameters:
        source1 - the first source Single
        source2 - a second source Single
        source3 - a third source Single
        source4 - a fourth source Single
        source5 - a fifth source Single
        source6 - a sixth source Single
        source7 - a seventh source Single
        zipper - 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
        Returns:
        a Single that emits the zipped results
        See Also:
        ReactiveX operators documentation: Zip
      • zip

        @CheckReturnValue
        @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)
        Returns a Single that emits the results of a specified combiner function applied to eight items emitted by eight other Singles.

        Scheduler:
        zip does not operate by default on a particular Scheduler.
        Type Parameters:
        T1 - the first source Single's value type
        T2 - the second source Single's value type
        T3 - the third source Single's value type
        T4 - the fourth source Single's value type
        T5 - the fifth source Single's value type
        T6 - the sixth source Single's value type
        T7 - the seventh source Single's value type
        T8 - the eighth source Single's value type
        R - the result value type
        Parameters:
        source1 - the first source Single
        source2 - a second source Single
        source3 - a third source Single
        source4 - a fourth source Single
        source5 - a fifth source Single
        source6 - a sixth source Single
        source7 - a seventh source Single
        source8 - an eighth source Single
        zipper - 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
        Returns:
        a Single that emits the zipped results
        See Also:
        ReactiveX operators documentation: Zip
      • zip

        @CheckReturnValue
        @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)
        Returns a Single that emits the results of a specified combiner function applied to nine items emitted by nine other Singles.

        Scheduler:
        zip does not operate by default on a particular Scheduler.
        Type Parameters:
        T1 - the first source Single's value type
        T2 - the second source Single's value type
        T3 - the third source Single's value type
        T4 - the fourth source Single's value type
        T5 - the fifth source Single's value type
        T6 - the sixth source Single's value type
        T7 - the seventh source Single's value type
        T8 - the eighth source Single's value type
        T9 - the ninth source Single's value type
        R - the result value type
        Parameters:
        source1 - the first source Single
        source2 - a second source Single
        source3 - a third source Single
        source4 - a fourth source Single
        source5 - a fifth source Single
        source6 - a sixth source Single
        source7 - a seventh source Single
        source8 - an eighth source Single
        source9 - a ninth source Single
        zipper - 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
        Returns:
        a Single that emits the zipped results
        See Also:
        ReactiveX operators documentation: Zip
      • zipArray

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public static <T,R> Single<R> zipArray(Function<? super java.lang.Object[],? 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.

        Note on method signature: since Java doesn't allow creating a generic array with new T[], the implementation of this operator has to create an Object[] instead. Unfortunately, a Function<Integer[], R> passed to the method would trigger a ClassCastException.

        If any of the SingleSources signal an error, all other SingleSources get cancelled and the error emitted to downstream immediately.

        Scheduler:
        zipArray does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the common value type
        R - the result value type
        Parameters:
        sources - the array of SingleSource instances
        zipper - the function that receives an array with values from each SingleSource and should return a value to be emitted to downstream
        Returns:
        the new Single instance
        Since:
        2.0
      • ambWith

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final Single<T> ambWith(SingleSource<? extends T> other)
        Signals the event of this or the other SingleSource whichever signals first.
        Scheduler:
        ambWith does not operate by default on a particular Scheduler.
        Parameters:
        other - the other SingleSource to race for the first emission of success or error
        Returns:
        the new Single instance. A subscription to this provided source will occur after subscribing to the current source.
        Since:
        2.0
      • hide

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final Single<T> hide()
        Hides the identity of the current Single, including the Disposable that is sent to the downstream via onSubscribe().
        Scheduler:
        hide does not operate by default on a particular Scheduler.
        Returns:
        the new Single instance
        Since:
        2.0
      • cache

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final Single<T> cache()
        Stores the success value or exception from the current Single and replays it to late SingleObservers.

        The returned Single subscribes to the current Single when the first SingleObserver subscribes.

        Scheduler:
        cache does not operate by default on a particular Scheduler.
        Returns:
        the new Single instance
        Since:
        2.0
      • cast

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final <U> Single<U> cast(java.lang.Class<? extends U> clazz)
        Casts the success value of the current Single into the target type or signals a ClassCastException if not compatible.
        Scheduler:
        cast does not operate by default on a particular Scheduler.
        Type Parameters:
        U - the target type
        Parameters:
        clazz - the type token to use for casting the success result from the current Single
        Returns:
        the new Single instance
        Since:
        2.0
      • delay

        @CheckReturnValue
        @SchedulerSupport(value="io.reactivex:computation")
        public final Single<T> delay(long time,
                                                             java.util.concurrent.TimeUnit unit)
        Delays the emission of the success or error signal from the current Single by the specified amount.
        Scheduler:
        delay operates by default on the computation Scheduler.
        Parameters:
        time - the time amount to delay the signals
        unit - the time unit
        Returns:
        the new Single instance
        Since:
        2.0
      • delay

        @CheckReturnValue
        @SchedulerSupport(value="custom")
        public final Single<T> delay(long time,
                                                             java.util.concurrent.TimeUnit unit,
                                                             Scheduler scheduler)
        Delays the emission of the success or error signal from the current Single by the specified amount.
        Scheduler:
        you specify the Scheduler where the non-blocking wait and emission happens
        Parameters:
        time - the time amount to delay the signals
        unit - the time unit
        scheduler - the target scheduler to use fro the non-blocking wait and emission
        Returns:
        the new Single instance
        Since:
        2.0
      • delaySubscription

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final Single<T> delaySubscription(CompletableSource other)
        Delays the actual subscription to the current Single until the given other CompletableSource completes.

        If the delaying source signals an error, that error is re-emitted and no subscription to the current Single happens.

        Scheduler:
        delaySubscription does not operate by default on a particular Scheduler.
        Parameters:
        other - the CompletableSource that has to complete before the subscription to the current Single happens
        Returns:
        the new Single instance
        Since:
        2.0
      • delaySubscription

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final <U> Single<T> delaySubscription(SingleSource<U> other)
        Delays the actual subscription to the current Single until the given other SingleSource signals success.

        If the delaying source signals an error, that error is re-emitted and no subscription to the current Single happens.

        Scheduler:
        delaySubscription does not operate by default on a particular Scheduler.
        Type Parameters:
        U - the element type of the other source
        Parameters:
        other - the SingleSource that has to complete before the subscription to the current Single happens
        Returns:
        the new Single instance
        Since:
        2.0
      • delaySubscription

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final <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.

        If the delaying source signals an error, that error is re-emitted and no subscription to the current Single happens.

        Scheduler:
        delaySubscription does not operate by default on a particular Scheduler.
        Type Parameters:
        U - the element type of the other source
        Parameters:
        other - the ObservableSource that has to signal a value or complete before the subscription to the current Single happens
        Returns:
        the new Single instance
        Since:
        2.0
      • delaySubscription

        @BackpressureSupport(value=FULL)
        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final <U> Single<T> delaySubscription(org.reactivestreams.Publisher<U> other)
        Delays the actual subscription to the current Single until the given other Publisher signals its first value or completes.

        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).

        Backpressure:
        The other publisher is consumed in an unbounded fashion but will be cancelled after the first item it produced.
        Scheduler:
        delaySubscription does not operate by default on a particular Scheduler.
        Type Parameters:
        U - the element type of the other source
        Parameters:
        other - the Publisher that has to signal a value or complete before the subscription to the current Single happens
        Returns:
        the new Single instance
        Since:
        2.0
      • delaySubscription

        @CheckReturnValue
        @SchedulerSupport(value="io.reactivex:computation")
        public final <U> Single<T> delaySubscription(long time,
                                                                             java.util.concurrent.TimeUnit unit)
        Delays the actual subscription to the current Single until the given time delay elapsed.
        Scheduler:
        delaySubscription does by default subscribe to the current Single on the computation Scheduler after the delay.
        Type Parameters:
        U - the element type of the other source
        Parameters:
        time - the time amount to wait with the subscription
        unit - the time unit of the waiting
        Returns:
        the new Single instance
        Since:
        2.0
      • delaySubscription

        @CheckReturnValue
        @SchedulerSupport(value="custom")
        public final <U> Single<T> delaySubscription(long time,
                                                                             java.util.concurrent.TimeUnit unit,
                                                                             Scheduler scheduler)
        Delays the actual subscription to the current Single until the given time delay elapsed.
        Scheduler:
        delaySubscription does by default subscribe to the current Single on the Scheduler you provided, after the delay.
        Type Parameters:
        U - the element type of the other source
        Parameters:
        time - the time amount to wait with the subscription
        unit - the time unit of the waiting
        scheduler - the scheduler to wait on and subscribe on to the current Single
        Returns:
        the new Single instance
        Since:
        2.0
      • doAfterSuccess

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final Single<T> doAfterSuccess(Consumer<? super T> onAfterSuccess)
        Calls the specified consumer with the success item after this item has been emitted to the downstream.

        Note that the doAfterSuccess action is shared between subscriptions and as such should be thread-safe.

        Scheduler:
        doAfterSuccess does not operate by default on a particular Scheduler.
        Parameters:
        onAfterSuccess - the Consumer that will be called after emitting an item from upstream to the downstream
        Returns:
        the new Single instance
        Since:
        2.0.1 - experimental
      • doAfterTerminate

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final Single<T> doAfterTerminate(Action onAfterTerminate)
        Registers an Action to be called after this Single invokes either onSuccess or onError. *

        Note that the doAfterSuccess action is shared between subscriptions and as such should be thread-safe.

        Scheduler:
        doAfterTerminate does not operate by default on a particular Scheduler.
        Parameters:
        onAfterTerminate - an Action to be invoked when the source Single finishes
        Returns:
        a Single that emits the same items as the source Single, then invokes the Action
        Since:
        2.0.6 - experimental
        See Also:
        ReactiveX operators documentation: Do
      • doFinally

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final Single<T> doFinally(Action onFinally)
        Calls the specified action after this Single signals onSuccess or onError or gets disposed by the downstream.

        In case of a race between a terminal event and a dispose call, the provided onFinally action is executed once per subscription.

        Note that the onFinally action is shared between subscriptions and as such should be thread-safe.

        Scheduler:
        doFinally does not operate by default on a particular Scheduler.
        Parameters:
        onFinally - the action called when this Single terminates or gets cancelled
        Returns:
        the new Single instance
        Since:
        2.0.1 - experimental
      • doOnSubscribe

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final Single<T> doOnSubscribe(Consumer<? super Disposable> onSubscribe)
        Calls the shared consumer with the Disposable sent through the onSubscribe for each SingleObserver that subscribes to the current Single.
        Scheduler:
        doOnSubscribe does not operate by default on a particular Scheduler.
        Parameters:
        onSubscribe - the consumer called with the Disposable sent via onSubscribe
        Returns:
        the new Single instance
        Since:
        2.0
      • doOnSuccess

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final Single<T> doOnSuccess(Consumer<? super T> onSuccess)
        Calls the shared consumer with the success value sent via onSuccess for each SingleObserver that subscribes to the current Single.
        Scheduler:
        doOnSuccess does not operate by default on a particular Scheduler.
        Parameters:
        onSuccess - the consumer called with the success value of onSuccess
        Returns:
        the new Single instance
        Since:
        2.0
      • doOnEvent

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final Single<T> doOnEvent(BiConsumer<? super T,? super java.lang.Throwable> 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.
        Scheduler:
        doOnEvent does not operate by default on a particular Scheduler.
        Parameters:
        onEvent - the consumer called with the success value of onEvent
        Returns:
        the new Single instance
        Since:
        2.0
      • doOnError

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final Single<T> doOnError(Consumer<? super java.lang.Throwable> onError)
        Calls the shared consumer with the error sent via onError for each SingleObserver that subscribes to the current Single.
        Scheduler:
        doOnError does not operate by default on a particular Scheduler.
        Parameters:
        onError - the consumer called with the success value of onError
        Returns:
        the new Single instance
        Since:
        2.0
      • doOnDispose

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final Single<T> doOnDispose(Action onDispose)
        Calls the shared runnable if a SingleObserver subscribed to the current Single disposes the common Disposable it received via onSubscribe.
        Scheduler:
        doOnDispose does not operate by default on a particular Scheduler.
        Parameters:
        onDispose - the runnable called when the subscription is disposed
        Returns:
        the new Single instance
        Since:
        2.0
      • filter

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final Maybe<T> filter(Predicate<? super T> predicate)
        Filters the success item of the Single via a predicate function and emitting it if the predicate returns true, completing otherwise.

        Scheduler:
        filter does not operate by default on a particular Scheduler.
        Parameters:
        predicate - a function that evaluates the item emitted by the source Maybe, returning true if it passes the filter
        Returns:
        a Maybe that emit the item emitted by the source Maybe that the filter evaluates as true
        See Also:
        ReactiveX operators documentation: Filter
      • flatMap

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final <R> Single<R> flatMap(Function<? super T,? extends SingleSource<? 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.

        Scheduler:
        flatMap does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the result value type
        Parameters:
        mapper - a function that, when applied to the item emitted by the source Single, returns a SingleSource
        Returns:
        the Single returned from mapper when applied to the item emitted by the source Single
        See Also:
        ReactiveX operators documentation: FlatMap
      • flatMapMaybe

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final <R> Maybe<R> flatMapMaybe(Function<? super T,? extends MaybeSource<? 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.

        Scheduler:
        flatMapMaybe does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the result value type
        Parameters:
        mapper - a function that, when applied to the item emitted by the source Single, returns a MaybeSource
        Returns:
        the Maybe returned from mapper when applied to the item emitted by the source Single
        See Also:
        ReactiveX operators documentation: FlatMap
      • flatMapPublisher

        @BackpressureSupport(value=FULL)
        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final <R> Flowable<R> flatMapPublisher(Function<? super T,? extends org.reactivestreams.Publisher<? 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.

        Backpressure:
        The returned Flowable honors the backpressure of the downstream consumer and the Publisher returned by the mapper function is expected to honor it as well.
        Scheduler:
        flatMapPublisher does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the result value type
        Parameters:
        mapper - a function that, when applied to the item emitted by the source Single, returns an Flowable
        Returns:
        the Flowable returned from func when applied to the item emitted by the source Single
        See Also:
        ReactiveX operators documentation: FlatMap
      • flattenAsFlowable

        @BackpressureSupport(value=FULL)
        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final <U> Flowable<U> flattenAsFlowable(Function<? super T,? extends java.lang.Iterable<? extends U>> mapper)
        Returns a Flowable that merges each item emitted by the source Single with the values in an Iterable corresponding to that item that is generated by a selector.

        Backpressure:
        The operator honors backpressure from downstream.
        Scheduler:
        flattenAsFlowable does not operate by default on a particular Scheduler.
        Type Parameters:
        U - the type of item emitted by the resulting Iterable
        Parameters:
        mapper - a function that returns an Iterable sequence of values for when given an item emitted by the source Single
        Returns:
        the new Flowable instance
        See Also:
        ReactiveX operators documentation: FlatMap
      • flattenAsObservable

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final <U> Observable<U> flattenAsObservable(Function<? super T,? extends java.lang.Iterable<? extends U>> mapper)
        Returns an Observable that maps a success value into an Iterable and emits its items.

        Scheduler:
        flattenAsObservable does not operate by default on a particular Scheduler.
        Type Parameters:
        U - the type of item emitted by the resulting Iterable
        Parameters:
        mapper - a function that returns an Iterable sequence of values for when given an item emitted by the source Single
        Returns:
        the new Observable instance
        See Also:
        ReactiveX operators documentation: FlatMap
      • flatMapObservable

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final <R> Observable<R> flatMapObservable(Function<? super T,? extends ObservableSource<? 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 a SingleSource.

        Scheduler:
        flatMapObservable does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the result value type
        Parameters:
        mapper - a function that, when applied to the item emitted by the source Single, returns an ObservableSource
        Returns:
        the Observable returned from func when applied to the item emitted by the source Single
        See Also:
        ReactiveX operators documentation: FlatMap
      • blockingGet

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final T blockingGet()
        Waits in a blocking fashion until the current Single signals a success value (which is returned) or an exception (which is propagated).
        Scheduler:
        blockingGet does not operate by default on a particular Scheduler.
        Returns:
        the success value
      • lift

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final <R> Single<R> lift(SingleOperator<? extends R,? super T> lift)
        Lifts a function to the current Single and returns a new Single that when subscribed to will pass the values of the current Single through the Operator function.

        In other words, this allows chaining TaskExecutors together on a Single for acting on the values within the Single.

        task.map(...).filter(...).lift(new OperatorA()).lift(new OperatorB(...)).subscribe()

        If the operator you are creating is designed to act on the item emitted by a source Single, use lift. If your operator is designed to transform the source Single as a whole (for instance, by applying a particular set of existing RxJava operators to it) use compose(io.reactivex.SingleTransformer<? super T, ? extends R>).

        Scheduler:
        lift does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the downstream's value type (output)
        Parameters:
        lift - the Operator that implements the Single-operating function to be applied to the source Single
        Returns:
        a Single that is the result of applying the lifted Operator to the source Single
        See Also:
        RxJava wiki: Implementing Your Own Operators
      • map

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final <R> Single<R> map(Function<? super T,? 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.

        Scheduler:
        map does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the result value type
        Parameters:
        mapper - a function to apply to the item emitted by the Single
        Returns:
        a Single that emits the item from the source Single, transformed by the specified function
        See Also:
        ReactiveX operators documentation: Map
      • contains

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final Single<java.lang.Boolean> contains(java.lang.Object value)
        Signals true if the current Single signals a success value that is Object-equals with the value provided.
        Scheduler:
        contains does not operate by default on a particular Scheduler.
        Parameters:
        value - the value to compare against the success value of this Single
        Returns:
        the new Single instance
        Since:
        2.0
      • contains

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final Single<java.lang.Boolean> contains(java.lang.Object value,
                                                                                BiPredicate<java.lang.Object,java.lang.Object> comparer)
        Signals true if the current Single signals a success value that is equal with the value provided by calling a bi-predicate.
        Scheduler:
        contains does not operate by default on a particular Scheduler.
        Parameters:
        value - the value to compare against the success value of this Single
        comparer - the function that receives the success value of this Single, the value provided and should return true if they are considered equal
        Returns:
        the new Single instance
        Since:
        2.0
      • onErrorReturn

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final Single<T> onErrorReturn(Function<java.lang.Throwable,? extends T> resumeFunction)
        Instructs a Single to emit an item (returned by a specified function) rather than invoking 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's SingleObserver.onError(java.lang.Throwable) method, and then quits without invoking any more of its subscriber's methods. The onErrorReturn method changes this behavior. If you pass a function (resumeFunction) to a Single's onErrorReturn method, if the original Single encounters an error, instead of invoking its subscriber's SingleObserver.onError(java.lang.Throwable) method, it will instead emit the return value of resumeFunction.

        You can use this to prevent errors from propagating or to supply fallback data should errors be encountered.

        Scheduler:
        onErrorReturn does not operate by default on a particular Scheduler.
        Parameters:
        resumeFunction - a function that returns an item that the new Single will emit if the source Single encounters an error
        Returns:
        the original Single with appropriately modified behavior
        See Also:
        ReactiveX operators documentation: Catch
      • onErrorReturnItem

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final Single<T> onErrorReturnItem(T value)
        Signals the specified value as success in case the current Single signals an error.
        Scheduler:
        onErrorReturnItem does not operate by default on a particular Scheduler.
        Parameters:
        value - the value to signal if the current Single fails
        Returns:
        the new Single instance
        Since:
        2.0
      • onErrorResumeNext

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final Single<T> onErrorResumeNext(Single<? extends T> resumeSingleInCaseOfError)
        Instructs a Single to pass control to another Single rather than invoking 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 its SingleObserver, the Single invokes its SingleObserver's onError method, and then quits without invoking any more of its SingleObserver's methods. The onErrorResumeNext method changes this behavior. If you pass another Single (resumeSingleInCaseOfError) to a Single's onErrorResumeNext method, if the original Single encounters an error, instead of invoking its SingleObserver's onError method, it will instead relinquish control to resumeSingleInCaseOfError which will invoke the SingleObserver's onSuccess method if it is able to do so. In such a case, because no Single necessarily invokes onError, 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.

        Scheduler:
        onErrorResumeNext does not operate by default on a particular Scheduler.
        Parameters:
        resumeSingleInCaseOfError - a Single that will take control if source Single encounters an error.
        Returns:
        the original Single, with appropriately modified behavior.
        See Also:
        ReactiveX operators documentation: Catch
      • onErrorResumeNext

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final Single<T> onErrorResumeNext(Function<? super java.lang.Throwable,? extends SingleSource<? extends T>> resumeFunctionInCaseOfError)
        Instructs a Single to pass control to another Single rather than invoking 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 its SingleObserver, the Single invokes its SingleObserver's onError method, and then quits without invoking any more of its SingleObserver's methods. The onErrorResumeNext method changes this behavior. If you pass a function that will return another Single (resumeFunctionInCaseOfError) to a Single's onErrorResumeNext method, if the original Single encounters an error, instead of invoking its SingleObserver's onError method, it will instead relinquish control to resumeSingleInCaseOfError which will invoke the SingleObserver's onSuccess method if it is able to do so. In such a case, because no Single necessarily invokes onError, 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.

        Scheduler:
        onErrorResumeNext does not operate by default on a particular Scheduler.
        Parameters:
        resumeFunctionInCaseOfError - a function that returns a Single that will take control if source Single encounters an error.
        Returns:
        the original Single, with appropriately modified behavior.
        Since:
        .20
        See Also:
        ReactiveX operators documentation: Catch
      • repeat

        @BackpressureSupport(value=FULL)
        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final Flowable<T> repeat(long times)
        Re-subscribes to the current Single at most the given number of times and emits each success value.
        Backpressure:
        The returned Flowable honors the backpressure of the downstream consumer.
        Scheduler:
        repeat does not operate by default on a particular Scheduler.
        Parameters:
        times - the number of times to re-subscribe to the current Single
        Returns:
        the new Flowable instance
        Since:
        2.0
      • repeatWhen

        @BackpressureSupport(value=FULL)
        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final Flowable<T> repeatWhen(Function<? super Flowable<java.lang.Object>,? extends org.reactivestreams.Publisher<?>> 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.
        Backpressure:
        The returned Flowable honors the backpressure of the downstream consumer. The Publisher returned by the handler function is expected to honor backpressure as well.
        Scheduler:
        repeatWhen does not operate by default on a particular Scheduler.
        Parameters:
        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.
        Returns:
        the new Flowable instance
        Since:
        2.0
      • repeatUntil

        @BackpressureSupport(value=FULL)
        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final Flowable<T> repeatUntil(BooleanSupplier stop)
        Re-subscribes to the current Single until the given BooleanSupplier returns true.
        Backpressure:
        The returned Flowable honors the backpressure of the downstream consumer.
        Scheduler:
        repeatUntil does not operate by default on a particular Scheduler.
        Parameters:
        stop - the BooleanSupplier called after the current Single succeeds and if returns false, the Single is re-subscribed; otherwise the sequence completes.
        Returns:
        the new Flowable instance
        Since:
        2.0
      • retry

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final Single<T> retry()
        Repeatedly re-subscribes to the current Single indefinitely if it fails with an onError.
        Scheduler:
        retry does not operate by default on a particular Scheduler.
        Returns:
        the new Single instance
        Since:
        2.0
      • retry

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final Single<T> retry(long times)
        Repeatedly re-subscribe at most the specified times to the current Single if it fails with an onError.
        Scheduler:
        retry does not operate by default on a particular Scheduler.
        Parameters:
        times - the number of times to resubscribe if the current Single fails
        Returns:
        the new Single instance
        Since:
        2.0
      • retry

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final Single<T> retry(BiPredicate<? super java.lang.Integer,? super java.lang.Throwable> predicate)
        Re-subscribe to the current Single if the given predicate returns true when the Single fails with an onError.
        Scheduler:
        retry does not operate by default on a particular Scheduler.
        Parameters:
        predicate - the predicate called with the resubscription count and the failure Throwable and should return true if a resubscription should happen
        Returns:
        the new Single instance
        Since:
        2.0
      • retry

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final Single<T> retry(Predicate<? super java.lang.Throwable> predicate)
        Re-subscribe to the current Single if the given predicate returns true when the Single fails with an onError.
        Scheduler:
        retry does not operate by default on a particular Scheduler.
        Parameters:
        predicate - the predicate called with the failure Throwable and should return true if a resubscription should happen
        Returns:
        the new Single instance
        Since:
        2.0
      • retryWhen

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final Single<T> retryWhen(Function<? super Flowable<java.lang.Throwable>,? extends org.reactivestreams.Publisher<?>> handler)
        Re-subscribes to the current Single if and when the Publisher returned by the handler function signals a value.

        If the Publisher signals an onComplete, the resulting Single will signal a NoSuchElementException.

        Scheduler:
        retryWhen does not operate by default on a particular Scheduler.
        Parameters:
        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
        Returns:
        the new Single instance
      • subscribe

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final Disposable subscribe(BiConsumer<? super T,? super java.lang.Throwable> onCallback)
        Subscribes to a Single and provides a composite callback to handle the item it emits or any error notification it issues.
        Scheduler:
        subscribe does not operate by default on a particular Scheduler.
        Parameters:
        onCallback - the callback that receives either the success value or the failure Throwable (whichever is not null)
        Returns:
        a Disposable reference can request the Single stop work.
        Throws:
        java.lang.NullPointerException - if onCallback is null
        See Also:
        ReactiveX operators documentation: Subscribe
      • subscribe

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final Disposable subscribe(Consumer<? super T> onSuccess,
                                                                  Consumer<? super java.lang.Throwable> onError)
        Subscribes to a Single and provides callbacks to handle the item it emits or any error notification it issues.
        Scheduler:
        subscribe does not operate by default on a particular Scheduler.
        Parameters:
        onSuccess - the Consumer<T> you have designed to accept the emission from the Single
        onError - the Consumer<Throwable> you have designed to accept any error notification from the Single
        Returns:
        a Disposable reference can request the Single stop work.
        Throws:
        java.lang.NullPointerException - if onSuccess is null, or if onError is null
        See Also:
        ReactiveX operators documentation: Subscribe
      • subscribeActual

        protected abstract void subscribeActual(SingleObserver<? super T> observer)
        Override this method in subclasses to handle the incoming SingleObservers.
        Parameters:
        observer - the SingleObserver to handle, not null
      • subscribeWith

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final <E extends SingleObserver<? super T>> E subscribeWith(E observer)
        Subscribes a given SingleObserver (subclass) to this Single and returns the given SingleObserver as is.

        Usage example:

        
         Single<Integer> source = Single.just(1);
         CompositeDisposable composite = new CompositeDisposable();
        
         class ResourceSingleObserver implements SingleObserver<Integer>, Disposable {
             // ...
         }
        
         composite.add(source.subscribeWith(new ResourceSingleObserver()));
         
        Scheduler:
        subscribeWith does not operate by default on a particular Scheduler.
        Type Parameters:
        E - the type of the SingleObserver to use and return
        Parameters:
        observer - the SingleObserver (subclass) to use and return, not null
        Returns:
        the input observer
        Throws:
        java.lang.NullPointerException - if observer is null
        Since:
        2.0
      • takeUntil

        @BackpressureSupport(value=FULL)
        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final <E> Single<T> takeUntil(org.reactivestreams.Publisher<E> other)
        Returns a Single that emits the item emitted by the source Single until a Publisher emits an item. Upon emission of an item from other, this will emit a CancellationException rather than go to SingleObserver.onSuccess(Object).

        Backpressure:
        The other publisher is consumed in an unbounded fashion but will be cancelled after the first item it produced.
        Scheduler:
        takeUntil does not operate by default on a particular Scheduler.
        Type Parameters:
        E - the type of items emitted by other
        Parameters:
        other - the Publisher whose first emitted item will cause takeUntil to emit the item from the source Single
        Returns:
        a Single that emits the item emitted by the source Single until such time as other emits its first item
        See Also:
        ReactiveX operators documentation: TakeUntil
      • takeUntil

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final <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. Upon emission of an item from other, this will emit a CancellationException rather than go to SingleObserver.onSuccess(Object).

        Scheduler:
        takeUntil does not operate by default on a particular Scheduler.
        Type Parameters:
        E - the type of item emitted by other
        Parameters:
        other - the Single whose emitted item will cause takeUntil to emit the item from the source Single
        Returns:
        a Single that emits the item emitted by the source Single until such time as other emits its item
        See Also:
        ReactiveX operators documentation: TakeUntil
      • timeout

        @CheckReturnValue
        @SchedulerSupport(value="io.reactivex:computation")
        public final Single<T> timeout(long timeout,
                                                               java.util.concurrent.TimeUnit unit)
        Signals a TimeoutException if the current Single doesn't signal a success value within the specified timeout window.
        Scheduler:
        timeout signals the TimeoutException on the computation Scheduler.
        Parameters:
        timeout - the timeout amount
        unit - the time unit
        Returns:
        the new Single instance
        Since:
        2.0
      • timeout

        @CheckReturnValue
        @SchedulerSupport(value="custom")
        public final Single<T> timeout(long timeout,
                                                               java.util.concurrent.TimeUnit unit,
                                                               Scheduler scheduler)
        Signals a TimeoutException if the current Single doesn't signal a success value within the specified timeout window.
        Scheduler:
        timeout signals the TimeoutException on the Scheduler you specify.
        Parameters:
        timeout - the timeout amount
        unit - the time unit
        scheduler - the target scheduler where the timeout is awaited and the TimeoutException signalled
        Returns:
        the new Single instance
        Since:
        2.0
      • timeout

        @CheckReturnValue
        @SchedulerSupport(value="custom")
        public final Single<T> timeout(long timeout,
                                                               java.util.concurrent.TimeUnit unit,
                                                               Scheduler scheduler,
                                                               SingleSource<? extends T> other)
        Runs the current Single and if it doesn't signal within the specified timeout window, it is cancelled and the other SingleSource subscribed to.
        Scheduler:
        timeout subscribes to the other SingleSource on the Scheduler you specify.
        Parameters:
        timeout - the timeout amount
        unit - the time unit
        scheduler - the scheduler where the timeout is awaited and the subscription to other happens
        other - the other SingleSource that gets subscribed to if the current Single times out
        Returns:
        the new Single instance
        Since:
        2.0
      • timeout

        @CheckReturnValue
        @SchedulerSupport(value="io.reactivex:computation")
        public final Single<T> timeout(long timeout,
                                                               java.util.concurrent.TimeUnit unit,
                                                               SingleSource<? extends T> other)
        Runs the current Single and if it doesn't signal within the specified timeout window, it is cancelled and the other SingleSource subscribed to.
        Scheduler:
        timeout subscribes to the other SingleSource on the computation Scheduler.
        Parameters:
        timeout - the timeout amount
        unit - the time unit
        other - the other SingleSource that gets subscribed to if the current Single times out
        Returns:
        the new Single instance
        Since:
        2.0
      • to

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final <R> R to(Function<? super Single<T>,R> convert)
        Calls the specified converter function with the current Single instance during assembly time and returns its result.
        Scheduler:
        to does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the result type
        Parameters:
        convert - the function that is called with the current Single instance during assembly time that should return some value to be the result
        Returns:
        the value returned by the convert function
      • zipWith

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final <U,R> Single<R> zipWith(SingleSource<U> other,
                                                                     BiFunction<? super T,? 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.

        Scheduler:
        zipWith does not operate by default on a particular Scheduler.
        Type Parameters:
        U - the type of items emitted by the other Single
        R - the type of items emitted by the resulting Single
        Parameters:
        other - the other SingleSource
        zipper - a function that combines the pairs of items from the two SingleSources to generate the items to be emitted by the resulting Single
        Returns:
        a Single that pairs up values from the source Single and the other SingleSource and emits the results of zipFunction applied to these pairs
        See Also:
        ReactiveX operators documentation: Zip
      • test

        @CheckReturnValue
        @SchedulerSupport(value="none")
        public final TestObserver<T> test(boolean cancelled)
        Creates a TestObserver optionally in cancelled state, then subscribes it to this Single.
        Scheduler:
        test does not operate by default on a particular Scheduler.
        Parameters:
        cancelled - if true, the TestObserver will be cancelled before subscribing to this Single.
        Returns:
        the new TestObserver instance
        Since:
        2.0