Class Observable<T>

    • Constructor Detail

      • Observable

        public Observable()
    • Method Detail

      • amb

        @CheckReturnValue
        @NonNull
        @SchedulerSupport("none")
        public static <@NonNull T> @NonNull Observable<T> amb​(@NonNull
                                                              @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources)
        Mirrors the one ObservableSource in an Iterable of several ObservableSources that first either emits an item or sends a termination notification.

        When one of the ObservableSources signal an item or terminates first, all subscriptions to the other ObservableSources are disposed.

        Scheduler:
        amb does not operate by default on a particular Scheduler.
        Error handling:
        If any of the losing ObservableSources signals an error, the error is routed to the global error handler via RxJavaPlugins.onError(Throwable).
        Type Parameters:
        T - the common element type
        Parameters:
        sources - an Iterable of ObservableSource sources competing to react first. A subscription to each source will occur in the same order as in the Iterable.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if sources is null
        See Also:
        ReactiveX operators documentation: Amb
      • ambArray

        @CheckReturnValue
        @NonNull
        @SchedulerSupport("none")
        @SafeVarargs
        public static <@NonNull T> @NonNull Observable<T> ambArray​(@NonNull
                                                                   @NonNull ObservableSource<? extends @NonNull T>... sources)
        Mirrors the one ObservableSource in an array of several ObservableSources that first either emits an item or sends a termination notification.

        When one of the ObservableSources signal an item or terminates first, all subscriptions to the other ObservableSources are disposed.

        Scheduler:
        ambArray does not operate by default on a particular Scheduler.
        Error handling:
        If any of the losing ObservableSources signals an error, the error is routed to the global error handler via RxJavaPlugins.onError(Throwable).
        Type Parameters:
        T - the common element type
        Parameters:
        sources - an array of ObservableSource sources competing to react first. A subscription to each source will occur in the same order as in the array.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if sources is null
        See Also:
        ReactiveX operators documentation: Amb
      • bufferSize

        @CheckReturnValue
        public static int bufferSize()
        Returns the default 'island' size or capacity-increment hint for unbounded buffers.

        Delegates to Flowable.bufferSize() but is public for convenience.

        The value can be overridden via system parameter rx3.buffer-size before the Flowable class is loaded.

        Returns:
        the default 'island' size or capacity-increment hint
      • combineLatest

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T,​@NonNull R> @NonNull Observable<R> combineLatest​(@NonNull
                                                                                         @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources,
                                                                                         @NonNull
                                                                                         @NonNull Function<? super java.lang.Object[],​? extends @NonNull R> combiner)
        Combines a collection of source ObservableSources by emitting an item that aggregates the latest values of each of the returned ObservableSources each time an item is received from any of the returned ObservableSources, where this aggregation is defined by a specified function.

        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 sources never produces an item but only terminates (normally or with an error), the resulting sequence terminates immediately (normally or with all the errors accumulated till that point). If that input source is also synchronous, other sources after it will not be subscribed to.

        If the provided iterable of ObservableSources is empty, the resulting sequence completes immediately without emitting any items and without any calls to the combiner function.

        Scheduler:
        combineLatest does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the common base type of source values
        R - the result type
        Parameters:
        sources - the collection of source ObservableSources
        combiner - the aggregation function used to combine the items emitted by the returned ObservableSources
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if sources or combiner is null
        See Also:
        ReactiveX operators documentation: CombineLatest
      • combineLatest

        @CheckReturnValue
        @NonNull
        @SchedulerSupport("none")
        public static <@NonNull T,​@NonNull R> @NonNull Observable<R> combineLatest​(@NonNull
                                                                                         @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources,
                                                                                         @NonNull
                                                                                         @NonNull Function<? super java.lang.Object[],​? extends @NonNull R> combiner,
                                                                                         int bufferSize)
        Combines an Iterable of source ObservableSources by emitting an item that aggregates the latest values of each of the returned ObservableSources each time an item is received from any of the returned ObservableSources, where this aggregation is defined by a specified function.

        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 sources never produces an item but only terminates (normally or with an error), the resulting sequence terminates immediately (normally or with all the errors accumulated till that point). If that input source is also synchronous, other sources after it will not be subscribed to.

        If the provided Iterable of ObservableSources is empty, the resulting sequence completes immediately without emitting any items and without any calls to the combiner function.

        Scheduler:
        combineLatest does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the common base type of source values
        R - the result type
        Parameters:
        sources - the collection of source ObservableSources
        combiner - the aggregation function used to combine the items emitted by the returned ObservableSources
        bufferSize - the expected number of row combination items to be buffered internally
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if sources or combiner is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        See Also:
        ReactiveX operators documentation: CombineLatest
      • combineLatestArray

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T,​@NonNull R> @NonNull Observable<R> combineLatestArray​(@NonNull
                                                                                              @NonNull ObservableSource<? extends @NonNull T>[] sources,
                                                                                              @NonNull
                                                                                              @NonNull Function<? super java.lang.Object[],​? extends @NonNull R> combiner)
        Combines an array of source ObservableSources by emitting an item that aggregates the latest values of each of the ObservableSources each time an item is received from any of the returned ObservableSources, where this aggregation is defined by a specified function.

        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 sources never produces an item but only terminates (normally or with an error), the resulting sequence terminates immediately (normally or with all the errors accumulated till that point). If that input source is also synchronous, other sources after it will not be subscribed to.

        If the provided array of ObservableSources is empty, the resulting sequence completes immediately without emitting any items and without any calls to the combiner function.

        Scheduler:
        combineLatestArray does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the common base type of source values
        R - the result type
        Parameters:
        sources - the collection of source ObservableSources
        combiner - the aggregation function used to combine the items emitted by the ObservableSources
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if sources or combiner is null
        See Also:
        ReactiveX operators documentation: CombineLatest
      • combineLatestArray

        @CheckReturnValue
        @NonNull
        @SchedulerSupport("none")
        public static <@NonNull T,​@NonNull R> @NonNull Observable<R> combineLatestArray​(@NonNull
                                                                                              @NonNull ObservableSource<? extends @NonNull T>[] sources,
                                                                                              @NonNull
                                                                                              @NonNull Function<? super java.lang.Object[],​? extends @NonNull R> combiner,
                                                                                              int bufferSize)
        Combines an array of source ObservableSources by emitting an item that aggregates the latest values of each of the ObservableSources each time an item is received from any of the ObservableSources, where this aggregation is defined by a specified function.

        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 sources never produces an item but only terminates (normally or with an error), the resulting sequence terminates immediately (normally or with all the errors accumulated till that point). If that input source is also synchronous, other sources after it will not be subscribed to.

        If the provided array of ObservableSources is empty, the resulting sequence completes immediately without emitting any items and without any calls to the combiner function.

        Scheduler:
        combineLatestArray does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the common base type of source values
        R - the result type
        Parameters:
        sources - the collection of source ObservableSources
        combiner - the aggregation function used to combine the items emitted by the ObservableSources
        bufferSize - the expected number of row combination items to be buffered internally
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if sources or combiner is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        See Also:
        ReactiveX operators documentation: CombineLatest
      • combineLatest

        @CheckReturnValue
        @NonNull
        @SchedulerSupport("none")
        public static <@NonNull T1,​@NonNull T2,​@NonNull R> @NonNull Observable<R> combineLatest​(@NonNull
                                                                                                            @NonNull ObservableSource<? extends @NonNull T1> source1,
                                                                                                            @NonNull
                                                                                                            @NonNull ObservableSource<? extends @NonNull T2> source2,
                                                                                                            @NonNull
                                                                                                            @NonNull BiFunction<? super @NonNull T1,​? super @NonNull T2,​? extends @NonNull R> combiner)
        Combines two source ObservableSources by emitting an item that aggregates the latest values of each of the ObservableSources each time an item is received from either of the ObservableSources, where this aggregation is defined by a specified function.

        If any of the sources never produces an item but only terminates (normally or with an error), the resulting sequence terminates immediately (normally or with all the errors accumulated till that point). If that input source is also synchronous, other sources after it will not be subscribed to.

        Scheduler:
        combineLatest does not operate by default on a particular Scheduler.
        Type Parameters:
        T1 - the element type of the first source
        T2 - the element type of the second source
        R - the combined output type
        Parameters:
        source1 - the first source ObservableSource
        source2 - the second source ObservableSource
        combiner - the aggregation function used to combine the items emitted by the ObservableSources
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if source1, source2 or combiner is null
        See Also:
        ReactiveX operators documentation: CombineLatest
      • combineLatest

        @CheckReturnValue
        @NonNull
        @SchedulerSupport("none")
        public static <@NonNull T1,​@NonNull T2,​@NonNull T3,​@NonNull R> @NonNull Observable<R> combineLatest​(@NonNull
                                                                                                                              @NonNull ObservableSource<? extends @NonNull T1> source1,
                                                                                                                              @NonNull
                                                                                                                              @NonNull ObservableSource<? extends @NonNull T2> source2,
                                                                                                                              @NonNull
                                                                                                                              @NonNull ObservableSource<? extends @NonNull T3> source3,
                                                                                                                              @NonNull
                                                                                                                              @NonNull Function3<? super @NonNull T1,​? super @NonNull T2,​? super @NonNull T3,​? extends @NonNull R> combiner)
        Combines three source ObservableSources by emitting an item that aggregates the latest values of each of the ObservableSources each time an item is received from any of the ObservableSources, where this aggregation is defined by a specified function.

        If any of the sources never produces an item but only terminates (normally or with an error), the resulting sequence terminates immediately (normally or with all the errors accumulated till that point). If that input source is also synchronous, other sources after it will not be subscribed to.

        Scheduler:
        combineLatest does not operate by default on a particular Scheduler.
        Type Parameters:
        T1 - the element type of the first source
        T2 - the element type of the second source
        T3 - the element type of the third source
        R - the combined output type
        Parameters:
        source1 - the first source ObservableSource
        source2 - the second source ObservableSource
        source3 - the third source ObservableSource
        combiner - the aggregation function used to combine the items emitted by the ObservableSources
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if source1, source2, source3 or combiner is null
        See Also:
        ReactiveX operators documentation: CombineLatest
      • combineLatestArrayDelayError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T,​@NonNull R> @NonNull Observable<R> combineLatestArrayDelayError​(@NonNull
                                                                                                        @NonNull ObservableSource<? extends @NonNull T>[] sources,
                                                                                                        @NonNull
                                                                                                        @NonNull Function<? super java.lang.Object[],​? extends @NonNull R> combiner)
        Combines an array of ObservableSources by emitting an item that aggregates the latest values of each of the ObservableSources each time an item is received from any of the ObservableSources, where this aggregation is defined by a specified function.

        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 sources never produces an item but only terminates (normally or with an error), the resulting sequence terminates immediately (normally or with all the errors accumulated till that point). If that input source is also synchronous, other sources after it will not be subscribed to.

        If the provided array of ObservableSources is empty, the resulting sequence completes immediately without emitting any items and without any calls to the combiner function.

        Scheduler:
        combineLatestArrayDelayError does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the common base type of source values
        R - the result type
        Parameters:
        sources - the collection of source ObservableSources
        combiner - the aggregation function used to combine the items emitted by the ObservableSources
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if sources or combiner is null
        See Also:
        ReactiveX operators documentation: CombineLatest
      • combineLatestArrayDelayError

        @CheckReturnValue
        @NonNull
        @SchedulerSupport("none")
        public static <@NonNull T,​@NonNull R> @NonNull Observable<R> combineLatestArrayDelayError​(@NonNull
                                                                                                        @NonNull ObservableSource<? extends @NonNull T>[] sources,
                                                                                                        @NonNull
                                                                                                        @NonNull Function<? super java.lang.Object[],​? extends @NonNull R> combiner,
                                                                                                        int bufferSize)
        Combines an array of ObservableSources by emitting an item that aggregates the latest values of each of the ObservableSources each time an item is received from any of the ObservableSources, where this aggregation is defined by a specified function and delays any error from the sources until all source ObservableSources terminate.

        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 sources never produces an item but only terminates (normally or with an error), the resulting sequence terminates immediately (normally or with all the errors accumulated till that point). If that input source is also synchronous, other sources after it will not be subscribed to.

        If the provided array of ObservableSources is empty, the resulting sequence completes immediately without emitting any items and without any calls to the combiner function.

        Scheduler:
        combineLatestArrayDelayError does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the common base type of source values
        R - the result type
        Parameters:
        sources - the collection of source ObservableSources
        combiner - the aggregation function used to combine the items emitted by the ObservableSources
        bufferSize - the expected number of row combination items to be buffered internally
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if sources or combiner is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        See Also:
        ReactiveX operators documentation: CombineLatest
      • combineLatestDelayError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T,​@NonNull R> @NonNull Observable<R> combineLatestDelayError​(@NonNull
                                                                                                   @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources,
                                                                                                   @NonNull
                                                                                                   @NonNull Function<? super java.lang.Object[],​? extends @NonNull R> combiner)
        Combines an Iterable of ObservableSources by emitting an item that aggregates the latest values of each of the ObservableSources each time an item is received from any of the ObservableSources, where this aggregation is defined by a specified function and delays any error from the sources until all source ObservableSources terminate.

        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 sources never produces an item but only terminates (normally or with an error), the resulting sequence terminates immediately (normally or with all the errors accumulated till that point). If that input source is also synchronous, other sources after it will not be subscribed to.

        If the provided iterable of ObservableSources is empty, the resulting sequence completes immediately without emitting any items and without any calls to the combiner function.

        Scheduler:
        combineLatestDelayError does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the common base type of source values
        R - the result type
        Parameters:
        sources - the Iterable of source ObservableSources
        combiner - the aggregation function used to combine the items emitted by the ObservableSources
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if sources or combiner is null
        See Also:
        ReactiveX operators documentation: CombineLatest
      • combineLatestDelayError

        @CheckReturnValue
        @NonNull
        @SchedulerSupport("none")
        public static <@NonNull T,​@NonNull R> @NonNull Observable<R> combineLatestDelayError​(@NonNull
                                                                                                   @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources,
                                                                                                   @NonNull
                                                                                                   @NonNull Function<? super java.lang.Object[],​? extends @NonNull R> combiner,
                                                                                                   int bufferSize)
        Combines an Iterable of ObservableSources by emitting an item that aggregates the latest values of each of the ObservableSources each time an item is received from any of the ObservableSources, where this aggregation is defined by a specified function and delays any error from the sources until all source ObservableSources terminate.

        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 sources never produces an item but only terminates (normally or with an error), the resulting sequence terminates immediately (normally or with all the errors accumulated till that point). If that input source is also synchronous, other sources after it will not be subscribed to.

        If the provided iterable of ObservableSources is empty, the resulting sequence completes immediately without emitting any items and without any calls to the combiner function.

        Scheduler:
        combineLatestDelayError does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the common base type of source values
        R - the result type
        Parameters:
        sources - the collection of source ObservableSources
        combiner - the aggregation function used to combine the items emitted by the ObservableSources
        bufferSize - the expected number of row combination items to be buffered internally
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if sources or combiner is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        See Also:
        ReactiveX operators documentation: CombineLatest
      • concatArrayEager

        @CheckReturnValue
        @SchedulerSupport("none")
        @SafeVarargs
        @NonNull
        public static <@NonNull T> @NonNull Observable<T> concatArrayEager​(@NonNull
                                                                           @NonNull ObservableSource<? extends @NonNull T>... sources)
        Concatenates an array of ObservableSources eagerly into a single stream of values.

        Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the ObservableSources. The operator buffers the values emitted by these ObservableSources and then drains them in order, each one after the previous one completes.

        Scheduler:
        This method does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the value type
        Parameters:
        sources - an array of ObservableSources that need to be eagerly concatenated
        Returns:
        the new Observable instance with the specified concatenation behavior
        Throws:
        java.lang.NullPointerException - if sources is null
        Since:
        2.0
      • concatArrayEager

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        @SafeVarargs
        public static <@NonNull T> @NonNull Observable<T> concatArrayEager​(int maxConcurrency,
                                                                           int bufferSize,
                                                                           @NonNull
                                                                           @NonNull ObservableSource<? extends @NonNull T>... sources)
        Concatenates an array of ObservableSources eagerly into a single stream of values.

        Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the ObservableSources. The operator buffers the values emitted by these ObservableSources and then drains them in order, each one after the previous one completes.

        Scheduler:
        This method does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the value type
        Parameters:
        sources - an array of ObservableSources that need to be eagerly concatenated
        maxConcurrency - the maximum number of concurrent subscriptions at a time, Integer.MAX_VALUE is interpreted as indication to subscribe to all sources at once
        bufferSize - the number of elements expected from each ObservableSource to be buffered
        Returns:
        the new Observable instance with the specified concatenation behavior
        Throws:
        java.lang.NullPointerException - if sources is null
        java.lang.IllegalArgumentException - if maxConcurrency or bufferSize is non-positive
        Since:
        2.0
      • concatArrayEagerDelayError

        @CheckReturnValue
        @SchedulerSupport("none")
        @SafeVarargs
        @NonNull
        public static <@NonNull T> @NonNull Observable<T> concatArrayEagerDelayError​(@NonNull
                                                                                     @NonNull ObservableSource<? extends @NonNull T>... sources)
        Concatenates an array of ObservableSources eagerly into a single stream of values and delaying any errors until all sources terminate.

        Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the ObservableSources. The operator buffers the values emitted by these ObservableSources and then drains them in order, each one after the previous one completes.

        Scheduler:
        This method does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the value type
        Parameters:
        sources - an array of ObservableSources that need to be eagerly concatenated
        Returns:
        the new Observable instance with the specified concatenation behavior
        Throws:
        java.lang.NullPointerException - if sources is null
        Since:
        2.2.1 - experimental
      • concatArrayEagerDelayError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        @SafeVarargs
        public static <@NonNull T> @NonNull Observable<T> concatArrayEagerDelayError​(int maxConcurrency,
                                                                                     int bufferSize,
                                                                                     @NonNull
                                                                                     @NonNull ObservableSource<? extends @NonNull T>... sources)
        Concatenates an array of ObservableSources eagerly into a single stream of values and delaying any errors until all sources terminate.

        Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the ObservableSources. The operator buffers the values emitted by these ObservableSources and then drains them in order, each one after the previous one completes.

        Scheduler:
        This method does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the value type
        Parameters:
        sources - an array of ObservableSources that need to be eagerly concatenated
        maxConcurrency - the maximum number of concurrent subscriptions at a time, Integer.MAX_VALUE is interpreted as indication to subscribe to all sources at once
        bufferSize - the number of elements expected from each ObservableSource to be buffered
        Returns:
        the new Observable instance with the specified concatenation behavior
        Throws:
        java.lang.NullPointerException - if sources is null
        java.lang.IllegalArgumentException - if maxConcurrency or bufferSize is non-positive
        Since:
        2.2.1 - experimental
      • concatDelayError

        @CheckReturnValue
        @NonNull
        @SchedulerSupport("none")
        public static <@NonNull T> @NonNull Observable<T> concatDelayError​(@NonNull
                                                                           @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources)
        Concatenates the Iterable sequence of ObservableSources into a single Observable sequence by subscribing to each ObservableSource, one after the other, one at a time and delays any errors till the all inner ObservableSources terminate.

        Scheduler:
        concatDelayError does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the common element base type
        Parameters:
        sources - the Iterable sequence of ObservableSources
        Returns:
        the new Observable with the concatenating behavior
        Throws:
        java.lang.NullPointerException - if sources is null
      • concatDelayError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T> @NonNull Observable<T> concatDelayError​(@NonNull
                                                                           @NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources)
        Concatenates the ObservableSource sequence of ObservableSources into a single Observable sequence by subscribing to each inner ObservableSource, one after the other, one at a time and delays any errors till the all inner and the outer ObservableSources terminate.

        Scheduler:
        concatDelayError does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the common element base type
        Parameters:
        sources - the ObservableSource sequence of ObservableSources
        Returns:
        the new Observable with the concatenating behavior
        Throws:
        java.lang.NullPointerException - if sources is null
      • concatDelayError

        @CheckReturnValue
        @NonNull
        @SchedulerSupport("none")
        public static <@NonNull T> @NonNull Observable<T> concatDelayError​(@NonNull
                                                                           @NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources,
                                                                           int bufferSize,
                                                                           boolean tillTheEnd)
        Concatenates the ObservableSource sequence of ObservableSources into a single sequence by subscribing to each inner ObservableSource, one after the other, one at a time and delays any errors till the all inner and the outer ObservableSources terminate.

        Scheduler:
        concatDelayError does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the common element base type
        Parameters:
        sources - the ObservableSource sequence of ObservableSources
        bufferSize - the number of inner ObservableSources expected to be buffered
        tillTheEnd - if true, exceptions from the outer and all inner ObservableSources are delayed to the end if false, exception from the outer ObservableSource is delayed till the active ObservableSource terminates
        Returns:
        the new Observable with the concatenating behavior
        Throws:
        java.lang.NullPointerException - if sources is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
      • concatEager

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T> @NonNull Observable<T> concatEager​(@NonNull
                                                                      @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources)
        Concatenates a sequence of ObservableSources eagerly into a single stream of values.

        Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the ObservableSources. The operator buffers the values emitted by these ObservableSources and then drains them in order, each one after the previous one completes.

        Scheduler:
        This method does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the value type
        Parameters:
        sources - a sequence of ObservableSources that need to be eagerly concatenated
        Returns:
        the new Observable instance with the specified concatenation behavior
        Throws:
        java.lang.NullPointerException - if sources is null
        Since:
        2.0
      • concatEager

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T> @NonNull Observable<T> concatEager​(@NonNull
                                                                      @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources,
                                                                      int maxConcurrency,
                                                                      int bufferSize)
        Concatenates a sequence of ObservableSources eagerly into a single stream of values and runs a limited number of inner sequences at once.

        Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the ObservableSources. The operator buffers the values emitted by these ObservableSources and then drains them in order, each one after the previous one completes.

        Scheduler:
        This method does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the value type
        Parameters:
        sources - a sequence of ObservableSources that need to be eagerly concatenated
        maxConcurrency - the maximum number of concurrently running inner ObservableSources; Integer.MAX_VALUE is interpreted as all inner ObservableSources can be active at the same time
        bufferSize - the number of elements expected from each inner ObservableSource to be buffered
        Returns:
        the new Observable instance with the specified concatenation behavior
        Throws:
        java.lang.NullPointerException - if sources is null
        java.lang.IllegalArgumentException - if maxConcurrency or bufferSize is non-positive
        Since:
        2.0
      • concatEager

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T> @NonNull Observable<T> concatEager​(@NonNull
                                                                      @NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources)
        Concatenates an ObservableSource sequence of ObservableSources eagerly into a single stream of values.

        Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the emitted source ObservableSources as they are observed. The operator buffers the values emitted by these ObservableSources and then drains them in order, each one after the previous one completes.

        Scheduler:
        This method does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the value type
        Parameters:
        sources - a sequence of ObservableSources that need to be eagerly concatenated
        Returns:
        the new Observable instance with the specified concatenation behavior
        Throws:
        java.lang.NullPointerException - if sources is null
        Since:
        2.0
      • concatEager

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T> @NonNull Observable<T> concatEager​(@NonNull
                                                                      @NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources,
                                                                      int maxConcurrency,
                                                                      int bufferSize)
        Concatenates an ObservableSource sequence of ObservableSources eagerly into a single stream of values and runs a limited number of inner sequences at once.

        Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the emitted source ObservableSources as they are observed. The operator buffers the values emitted by these ObservableSources and then drains them in order, each one after the previous one completes.

        Scheduler:
        This method does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the value type
        Parameters:
        sources - a sequence of ObservableSources that need to be eagerly concatenated
        maxConcurrency - the maximum number of concurrently running inner ObservableSources; Integer.MAX_VALUE is interpreted as all inner ObservableSources can be active at the same time
        bufferSize - the number of inner ObservableSource expected to be buffered
        Returns:
        the new Observable instance with the specified concatenation behavior
        Throws:
        java.lang.NullPointerException - if sources is null
        java.lang.IllegalArgumentException - if maxConcurrency or bufferSize is non-positive
        Since:
        2.0
      • concatEagerDelayError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T> @NonNull Observable<T> concatEagerDelayError​(@NonNull
                                                                                @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources)
        Concatenates a sequence of ObservableSources eagerly into a single stream of values, delaying errors until all the inner sequences terminate.

        Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the ObservableSources. The operator buffers the values emitted by these ObservableSources and then drains them in order, each one after the previous one completes.

        Scheduler:
        This method does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the value type
        Parameters:
        sources - a sequence of ObservableSources that need to be eagerly concatenated
        Returns:
        the new Observable instance with the specified concatenation behavior
        Throws:
        java.lang.NullPointerException - if sources is null
        Since:
        3.0.0
      • concatEagerDelayError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T> @NonNull Observable<T> concatEagerDelayError​(@NonNull
                                                                                @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources,
                                                                                int maxConcurrency,
                                                                                int bufferSize)
        Concatenates a sequence of ObservableSources eagerly into a single stream of values, delaying errors until all the inner sequences terminate and runs a limited number of inner sequences at once.

        Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the ObservableSources. The operator buffers the values emitted by these ObservableSources and then drains them in order, each one after the previous one completes.

        Scheduler:
        This method does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the value type
        Parameters:
        sources - a sequence of ObservableSources that need to be eagerly concatenated
        maxConcurrency - the maximum number of concurrently running inner ObservableSources; Integer.MAX_VALUE is interpreted as all inner ObservableSources can be active at the same time
        bufferSize - the number of elements expected from each inner ObservableSource to be buffered
        Returns:
        the new Observable instance with the specified concatenation behavior
        Throws:
        java.lang.NullPointerException - if sources is null
        java.lang.IllegalArgumentException - if maxConcurrency or bufferSize is non-positive
        Since:
        3.0.0
      • concatEagerDelayError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T> @NonNull Observable<T> concatEagerDelayError​(@NonNull
                                                                                @NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources)
        Concatenates an ObservableSource sequence of ObservableSources eagerly into a single stream of values, delaying errors until all the inner and the outer sequence terminate.

        Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the emitted source ObservableSources as they are observed. The operator buffers the values emitted by these ObservableSources and then drains them in order, each one after the previous one completes.

        Scheduler:
        This method does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the value type
        Parameters:
        sources - a sequence of ObservableSources that need to be eagerly concatenated
        Returns:
        the new Observable instance with the specified concatenation behavior
        Throws:
        java.lang.NullPointerException - if sources is null
        Since:
        3.0.0
      • concatEagerDelayError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T> @NonNull Observable<T> concatEagerDelayError​(@NonNull
                                                                                @NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources,
                                                                                int maxConcurrency,
                                                                                int bufferSize)
        Concatenates an ObservableSource sequence of ObservableSources eagerly into a single stream of values, delaying errors until all the inner and the outer sequence terminate and runs a limited number of inner sequences at once.

        Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the emitted source ObservableSources as they are observed. The operator buffers the values emitted by these ObservableSources and then drains them in order, each one after the previous one completes.

        Scheduler:
        This method does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the value type
        Parameters:
        sources - a sequence of ObservableSources that need to be eagerly concatenated
        maxConcurrency - the maximum number of concurrently running inner ObservableSources; Integer.MAX_VALUE is interpreted as all inner ObservableSources can be active at the same time
        bufferSize - the number of inner ObservableSource expected to be buffered
        Returns:
        the new Observable instance with the specified concatenation behavior
        Throws:
        java.lang.NullPointerException - if sources is null
        java.lang.IllegalArgumentException - if maxConcurrency or bufferSize is non-positive
        Since:
        3.0.0
      • create

        @CheckReturnValue
        @NonNull
        @SchedulerSupport("none")
        public static <@NonNull T> @NonNull Observable<T> create​(@NonNull
                                                                 @NonNull ObservableOnSubscribe<@NonNull T> source)
        Provides an API (via a cold Observable) that bridges the reactive world with the callback-style world.

        Example:

        
         Observable.<Event>create(emitter -> {
             Callback listener = new Callback() {
                 @Override
                 public void onEvent(Event e) {
                     emitter.onNext(e);
                     if (e.isLast()) {
                         emitter.onComplete();
                     }
                 }
        
                 @Override
                 public void onFailure(Exception e) {
                     emitter.onError(e);
                 }
             };
        
             AutoCloseable c = api.someMethod(listener);
        
             emitter.setCancellable(c::close);
        
         });
         

        Whenever an Observer subscribes to the returned Observable, the provided ObservableOnSubscribe callback is invoked with a fresh instance of an ObservableEmitter that will interact only with that specific Observer. If this Observer disposes the flow (making ObservableEmitter.isDisposed() return true), other observers subscribed to the same returned Observable are not affected.

        You should call the ObservableEmitter's onNext, onError and onComplete methods in a serialized fashion. The rest of its methods are thread-safe.

        Scheduler:
        create does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the element type
        Parameters:
        source - the emitter that is called when an Observer subscribes to the returned Observable
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if source is null
        See Also:
        ObservableOnSubscribe, ObservableEmitter, Cancellable
      • defer

        @CheckReturnValue
        @NonNull
        @SchedulerSupport("none")
        public static <@NonNull T> @NonNull Observable<T> defer​(@NonNull
                                                                @NonNull Supplier<? extends @NonNull ObservableSource<? extends @NonNull T>> supplier)
        Returns an Observable that calls an ObservableSource factory to create an ObservableSource for each new Observer that subscribes. That is, for each subscriber, the actual ObservableSource that subscriber observes is determined by the factory function.

        The defer operator allows you to defer or delay emitting items from an ObservableSource until such time as an Observer subscribes to the ObservableSource. This allows an Observer to easily obtain updates or a refreshed version of the sequence.

        Scheduler:
        defer does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the type of the items emitted by the ObservableSource
        Parameters:
        supplier - the ObservableSource factory function to invoke for each Observer that subscribes to the resulting Observable
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if supplier is null
        See Also:
        ReactiveX operators documentation: Defer
      • fromCallable

        @CheckReturnValue
        @NonNull
        @SchedulerSupport("none")
        public static <@NonNull T> @NonNull Observable<T> fromCallable​(@NonNull
                                                                       @NonNull java.util.concurrent.Callable<? extends @NonNull T> callable)
        Returns an Observable that, when an observer subscribes to it, invokes a function you specify and then emits the value returned from that function.

        This allows you to defer the execution of the function you specify until an observer subscribes to the Observable. That is to say, it makes the function "lazy."

        Scheduler:
        fromCallable does not operate by default on a particular Scheduler.
        Error handling:
        If the Callable throws an exception, the respective Throwable is delivered to the downstream via Observer.onError(Throwable), except when the downstream has disposed the current Observable source. In this latter case, the Throwable is delivered to the global error handler via RxJavaPlugins.onError(Throwable) as an UndeliverableException.
        Type Parameters:
        T - the type of the item returned by the Callable and emitted by the Observable
        Parameters:
        callable - a function, the execution of which should be deferred; fromCallable will invoke this function only when an observer subscribes to the Observable that fromCallable returns
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if callable is null
        Since:
        2.0
        See Also:
        defer(Supplier), fromSupplier(Supplier)
      • fromFuture

        @CheckReturnValue
        @NonNull
        @SchedulerSupport("none")
        public static <@NonNull T> @NonNull Observable<T> fromFuture​(@NonNull
                                                                     @NonNull java.util.concurrent.Future<? extends @NonNull T> future)
        Converts a Future into an Observable.

        The operator calls Future.get(), which is a blocking method, on the subscription thread. It is recommended applying subscribeOn(Scheduler) to move this blocking wait to a background thread, and if the Scheduler supports it, interrupt the wait when the flow is disposed.

        Unlike 1.x, disposing the Observable won't cancel the future. If necessary, one can use composition to achieve the cancellation effect: futureObservableSource.doOnDispose(() -> future.cancel(true));.

        Also note that this operator will consume a CompletionStage-based Future subclass (such as CompletableFuture) in a blocking manner as well. Use the fromCompletionStage(CompletionStage) operator to convert and consume such sources in a non-blocking fashion instead.

        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 Observable
        Parameters:
        future - the source Future
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if future is null
        See Also:
        ReactiveX operators documentation: From, fromCompletionStage(CompletionStage)
      • fromFuture

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

        The operator calls Future.get(long, TimeUnit), which is a blocking method, on the subscription thread. It is recommended applying subscribeOn(Scheduler) to move this blocking wait to a background thread, and if the Scheduler supports it, interrupt the wait when the flow is disposed.

        Unlike 1.x, disposing the Observable won't cancel the future. If necessary, one can use composition to achieve the cancellation effect: futureObservableSource.doOnDispose(() -> future.cancel(true));.

        Also note that this operator will consume a CompletionStage-based Future subclass (such as CompletableFuture) in a blocking manner as well. Use the fromCompletionStage(CompletionStage) operator to convert and consume such sources in a non-blocking fashion instead.

        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 Observable
        Parameters:
        future - the source Future
        timeout - the maximum time to wait before calling get
        unit - the TimeUnit of the timeout argument
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if future or unit is null
        See Also:
        ReactiveX operators documentation: From, fromCompletionStage(CompletionStage)
      • fromMaybe

        @CheckReturnValue
        @NonNull
        @SchedulerSupport("none")
        public static <@NonNull T> @NonNull Observable<T> fromMaybe​(@NonNull
                                                                    @NonNull MaybeSource<@NonNull T> maybe)
        Returns an Observable instance that when subscribed to, subscribes to the MaybeSource instance and emits onSuccess as a single item or forwards any onComplete or onError signal.

        Scheduler:
        fromMaybe does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the value type of the MaybeSource element
        Parameters:
        maybe - the MaybeSource instance to subscribe to, not null
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if maybe is null
        Since:
        3.0.0
      • fromPublisher

        @BackpressureSupport(UNBOUNDED_IN)
        @CheckReturnValue
        @NonNull
        @SchedulerSupport("none")
        public static <@NonNull T> @NonNull Observable<T> fromPublisher​(@NonNull
                                                                        @NonNull org.reactivestreams.Publisher<? extends @NonNull T> publisher)
        Converts an arbitrary Reactive Streams Publisher into an Observable.

        The Publisher must follow the Reactive-Streams specification. Violating the specification may result in undefined behavior.

        If possible, use create(ObservableOnSubscribe) to create a source-like Observable instead.

        Note that even though Publisher appears to be a functional interface, it is not recommended to implement it through a lambda as the specification requires state management that is not achievable with a stateless lambda.

        Backpressure:
        The source publisher is consumed in an unbounded fashion without applying any backpressure to it.
        Scheduler:
        fromPublisher does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the value type of the flow
        Parameters:
        publisher - the Publisher to convert
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if publisher is null
        See Also:
        create(ObservableOnSubscribe)
      • fromRunnable

        @CheckReturnValue
        @NonNull
        @SchedulerSupport("none")
        public static <@NonNull T> @NonNull Observable<T> fromRunnable​(@NonNull
                                                                       @NonNull java.lang.Runnable run)
        Returns an Observable instance that runs the given Runnable for each Observer and emits either its unchecked exception or simply completes.

        If the code to be wrapped needs to throw a checked or more broader Throwable exception, that exception has to be converted to an unchecked exception by the wrapped code itself. Alternatively, use the fromAction(Action) method which allows the wrapped code to throw any Throwable exception and will signal it to observers as-is.

        Scheduler:
        fromRunnable does not operate by default on a particular Scheduler.
        Error handling:
        If the Runnable throws an exception, the respective Throwable is delivered to the downstream via Observer.onError(Throwable), except when the downstream has canceled the resulting Observable source. In this latter case, the Throwable is delivered to the global error handler via RxJavaPlugins.onError(Throwable) as an UndeliverableException.
        Type Parameters:
        T - the target type
        Parameters:
        run - the Runnable to run for each Observer
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if run is null
        Since:
        3.0.0
        See Also:
        fromAction(Action)
      • fromSingle

        @CheckReturnValue
        @NonNull
        @SchedulerSupport("none")
        public static <@NonNull T> @NonNull Observable<T> fromSingle​(@NonNull
                                                                     @NonNull SingleSource<@NonNull T> source)
        Returns an Observable instance that when subscribed to, subscribes to the SingleSource instance and emits onSuccess as a single item or forwards the onError signal.

        Scheduler:
        fromSingle does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the value type of the SingleSource element
        Parameters:
        source - the SingleSource instance to subscribe to, not null
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if source is null
        Since:
        3.0.0
      • fromSupplier

        @CheckReturnValue
        @NonNull
        @SchedulerSupport("none")
        public static <@NonNull T> @NonNull Observable<T> fromSupplier​(@NonNull
                                                                       @NonNull Supplier<? extends @NonNull T> supplier)
        Returns an Observable that, when an observer subscribes to it, invokes a supplier function you specify and then emits the value returned from that function.

        This allows you to defer the execution of the function you specify until an observer subscribes to the Observable. That is to say, it makes the function "lazy."

        Scheduler:
        fromSupplier does not operate by default on a particular Scheduler.
        Error handling:
        If the Supplier throws an exception, the respective Throwable is delivered to the downstream via Observer.onError(Throwable), except when the downstream has disposed the current Observable source. In this latter case, the Throwable is delivered to the global error handler via RxJavaPlugins.onError(Throwable) as an UndeliverableException.
        Type Parameters:
        T - the type of the item emitted by the Observable
        Parameters:
        supplier - a function, the execution of which should be deferred; fromSupplier will invoke this function only when an observer subscribes to the Observable that fromSupplier returns
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if supplier is null
        Since:
        3.0.0
        See Also:
        defer(Supplier), fromCallable(Callable)
      • generate

        @CheckReturnValue
        @NonNull
        @SchedulerSupport("none")
        public static <@NonNull T> @NonNull Observable<T> generate​(@NonNull
                                                                   @NonNull Consumer<Emitter<@NonNull T>> generator)
        Returns a cold, synchronous and stateless generator of values.

        Note that the Emitter.onNext(T), Emitter.onError(java.lang.Throwable) and Emitter.onComplete() methods provided to the function via the Emitter instance should be called synchronously, never concurrently and only while the function body is executing. Calling them from multiple threads or outside the function call is not supported and leads to an undefined behavior.

        Scheduler:
        generate does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the generated value type
        Parameters:
        generator - the Consumer called in a loop after a downstream Observer has subscribed. The callback then should call onNext, onError or onComplete to signal a value or a terminal event. Signaling multiple onNext in a call will make the operator signal IllegalStateException.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if generator is null
      • generate

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T,​@NonNull S> @NonNull Observable<T> generate​(@NonNull
                                                                                    @NonNull Supplier<@NonNull S> initialState,
                                                                                    @NonNull
                                                                                    @NonNull BiFunction<@NonNull S,​Emitter<@NonNull T>,​@NonNull S> generator)
        Returns a cold, synchronous and stateful generator of values.

        Note that the Emitter.onNext(T), Emitter.onError(java.lang.Throwable) and Emitter.onComplete() methods provided to the function via the Emitter instance should be called synchronously, never concurrently and only while the function body is executing. Calling them from multiple threads or outside the function call is not supported and leads to an undefined behavior.

        Scheduler:
        generate does not operate by default on a particular Scheduler.
        Type Parameters:
        S - the type of the per-Observer state
        T - the generated value type
        Parameters:
        initialState - the Supplier to generate the initial state for each Observer
        generator - the BiConsumer called in a loop after a downstream Observer has subscribed. The callback then should call onNext, onError or onComplete to signal a value or a terminal event and should return a (new) state for the next invocation. Signaling multiple onNext in a call will make the operator signal IllegalStateException.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if initialState or generator is null
      • generate

        @CheckReturnValue
        @NonNull
        @SchedulerSupport("none")
        public static <@NonNull T,​@NonNull S> @NonNull Observable<T> generate​(@NonNull
                                                                                    @NonNull Supplier<@NonNull S> initialState,
                                                                                    @NonNull
                                                                                    @NonNull BiFunction<@NonNull S,​Emitter<@NonNull T>,​@NonNull S> generator,
                                                                                    @NonNull
                                                                                    @NonNull Consumer<? super @NonNull S> disposeState)
        Returns a cold, synchronous and stateful generator of values.

        Note that the Emitter.onNext(T), Emitter.onError(java.lang.Throwable) and Emitter.onComplete() methods provided to the function via the Emitter instance should be called synchronously, never concurrently and only while the function body is executing. Calling them from multiple threads or outside the function call is not supported and leads to an undefined behavior.

        Scheduler:
        generate does not operate by default on a particular Scheduler.
        Type Parameters:
        S - the type of the per-Observer state
        T - the generated value type
        Parameters:
        initialState - the Supplier to generate the initial state for each Observer
        generator - the BiConsumer called in a loop after a downstream Observer has subscribed. The callback then should call onNext, onError or onComplete to signal a value or a terminal event and should return a (new) state for the next invocation. Signaling multiple onNext in a call will make the operator signal IllegalStateException.
        disposeState - the Consumer that is called with the current state when the generator terminates the sequence or it gets disposed
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if initialState, generator or disposeState is null
      • interval

        @CheckReturnValue
        @SchedulerSupport("io.reactivex:computation")
        @NonNull
        public static @NonNull Observable<java.lang.Long> interval​(long initialDelay,
                                                                   long period,
                                                                   @NonNull
                                                                   @NonNull java.util.concurrent.TimeUnit unit)
        Returns an Observable that emits a 0L after the initialDelay and ever increasing numbers after each period of time thereafter.

        Scheduler:
        interval operates by default on the computation Scheduler.
        Parameters:
        initialDelay - the initial delay time to wait before emitting the first value of 0L
        period - the period of time between emissions of the subsequent numbers
        unit - the time unit for both initialDelay and period
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit is null
        Since:
        1.0.12
        See Also:
        ReactiveX operators documentation: Interval
      • interval

        @CheckReturnValue
        @NonNull
        @SchedulerSupport("custom")
        public static @NonNull Observable<java.lang.Long> interval​(long initialDelay,
                                                                   long period,
                                                                   @NonNull
                                                                   @NonNull java.util.concurrent.TimeUnit unit,
                                                                   @NonNull
                                                                   @NonNull Scheduler scheduler)
        Returns an Observable that emits a 0L after the initialDelay and ever increasing numbers after each period of time thereafter, on a specified Scheduler.

        Scheduler:
        You specify which Scheduler this operator will use.
        Parameters:
        initialDelay - the initial delay time to wait before emitting the first value of 0L
        period - the period of time between emissions of the subsequent numbers
        unit - the time unit for both initialDelay and period
        scheduler - the Scheduler on which the waiting happens and items are emitted
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null
        Since:
        1.0.12
        See Also:
        ReactiveX operators documentation: Interval
      • intervalRange

        @CheckReturnValue
        @NonNull
        @SchedulerSupport("io.reactivex:computation")
        public static @NonNull Observable<java.lang.Long> intervalRange​(long start,
                                                                        long count,
                                                                        long initialDelay,
                                                                        long period,
                                                                        @NonNull
                                                                        @NonNull java.util.concurrent.TimeUnit unit)
        Signals a range of long values, the first after some initial delay and the rest periodically after.

        The sequence completes immediately after the last value (start + count - 1) has been reached.

        Scheduler:
        intervalRange by default operates on the computation Scheduler.
        Parameters:
        start - that start value of the range
        count - the number of values to emit in total, if zero, the operator emits an onComplete after the initial delay.
        initialDelay - the initial delay before signaling the first value (the start)
        period - the period between subsequent values
        unit - the unit of measure of the initialDelay and period amounts
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit is null
        java.lang.IllegalArgumentException - if count is negative, or if start + count − 1 exceeds Long.MAX_VALUE
        See Also:
        range(int, int)
      • intervalRange

        @CheckReturnValue
        @NonNull
        @SchedulerSupport("custom")
        public static @NonNull Observable<java.lang.Long> intervalRange​(long start,
                                                                        long count,
                                                                        long initialDelay,
                                                                        long period,
                                                                        @NonNull
                                                                        @NonNull java.util.concurrent.TimeUnit unit,
                                                                        @NonNull
                                                                        @NonNull Scheduler scheduler)
        Signals a range of long values, the first after some initial delay and the rest periodically after.

        The sequence completes immediately after the last value (start + count - 1) has been reached.

        *

        Scheduler:
        you provide the Scheduler.
        Parameters:
        start - that start value of the range
        count - the number of values to emit in total, if zero, the operator emits an onComplete after the initial delay.
        initialDelay - the initial delay before signaling the first value (the start)
        period - the period between subsequent values
        unit - the unit of measure of the initialDelay and period amounts
        scheduler - the target scheduler where the values and terminal signals will be emitted
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null
        java.lang.IllegalArgumentException - if count is negative, or if start + count − 1 exceeds Long.MAX_VALUE
      • merge

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T> @NonNull Observable<T> merge​(@NonNull
                                                                @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources,
                                                                int maxConcurrency,
                                                                int bufferSize)
        Flattens an Iterable of ObservableSources into one Observable, without any transformation, while limiting the number of concurrent subscriptions to these ObservableSources.

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

        Scheduler:
        merge does not operate by default on a particular Scheduler.
        Error handling:
        If any of the returned ObservableSources signal a Throwable via onError, the resulting Observable terminates with that Throwable and all other source ObservableSources are disposed. If more than one ObservableSource signals an error, the resulting Observable may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with a CompositeException containing two or more of the various error signals. Throwables that didn't make into the composite will be sent (individually) to the global error handler via RxJavaPlugins.onError(Throwable) method as UndeliverableException errors. Similarly, Throwables signaled by source(s) after the returned Observable has been disposed or terminated with a (composite) error will be sent to the same global error handler. Use mergeDelayError(Iterable, int, int) to merge sources and terminate only when all source ObservableSources have completed or failed with an error.
        Type Parameters:
        T - the common element base type
        Parameters:
        sources - the Iterable of ObservableSources
        maxConcurrency - the maximum number of ObservableSources that may be subscribed to concurrently
        bufferSize - the number of items expected from each inner ObservableSource to be buffered
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if sources is null
        java.lang.IllegalArgumentException - if maxConcurrency or bufferSize is non-positive
        See Also:
        ReactiveX operators documentation: Merge, mergeDelayError(Iterable, int, int)
      • mergeArray

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        @SafeVarargs
        public static <@NonNull T> @NonNull Observable<T> mergeArray​(int maxConcurrency,
                                                                     int bufferSize,
                                                                     @NonNull
                                                                     @NonNull ObservableSource<? extends @NonNull T>... sources)
        Flattens an array of ObservableSources into one Observable, without any transformation, while limiting the number of concurrent subscriptions to these ObservableSources.

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

        Scheduler:
        mergeArray does not operate by default on a particular Scheduler.
        Error handling:
        If any of the ObservableSources signal a Throwable via onError, the resulting Observable terminates with that Throwable and all other source ObservableSources are disposed. If more than one ObservableSource signals an error, the resulting Observable may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with a CompositeException containing two or more of the various error signals. Throwables that didn't make into the composite will be sent (individually) to the global error handler via RxJavaPlugins.onError(Throwable) method as UndeliverableException errors. Similarly, Throwables signaled by source(s) after the returned Observable has been disposed or terminated with a (composite) error will be sent to the same global error handler. Use mergeArrayDelayError(int, int, ObservableSource...) to merge sources and terminate only when all source ObservableSources have completed or failed with an error.
        Type Parameters:
        T - the common element base type
        Parameters:
        sources - the array of ObservableSources
        maxConcurrency - the maximum number of ObservableSources that may be subscribed to concurrently
        bufferSize - the number of items expected from each inner ObservableSource to be buffered
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if sources is null
        java.lang.IllegalArgumentException - if maxConcurrency or bufferSize is non-positive
        See Also:
        ReactiveX operators documentation: Merge, mergeArrayDelayError(int, int, ObservableSource...)
      • merge

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T> @NonNull Observable<T> merge​(@NonNull
                                                                @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources)
        Flattens an Iterable of ObservableSources into one Observable, without any transformation.

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

        Scheduler:
        merge does not operate by default on a particular Scheduler.
        Error handling:
        If any of the returned ObservableSources signal a Throwable via onError, the resulting Observable terminates with that Throwable and all other source ObservableSources are disposed. If more than one ObservableSource signals an error, the resulting Observable may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with a CompositeException containing two or more of the various error signals. Throwables that didn't make into the composite will be sent (individually) to the global error handler via RxJavaPlugins.onError(Throwable) method as UndeliverableException errors. Similarly, Throwables signaled by source(s) after the returned Observable has been disposed or terminated with a (composite) error will be sent to the same global error handler. Use mergeDelayError(Iterable) to merge sources and terminate only when all source ObservableSources have completed or failed with an error.
        Type Parameters:
        T - the common element base type
        Parameters:
        sources - the Iterable of ObservableSources
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if sources is null
        See Also:
        ReactiveX operators documentation: Merge, mergeDelayError(Iterable)
      • merge

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T> @NonNull Observable<T> merge​(@NonNull
                                                                @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources,
                                                                int maxConcurrency)
        Flattens an Iterable of ObservableSources into one Observable, without any transformation, while limiting the number of concurrent subscriptions to these ObservableSources.

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

        Scheduler:
        merge does not operate by default on a particular Scheduler.
        Error handling:
        If any of the returned ObservableSources signal a Throwable via onError, the resulting Observable terminates with that Throwable and all other source ObservableSources are disposed. If more than one ObservableSource signals an error, the resulting Observable may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with a CompositeException containing two or more of the various error signals. Throwables that didn't make into the composite will be sent (individually) to the global error handler via RxJavaPlugins.onError(Throwable) method as UndeliverableException errors. Similarly, Throwables signaled by source(s) after the returned Observable has been disposed or terminated with a (composite) error will be sent to the same global error handler. Use mergeDelayError(Iterable, int) to merge sources and terminate only when all source ObservableSources have completed or failed with an error.
        Type Parameters:
        T - the common element base type
        Parameters:
        sources - the Iterable of ObservableSources
        maxConcurrency - the maximum number of ObservableSources that may be subscribed to concurrently
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if sources is null
        java.lang.IllegalArgumentException - if maxConcurrency is less than or equal to 0
        See Also:
        ReactiveX operators documentation: Merge, mergeDelayError(Iterable, int)
      • merge

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T> @NonNull Observable<T> merge​(@NonNull
                                                                @NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources)
        Flattens an ObservableSource that emits ObservableSources into a single Observable that emits the items emitted by those ObservableSources, without any transformation.

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

        Scheduler:
        merge does not operate by default on a particular Scheduler.
        Error handling:
        If any of the returned ObservableSources signal a Throwable via onError, the resulting Observable terminates with that Throwable and all other source ObservableSources are disposed. If more than one ObservableSource signals an error, the resulting Observable may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with a CompositeException containing two or more of the various error signals. Throwables that didn't make into the composite will be sent (individually) to the global error handler via RxJavaPlugins.onError(Throwable) method as UndeliverableException errors. Similarly, Throwables signaled by source(s) after the returned Observable has been disposed or terminated with a (composite) error will be sent to the same global error handler. Use mergeDelayError(ObservableSource) to merge sources and terminate only when all source ObservableSources have completed or failed with an error.
        Type Parameters:
        T - the common element base type
        Parameters:
        sources - an ObservableSource that emits ObservableSources
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if sources is null
        See Also:
        ReactiveX operators documentation: Merge, mergeDelayError(ObservableSource)
      • merge

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T> @NonNull Observable<T> merge​(@NonNull
                                                                @NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources,
                                                                int maxConcurrency)
        Flattens an ObservableSource that emits ObservableSources into a single Observable that emits the items emitted by those ObservableSources, without any transformation, while limiting the maximum number of concurrent subscriptions to these ObservableSources.

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

        Scheduler:
        merge does not operate by default on a particular Scheduler.
        Error handling:
        If any of the returned ObservableSources signal a Throwable via onError, the resulting Observable terminates with that Throwable and all other source ObservableSources are disposed. If more than one ObservableSource signals an error, the resulting Observable may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with a CompositeException containing two or more of the various error signals. Throwables that didn't make into the composite will be sent (individually) to the global error handler via RxJavaPlugins.onError(Throwable) method as UndeliverableException errors. Similarly, Throwables signaled by source(s) after the returned Observable has been disposed or terminated with a (composite) error will be sent to the same global error handler. Use mergeDelayError(ObservableSource, int) to merge sources and terminate only when all source ObservableSources have completed or failed with an error.
        Type Parameters:
        T - the common element base type
        Parameters:
        sources - an ObservableSource that emits ObservableSources
        maxConcurrency - the maximum number of ObservableSources that may be subscribed to concurrently
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if sources is null
        java.lang.IllegalArgumentException - if maxConcurrency is non-positive
        Since:
        1.1.0
        See Also:
        ReactiveX operators documentation: Merge, mergeDelayError(ObservableSource, int)
      • mergeArray

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        @SafeVarargs
        public static <@NonNull T> @NonNull Observable<T> mergeArray​(@NonNull
                                                                     @NonNull ObservableSource<? extends @NonNull T>... sources)
        Flattens an array of ObservableSources into one Observable, without any transformation.

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

        Scheduler:
        mergeArray does not operate by default on a particular Scheduler.
        Error handling:
        If any of the ObservableSources signal a Throwable via onError, the resulting Observable terminates with that Throwable and all other source ObservableSources are disposed. If more than one ObservableSource signals an error, the resulting Observable may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with a CompositeException containing two or more of the various error signals. Throwables that didn't make into the composite will be sent (individually) to the global error handler via RxJavaPlugins.onError(Throwable) method as UndeliverableException errors. Similarly, Throwables signaled by source(s) after the returned Observable has been disposed or terminated with a (composite) error will be sent to the same global error handler. Use mergeArrayDelayError(ObservableSource...) to merge sources and terminate only when all source ObservableSources have completed or failed with an error.
        Type Parameters:
        T - the common element base type
        Parameters:
        sources - the array of ObservableSources
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if sources is null
        See Also:
        ReactiveX operators documentation: Merge, mergeArrayDelayError(ObservableSource...)
      • mergeDelayError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T> @NonNull Observable<T> mergeDelayError​(@NonNull
                                                                          @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources)
        Flattens an Iterable of ObservableSources into one Observable, in a way that allows an Observer to receive all successfully emitted items from each of the returned ObservableSources without being interrupted by an error notification from one of them.

        This behaves like merge(ObservableSource) except that if any of the merged ObservableSources notify of an error via onError, mergeDelayError will refrain from propagating that error notification until all of the merged ObservableSources have finished emitting items.

        Even if multiple merged ObservableSources send onError notifications, mergeDelayError will only invoke the onError method of its Observers once.

        Scheduler:
        mergeDelayError does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the common element base type
        Parameters:
        sources - the Iterable of ObservableSources
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if sources is null
        See Also:
        ReactiveX operators documentation: Merge
      • mergeDelayError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T> @NonNull Observable<T> mergeDelayError​(@NonNull
                                                                          @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources,
                                                                          int maxConcurrency,
                                                                          int bufferSize)
        Flattens an Iterable of ObservableSources into one Observable, in a way that allows an Observer to receive all successfully emitted items from each of the returned ObservableSources without being interrupted by an error notification from one of them, while limiting the number of concurrent subscriptions to these ObservableSources.

        This behaves like merge(ObservableSource) except that if any of the merged ObservableSources notify of an error via onError, mergeDelayError will refrain from propagating that error notification until all of the merged ObservableSources have finished emitting items.

        Even if multiple merged ObservableSources send onError notifications, mergeDelayError will only invoke the onError method of its Observers once.

        Scheduler:
        mergeDelayError does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the common element base type
        Parameters:
        sources - the Iterable of ObservableSources
        maxConcurrency - the maximum number of ObservableSources that may be subscribed to concurrently
        bufferSize - the number of items expected from each inner ObservableSource to be buffered
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if sources is null
        java.lang.IllegalArgumentException - if maxConcurrency or bufferSize is non-positive
        See Also:
        ReactiveX operators documentation: Merge
      • mergeArrayDelayError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        @SafeVarargs
        public static <@NonNull T> @NonNull Observable<T> mergeArrayDelayError​(int maxConcurrency,
                                                                               int bufferSize,
                                                                               @NonNull
                                                                               @NonNull ObservableSource<? extends @NonNull T>... sources)
        Flattens an array of ObservableSources into one Observable, in a way that allows an Observer to receive all successfully emitted items from each of the ObservableSources without being interrupted by an error notification from one of them, while limiting the number of concurrent subscriptions to these ObservableSources.

        This behaves like merge(ObservableSource) except that if any of the merged ObservableSources notify of an error via onError, mergeDelayError will refrain from propagating that error notification until all of the merged ObservableSources have finished emitting items.

        Even if multiple merged ObservableSources send onError notifications, mergeDelayError will only invoke the onError method of its Observers once.

        Scheduler:
        mergeArrayDelayError does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the common element base type
        Parameters:
        sources - the array of ObservableSources
        maxConcurrency - the maximum number of ObservableSources that may be subscribed to concurrently
        bufferSize - the number of items expected from each inner ObservableSource to be buffered
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if sources is null
        java.lang.IllegalArgumentException - if maxConcurrency or bufferSize is non-positive
        See Also:
        ReactiveX operators documentation: Merge
      • mergeDelayError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T> @NonNull Observable<T> mergeDelayError​(@NonNull
                                                                          @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources,
                                                                          int maxConcurrency)
        Flattens an Iterable of ObservableSources into one Observable, in a way that allows an Observer to receive all successfully emitted items from each of the returned ObservableSources without being interrupted by an error notification from one of them, while limiting the number of concurrent subscriptions to these ObservableSources.

        This behaves like merge(ObservableSource) except that if any of the merged ObservableSources notify of an error via onError, mergeDelayError will refrain from propagating that error notification until all of the merged ObservableSources have finished emitting items.

        Even if multiple merged ObservableSources send onError notifications, mergeDelayError will only invoke the onError method of its Observers once.

        Scheduler:
        mergeDelayError does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the common element base type
        Parameters:
        sources - the Iterable of ObservableSources
        maxConcurrency - the maximum number of ObservableSources that may be subscribed to concurrently
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if sources is null
        java.lang.IllegalArgumentException - if maxConcurrency is non-positive
        See Also:
        ReactiveX operators documentation: Merge
      • mergeDelayError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T> @NonNull Observable<T> mergeDelayError​(@NonNull
                                                                          @NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources)
        Flattens an ObservableSource that emits ObservableSources into one Observable, in a way that allows an Observer to receive all successfully emitted items from all of the emitted ObservableSources without being interrupted by an error notification from one of them.

        This behaves like merge(ObservableSource) except that if any of the merged ObservableSources notify of an error via onError, mergeDelayError will refrain from propagating that error notification until all of the merged ObservableSources have finished emitting items.

        Even if multiple merged ObservableSources send onError notifications, mergeDelayError will only invoke the onError method of its Observers once.

        Scheduler:
        mergeDelayError does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the common element base type
        Parameters:
        sources - an ObservableSource that emits ObservableSources
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if sources is null
        See Also:
        ReactiveX operators documentation: Merge
      • mergeDelayError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T> @NonNull Observable<T> mergeDelayError​(@NonNull
                                                                          @NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources,
                                                                          int maxConcurrency)
        Flattens an ObservableSource that emits ObservableSources into one Observable, in a way that allows an Observer to receive all successfully emitted items from all of the emitted ObservableSources without being interrupted by an error notification from one of them, while limiting the number of concurrent subscriptions to these ObservableSources.

        This behaves like merge(ObservableSource) except that if any of the merged ObservableSources notify of an error via onError, mergeDelayError will refrain from propagating that error notification until all of the merged ObservableSources have finished emitting items.

        Even if multiple merged ObservableSources send onError notifications, mergeDelayError will only invoke the onError method of its Observers once.

        Scheduler:
        mergeDelayError does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the common element base type
        Parameters:
        sources - an ObservableSource that emits ObservableSources
        maxConcurrency - the maximum number of ObservableSources that may be subscribed to concurrently
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if sources is null
        java.lang.IllegalArgumentException - if maxConcurrency is non-positive
        Since:
        2.0
        See Also:
        ReactiveX operators documentation: Merge
      • mergeArrayDelayError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        @SafeVarargs
        public static <@NonNull T> @NonNull Observable<T> mergeArrayDelayError​(@NonNull
                                                                               @NonNull ObservableSource<? extends @NonNull T>... sources)
        Flattens an array of ObservableSources into one Observable, in a way that allows an Observer to receive all successfully emitted items from each of the ObservableSources without being interrupted by an error notification from one of them.

        This behaves like merge(ObservableSource) except that if any of the merged ObservableSources notify of an error via onError, mergeDelayError will refrain from propagating that error notification until all of the merged ObservableSources have finished emitting items.

        Even if multiple merged ObservableSources send onError notifications, mergeDelayError will only invoke the onError method of its Observers once.

        Scheduler:
        mergeArrayDelayError does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the common element base type
        Parameters:
        sources - the array of ObservableSources
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if sources is null
        See Also:
        ReactiveX operators documentation: Merge
      • switchOnNext

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T> @NonNull Observable<T> switchOnNext​(@NonNull
                                                                       @NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources,
                                                                       int bufferSize)
        Converts an ObservableSource that emits ObservableSources into an Observable that emits the items emitted by the most recently emitted of those ObservableSources.

        switchOnNext subscribes to an ObservableSource that emits ObservableSources. Each time it observes one of these emitted ObservableSources, the ObservableSource returned by switchOnNext begins emitting the items emitted by that ObservableSource. When a new inner ObservableSource is emitted, switchOnNext stops emitting items from the earlier-emitted ObservableSource and begins emitting items from the new one.

        The resulting Observable completes if both the outer ObservableSource and the last inner ObservableSource, if any, complete. If the outer ObservableSource signals an onError, the inner ObservableSource is disposed and the error delivered in-sequence.

        Scheduler:
        switchOnNext does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the item type
        Parameters:
        sources - the ObservableSource that emits ObservableSources
        bufferSize - the expected number of items to cache from the inner ObservableSources
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if sources is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        See Also:
        ReactiveX operators documentation: Switch
      • switchOnNext

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T> @NonNull Observable<T> switchOnNext​(@NonNull
                                                                       @NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources)
        Converts an ObservableSource that emits ObservableSources into an Observable that emits the items emitted by the most recently emitted of those ObservableSources.

        switchOnNext subscribes to an ObservableSource that emits ObservableSources. Each time it observes one of these emitted ObservableSources, the ObservableSource returned by switchOnNext begins emitting the items emitted by that ObservableSource. When a new inner ObservableSource is emitted, switchOnNext stops emitting items from the earlier-emitted ObservableSource and begins emitting items from the new one.

        The resulting Observable completes if both the outer ObservableSource and the last inner ObservableSource, if any, complete. If the outer ObservableSource signals an onError, the inner ObservableSource is disposed and the error delivered in-sequence.

        Scheduler:
        switchOnNext does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the item type
        Parameters:
        sources - the ObservableSource that emits ObservableSources
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if sources is null
        See Also:
        ReactiveX operators documentation: Switch
      • switchOnNextDelayError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T> @NonNull Observable<T> switchOnNextDelayError​(@NonNull
                                                                                 @NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources)
        Converts an ObservableSource that emits ObservableSources into an Observable that emits the items emitted by the most recently emitted of those ObservableSources and delays any exception until all ObservableSources terminate.

        switchOnNext subscribes to an ObservableSource that emits ObservableSources. Each time it observes one of these emitted ObservableSources, the ObservableSource returned by switchOnNext begins emitting the items emitted by that ObservableSource. When a new inner ObservableSource is emitted, switchOnNext stops emitting items from the earlier-emitted ObservableSource and begins emitting items from the new one.

        The resulting Observable completes if both the main ObservableSource and the last inner ObservableSource, if any, complete. If the main ObservableSource signals an onError, the termination of the last inner ObservableSource will emit that error as is or wrapped into a CompositeException along with the other possible errors the former inner ObservableSources signaled.

        Scheduler:
        switchOnNextDelayError does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the item type
        Parameters:
        sources - the ObservableSource that emits ObservableSources
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if sources is null
        Since:
        2.0
        See Also:
        ReactiveX operators documentation: Switch
      • switchOnNextDelayError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T> @NonNull Observable<T> switchOnNextDelayError​(@NonNull
                                                                                 @NonNull ObservableSource<? extends ObservableSource<? extends @NonNull T>> sources,
                                                                                 int bufferSize)
        Converts an ObservableSource that emits ObservableSources into an Observable that emits the items emitted by the most recently emitted of those ObservableSources and delays any exception until all ObservableSources terminate.

        switchOnNext subscribes to an ObservableSource that emits ObservableSources. Each time it observes one of these emitted ObservableSources, the ObservableSource returned by switchOnNext begins emitting the items emitted by that ObservableSource. When a new inner ObservableSource is emitted, switchOnNext stops emitting items from the earlier-emitted ObservableSource and begins emitting items from the new one.

        The resulting Observable completes if both the main ObservableSource and the last inner ObservableSource, if any, complete. If the main ObservableSource signals an onError, the termination of the last inner ObservableSource will emit that error as is or wrapped into a CompositeException along with the other possible errors the former inner ObservableSources signaled.

        Scheduler:
        switchOnNextDelayError does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the item type
        Parameters:
        sources - the ObservableSource that emits ObservableSources
        bufferSize - the expected number of items to cache from the inner ObservableSources
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if sources is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        Since:
        2.0
        See Also:
        ReactiveX operators documentation: Switch
      • unsafeCreate

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T> @NonNull Observable<T> unsafeCreate​(@NonNull
                                                                       @NonNull ObservableSource<@NonNull T> onSubscribe)
        Create an Observable by wrapping an ObservableSource which has to be implemented according to the Observable specification derived from the Reactive Streams specification by handling disposal correctly; no safeguards are provided by the Observable itself.
        Scheduler:
        unsafeCreate by default doesn't operate on any particular Scheduler.
        Type Parameters:
        T - the value type emitted
        Parameters:
        onSubscribe - the ObservableSource instance to wrap
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if onSubscribe is null
        java.lang.IllegalArgumentException - if the onSubscribe is already an Observable, use wrap(ObservableSource) in this case
        See Also:
        wrap(ObservableSource)
      • using

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T,​@NonNull D> @NonNull Observable<T> using​(@NonNull
                                                                                 @NonNull Supplier<? extends @NonNull D> resourceSupplier,
                                                                                 @NonNull
                                                                                 @NonNull Function<? super @NonNull D,​? extends ObservableSource<? extends @NonNull T>> sourceSupplier,
                                                                                 @NonNull
                                                                                 @NonNull Consumer<? super @NonNull D> resourceCleanup,
                                                                                 boolean eager)
        Constructs an Observable that creates a dependent resource object, an ObservableSource with that resource and calls the provided disposer function if this inner source terminates or the downstream disposes the flow; doing it before these end-states have been reached if eager == true, after otherwise.

        Scheduler:
        using does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the element type of the generated ObservableSource
        D - the type of the resource associated with the output sequence
        Parameters:
        resourceSupplier - the factory function to create a resource object that depends on the ObservableSource
        sourceSupplier - the factory function to create an ObservableSource
        resourceCleanup - the function that will dispose of the resource
        eager - If true, the resource disposal will happen either on a dispose() call before the upstream is disposed or just before the emission of a terminal event (onComplete or onError). If false, the resource disposal will happen either on a dispose() call after the upstream is disposed or just after the emission of a terminal event (onComplete or onError).
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if resourceSupplier, sourceSupplier and resourceCleanup is null
        Since:
        2.0
        See Also:
        ReactiveX operators documentation: Using
      • zip

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T,​@NonNull R> @NonNull Observable<R> zip​(@NonNull
                                                                               @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources,
                                                                               @NonNull
                                                                               @NonNull Function<? super java.lang.Object[],​? extends @NonNull R> zipper)
        Returns an Observable that emits the results of a specified combiner function applied to combinations of items emitted, in sequence, by an Iterable of other ObservableSources.

        zip applies this function in strict sequence, so the first item emitted by the resulting Observable will be the result of the function applied to the first item emitted by each of the ObservableSources; the second item emitted by the resulting Observable will be the result of the function applied to the second item emitted by each of those ObservableSources; and so forth.

        The resulting Observable<R> returned from zip will invoke onNext as many times as the number of onNext invocations of the ObservableSource that emits the fewest items.

        The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling doOnComplete()). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will dispose B immediately. For example:

        zip(Arrays.asList(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2)), (a) -> a)
        action1 will be called but action2 won't.
        To work around this termination property, use doOnDispose(Action) as well or use using() to do cleanup in case of completion or a dispose() call.

        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.

        Scheduler:
        zip does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the common value type
        R - the zipped result type
        Parameters:
        sources - an Iterable of source ObservableSources
        zipper - a function that, when applied to an item emitted by each of the ObservableSources, results in an item that will be emitted by the resulting Observable
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if sources or zipper is null
        See Also:
        ReactiveX operators documentation: Zip
      • zip

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T,​@NonNull R> @NonNull Observable<R> zip​(@NonNull
                                                                               @NonNull java.lang.Iterable<? extends ObservableSource<? extends @NonNull T>> sources,
                                                                               @NonNull
                                                                               @NonNull Function<? super java.lang.Object[],​? extends @NonNull R> zipper,
                                                                               boolean delayError,
                                                                               int bufferSize)
        Returns an Observable that emits the results of a specified combiner function applied to combinations of items emitted, in sequence, by an Iterable of other ObservableSources.

        zip applies this function in strict sequence, so the first item emitted by the resulting Observable will be the result of the function applied to the first item emitted by each of the ObservableSources; the second item emitted by the resulting Observable will be the result of the function applied to the second item emitted by each of those ObservableSources; and so forth.

        The resulting Observable<R> returned from zip will invoke onNext as many times as the number of onNext invocations of the ObservableSource that emits the fewest items.

        The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling doOnComplete()). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will dispose B immediately. For example:

        zip(Arrays.asList(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2)), (a) -> a)
        action1 will be called but action2 won't.
        To work around this termination property, use doOnDispose(Action) as well or use using() to do cleanup in case of completion or a dispose() call.

        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.

        Scheduler:
        zip does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the common source value type
        R - the zipped result type
        Parameters:
        sources - an Iterable of source ObservableSources
        zipper - a function that, when applied to an item emitted by each of the ObservableSources, results in an item that will be emitted by the resulting Observable
        delayError - delay errors signaled by any of the ObservableSource until all ObservableSources terminate
        bufferSize - the number of elements expected from each source ObservableSource to be buffered
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if sources or zipper is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        See Also:
        ReactiveX operators documentation: Zip
      • zip

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T1,​@NonNull T2,​@NonNull R> @NonNull Observable<R> zip​(@NonNull
                                                                                                  @NonNull ObservableSource<? extends @NonNull T1> source1,
                                                                                                  @NonNull
                                                                                                  @NonNull ObservableSource<? extends @NonNull T2> source2,
                                                                                                  @NonNull
                                                                                                  @NonNull BiFunction<? super @NonNull T1,​? super @NonNull T2,​? extends @NonNull R> zipper)
        Returns an Observable that emits the results of a specified combiner function applied to combinations of two items emitted, in sequence, by two other ObservableSources.

        zip applies this function in strict sequence, so the first item emitted by the resulting Observable will be the result of the function applied to the first item emitted by o1 and the first item emitted by o2; the second item emitted by the resulting Observable will be the result of the function applied to the second item emitted by o1 and the second item emitted by o2; and so forth.

        The resulting Observable<R> returned from zip will invoke onNext as many times as the number of onNext invocations of the ObservableSource that emits the fewest items.

        The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling doOnComplete()). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will dispose B immediately. For example:

        zip(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2), (a, b) -> a + b)
        action1 will be called but action2 won't.
        To work around this termination property, use doOnDispose(Action) as well or use using() to do cleanup in case of completion or a dispose() call.
        Scheduler:
        zip does not operate by default on a particular Scheduler.
        Type Parameters:
        T1 - the value type of the first source
        T2 - the value type of the second source
        R - the zipped result type
        Parameters:
        source1 - the first source ObservableSource
        source2 - a second source ObservableSource
        zipper - a function that, when applied to an item emitted by each of the ObservableSources, results in an item that will be emitted by the resulting Observable
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if source1, source2 or zipper is null
        See Also:
        ReactiveX operators documentation: Zip
      • zip

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T1,​@NonNull T2,​@NonNull R> @NonNull Observable<R> zip​(@NonNull
                                                                                                  @NonNull ObservableSource<? extends @NonNull T1> source1,
                                                                                                  @NonNull
                                                                                                  @NonNull ObservableSource<? extends @NonNull T2> source2,
                                                                                                  @NonNull
                                                                                                  @NonNull BiFunction<? super @NonNull T1,​? super @NonNull T2,​? extends @NonNull R> zipper,
                                                                                                  boolean delayError)
        Returns an Observable that emits the results of a specified combiner function applied to combinations of two items emitted, in sequence, by two other ObservableSources.

        zip applies this function in strict sequence, so the first item emitted by the resulting Observable will be the result of the function applied to the first item emitted by o1 and the first item emitted by o2; the second item emitted by the resulting Observable will be the result of the function applied to the second item emitted by o1 and the second item emitted by o2; and so forth.

        The resulting Observable<R> returned from zip will invoke onNext as many times as the number of onNext invocations of the ObservableSource that emits the fewest items.

        The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling doOnComplete()). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will dispose B immediately. For example:

        zip(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2), (a, b) -> a + b)
        action1 will be called but action2 won't.
        To work around this termination property, use doOnDispose(Action) as well or use using() to do cleanup in case of completion or a dispose() call.
        Scheduler:
        zip does not operate by default on a particular Scheduler.
        Type Parameters:
        T1 - the value type of the first source
        T2 - the value type of the second source
        R - the zipped result type
        Parameters:
        source1 - the first source ObservableSource
        source2 - a second source ObservableSource
        zipper - a function that, when applied to an item emitted by each of the ObservableSources, results in an item that will be emitted by the resulting Observable
        delayError - delay errors from any of the ObservableSources till the other terminates
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if source1, source2 or zipper is null
        See Also:
        ReactiveX operators documentation: Zip
      • zip

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T1,​@NonNull T2,​@NonNull R> @NonNull Observable<R> zip​(@NonNull
                                                                                                  @NonNull ObservableSource<? extends @NonNull T1> source1,
                                                                                                  @NonNull
                                                                                                  @NonNull ObservableSource<? extends @NonNull T2> source2,
                                                                                                  @NonNull
                                                                                                  @NonNull BiFunction<? super @NonNull T1,​? super @NonNull T2,​? extends @NonNull R> zipper,
                                                                                                  boolean delayError,
                                                                                                  int bufferSize)
        Returns an Observable that emits the results of a specified combiner function applied to combinations of two items emitted, in sequence, by two other ObservableSources.

        zip applies this function in strict sequence, so the first item emitted by the resulting Observable will be the result of the function applied to the first item emitted by o1 and the first item emitted by o2; the second item emitted by the resulting Observable will be the result of the function applied to the second item emitted by o1 and the second item emitted by o2; and so forth.

        The resulting Observable<R> returned from zip will invoke onNext as many times as the number of onNext invocations of the ObservableSource that emits the fewest items.

        The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling doOnComplete()). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will dispose B immediately. For example:

        zip(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2), (a, b) -> a + b)
        action1 will be called but action2 won't.
        To work around this termination property, use doOnDispose(Action) as well or use using() to do cleanup in case of completion or a dispose() call.
        Scheduler:
        zip does not operate by default on a particular Scheduler.
        Type Parameters:
        T1 - the value type of the first source
        T2 - the value type of the second source
        R - the zipped result type
        Parameters:
        source1 - the first source ObservableSource
        source2 - a second source ObservableSource
        zipper - a function that, when applied to an item emitted by each of the ObservableSources, results in an item that will be emitted by the resulting Observable
        delayError - delay errors from any of the ObservableSources till the other terminates
        bufferSize - the number of elements expected from each source ObservableSource to be buffered
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if source1, source2 or zipper is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        See Also:
        ReactiveX operators documentation: Zip
      • zip

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T1,​@NonNull T2,​@NonNull T3,​@NonNull R> @NonNull Observable<R> zip​(@NonNull
                                                                                                                    @NonNull ObservableSource<? extends @NonNull T1> source1,
                                                                                                                    @NonNull
                                                                                                                    @NonNull ObservableSource<? extends @NonNull T2> source2,
                                                                                                                    @NonNull
                                                                                                                    @NonNull ObservableSource<? extends @NonNull T3> source3,
                                                                                                                    @NonNull
                                                                                                                    @NonNull Function3<? super @NonNull T1,​? super @NonNull T2,​? super @NonNull T3,​? extends @NonNull R> zipper)
        Returns an Observable that emits the results of a specified combiner function applied to combinations of three items emitted, in sequence, by three other ObservableSources.

        zip applies this function in strict sequence, so the first item emitted by the resulting Observable will be the result of the function applied to the first item emitted by o1, the first item emitted by o2, and the first item emitted by o3; the second item emitted by the resulting Observable will be the result of the function applied to the second item emitted by o1, the second item emitted by o2, and the second item emitted by o3; and so forth.

        The resulting Observable<R> returned from zip will invoke onNext as many times as the number of onNext invocations of the ObservableSource that emits the fewest items.

        The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling doOnComplete()). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will dispose B immediately. For example:

        zip(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2), ..., (a, b, c) -> a + b)
        action1 will be called but action2 won't.
        To work around this termination property, use doOnDispose(Action) as well or use using() to do cleanup in case of completion or a dispose() call.
        Scheduler:
        zip does not operate by default on a particular Scheduler.
        Type Parameters:
        T1 - the value type of the first source
        T2 - the value type of the second source
        T3 - the value type of the third source
        R - the zipped result type
        Parameters:
        source1 - the first source ObservableSource
        source2 - a second source ObservableSource
        source3 - a third source ObservableSource
        zipper - a function that, when applied to an item emitted by each of the ObservableSources, results in an item that will be emitted by the resulting Observable
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if source1, source2, source3 or zipper is null
        See Also:
        ReactiveX operators documentation: Zip
      • zip

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T1,​@NonNull T2,​@NonNull T3,​@NonNull T4,​@NonNull R> @NonNull Observable<R> zip​(@NonNull
                                                                                                                                      @NonNull ObservableSource<? extends @NonNull T1> source1,
                                                                                                                                      @NonNull
                                                                                                                                      @NonNull ObservableSource<? extends @NonNull T2> source2,
                                                                                                                                      @NonNull
                                                                                                                                      @NonNull ObservableSource<? extends @NonNull T3> source3,
                                                                                                                                      @NonNull
                                                                                                                                      @NonNull ObservableSource<? extends @NonNull T4> source4,
                                                                                                                                      @NonNull
                                                                                                                                      @NonNull Function4<? super @NonNull T1,​? super @NonNull T2,​? super @NonNull T3,​? super @NonNull T4,​? extends @NonNull R> zipper)
        Returns an Observable that emits the results of a specified combiner function applied to combinations of four items emitted, in sequence, by four other ObservableSources.

        zip applies this function in strict sequence, so the first item emitted by the resulting Observable will be the result of the function applied to the first item emitted by o1, the first item emitted by o2, the first item emitted by o3, and the first item emitted by 04; the second item emitted by the resulting Observable will be the result of the function applied to the second item emitted by each of those ObservableSources; and so forth.

        The resulting Observable<R> returned from zip will invoke onNext as many times as the number of onNext invocations of the ObservableSource that emits the fewest items.

        The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling doOnComplete()). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will dispose B immediately. For example:

        zip(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2), ..., (a, b, c, d) -> a + b)
        action1 will be called but action2 won't.
        To work around this termination property, use doOnDispose(Action) as well or use using() to do cleanup in case of completion or a dispose() call.
        Scheduler:
        zip does not operate by default on a particular Scheduler.
        Type Parameters:
        T1 - the value type of the first source
        T2 - the value type of the second source
        T3 - the value type of the third source
        T4 - the value type of the fourth source
        R - the zipped result type
        Parameters:
        source1 - the first source ObservableSource
        source2 - a second source ObservableSource
        source3 - a third source ObservableSource
        source4 - a fourth source ObservableSource
        zipper - a function that, when applied to an item emitted by each of the ObservableSources, results in an item that will be emitted by the resulting Observable
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if source1, source2, source3, source4 or zipper is null
        See Also:
        ReactiveX operators documentation: Zip
      • zip

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T1,​@NonNull T2,​@NonNull T3,​@NonNull T4,​@NonNull T5,​@NonNull R> @NonNull Observable<R> zip​(@NonNull
                                                                                                                                                        @NonNull ObservableSource<? extends @NonNull T1> source1,
                                                                                                                                                        @NonNull
                                                                                                                                                        @NonNull ObservableSource<? extends @NonNull T2> source2,
                                                                                                                                                        @NonNull
                                                                                                                                                        @NonNull ObservableSource<? extends @NonNull T3> source3,
                                                                                                                                                        @NonNull
                                                                                                                                                        @NonNull ObservableSource<? extends @NonNull T4> source4,
                                                                                                                                                        @NonNull
                                                                                                                                                        @NonNull ObservableSource<? extends @NonNull T5> source5,
                                                                                                                                                        @NonNull
                                                                                                                                                        @NonNull Function5<? super @NonNull T1,​? super @NonNull T2,​? super @NonNull T3,​? super @NonNull T4,​? super @NonNull T5,​? extends @NonNull R> zipper)
        Returns an Observable that emits the results of a specified combiner function applied to combinations of five items emitted, in sequence, by five other ObservableSources.

        zip applies this function in strict sequence, so the first item emitted by the resulting Observable will be the result of the function applied to the first item emitted by o1, the first item emitted by o2, the first item emitted by o3, the first item emitted by o4, and the first item emitted by o5; the second item emitted by the resulting Observable will be the result of the function applied to the second item emitted by each of those ObservableSources; and so forth.

        The resulting Observable<R> returned from zip will invoke onNext as many times as the number of onNext invocations of the ObservableSource that emits the fewest items.

        The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling doOnComplete()). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will dispose B immediately. For example:

        zip(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2), ..., (a, b, c, d, e) -> a + b)
        action1 will be called but action2 won't.
        To work around this termination property, use doOnDispose(Action) as well or use using() to do cleanup in case of completion or a dispose() call.
        Scheduler:
        zip does not operate by default on a particular Scheduler.
        Type Parameters:
        T1 - the value type of the first source
        T2 - the value type of the second source
        T3 - the value type of the third source
        T4 - the value type of the fourth source
        T5 - the value type of the fifth source
        R - the zipped result type
        Parameters:
        source1 - the first source ObservableSource
        source2 - a second source ObservableSource
        source3 - a third source ObservableSource
        source4 - a fourth source ObservableSource
        source5 - a fifth source ObservableSource
        zipper - a function that, when applied to an item emitted by each of the ObservableSources, results in an item that will be emitted by the resulting Observable
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if source1, source2, source3, source4, source5 or zipper is null
        See Also:
        ReactiveX operators documentation: Zip
      • zip

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T1,​@NonNull T2,​@NonNull T3,​@NonNull T4,​@NonNull T5,​@NonNull T6,​@NonNull R> @NonNull Observable<R> zip​(@NonNull
                                                                                                                                                                          @NonNull ObservableSource<? extends @NonNull T1> source1,
                                                                                                                                                                          @NonNull
                                                                                                                                                                          @NonNull ObservableSource<? extends @NonNull T2> source2,
                                                                                                                                                                          @NonNull
                                                                                                                                                                          @NonNull ObservableSource<? extends @NonNull T3> source3,
                                                                                                                                                                          @NonNull
                                                                                                                                                                          @NonNull ObservableSource<? extends @NonNull T4> source4,
                                                                                                                                                                          @NonNull
                                                                                                                                                                          @NonNull ObservableSource<? extends @NonNull T5> source5,
                                                                                                                                                                          @NonNull
                                                                                                                                                                          @NonNull ObservableSource<? extends @NonNull T6> source6,
                                                                                                                                                                          @NonNull
                                                                                                                                                                          @NonNull Function6<? super @NonNull T1,​? super @NonNull T2,​? super @NonNull T3,​? super @NonNull T4,​? super @NonNull T5,​? super @NonNull T6,​? extends @NonNull R> zipper)
        Returns an Observable that emits the results of a specified combiner function applied to combinations of six items emitted, in sequence, by six other ObservableSources.

        zip applies this function in strict sequence, so the first item emitted by the resulting Observable will be the result of the function applied to the first item emitted by each source ObservableSource, the second item emitted by the resulting Observable will be the result of the function applied to the second item emitted by each of those ObservableSources, and so forth.

        The resulting Observable<R> returned from zip will invoke onNext as many times as the number of onNext invocations of the ObservableSource that emits the fewest items.

        The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling doOnComplete()). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will dispose B immediately. For example:

        zip(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2), ..., (a, b, c, d, e, f) -> a + b)
        action1 will be called but action2 won't.
        To work around this termination property, use doOnDispose(Action) as well or use using() to do cleanup in case of completion or a dispose() call.
        Scheduler:
        zip does not operate by default on a particular Scheduler.
        Type Parameters:
        T1 - the value type of the first source
        T2 - the value type of the second source
        T3 - the value type of the third source
        T4 - the value type of the fourth source
        T5 - the value type of the fifth source
        T6 - the value type of the sixth source
        R - the zipped result type
        Parameters:
        source1 - the first source ObservableSource
        source2 - a second source ObservableSource
        source3 - a third source ObservableSource
        source4 - a fourth source ObservableSource
        source5 - a fifth source ObservableSource
        source6 - a sixth source ObservableSource
        zipper - a function that, when applied to an item emitted by each of the ObservableSources, results in an item that will be emitted by the resulting Observable
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if source1, source2, source3, source4, source5, source6 or zipper is null
        See Also:
        ReactiveX operators documentation: Zip
      • zip

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T1,​@NonNull T2,​@NonNull T3,​@NonNull T4,​@NonNull T5,​@NonNull T6,​@NonNull T7,​@NonNull R> @NonNull Observable<R> zip​(@NonNull
                                                                                                                                                                                            @NonNull ObservableSource<? extends @NonNull T1> source1,
                                                                                                                                                                                            @NonNull
                                                                                                                                                                                            @NonNull ObservableSource<? extends @NonNull T2> source2,
                                                                                                                                                                                            @NonNull
                                                                                                                                                                                            @NonNull ObservableSource<? extends @NonNull T3> source3,
                                                                                                                                                                                            @NonNull
                                                                                                                                                                                            @NonNull ObservableSource<? extends @NonNull T4> source4,
                                                                                                                                                                                            @NonNull
                                                                                                                                                                                            @NonNull ObservableSource<? extends @NonNull T5> source5,
                                                                                                                                                                                            @NonNull
                                                                                                                                                                                            @NonNull ObservableSource<? extends @NonNull T6> source6,
                                                                                                                                                                                            @NonNull
                                                                                                                                                                                            @NonNull ObservableSource<? extends @NonNull T7> source7,
                                                                                                                                                                                            @NonNull
                                                                                                                                                                                            @NonNull Function7<? super @NonNull T1,​? super @NonNull T2,​? super @NonNull T3,​? super @NonNull T4,​? super @NonNull T5,​? super @NonNull T6,​? super @NonNull T7,​? extends @NonNull R> zipper)
        Returns an Observable that emits the results of a specified combiner function applied to combinations of seven items emitted, in sequence, by seven other ObservableSources.

        zip applies this function in strict sequence, so the first item emitted by the resulting Observable will be the result of the function applied to the first item emitted by each source ObservableSource, the second item emitted by the resulting Observable will be the result of the function applied to the second item emitted by each of those ObservableSources, and so forth.

        The resulting Observable<R> returned from zip will invoke onNext as many times as the number of onNext invocations of the ObservableSource that emits the fewest items.

        The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling doOnComplete()). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will dispose B immediately. For example:

        zip(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2), ..., (a, b, c, d, e, f, g) -> a + b)
        action1 will be called but action2 won't.
        To work around this termination property, use doOnDispose(Action) as well or use using() to do cleanup in case of completion or a dispose() call.
        Scheduler:
        zip does not operate by default on a particular Scheduler.
        Type Parameters:
        T1 - the value type of the first source
        T2 - the value type of the second source
        T3 - the value type of the third source
        T4 - the value type of the fourth source
        T5 - the value type of the fifth source
        T6 - the value type of the sixth source
        T7 - the value type of the seventh source
        R - the zipped result type
        Parameters:
        source1 - the first source ObservableSource
        source2 - a second source ObservableSource
        source3 - a third source ObservableSource
        source4 - a fourth source ObservableSource
        source5 - a fifth source ObservableSource
        source6 - a sixth source ObservableSource
        source7 - a seventh source ObservableSource
        zipper - a function that, when applied to an item emitted by each of the ObservableSources, results in an item that will be emitted by the resulting Observable
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if source1, source2, source3, source4, source5, source6, source7 or zipper is null
        See Also:
        ReactiveX operators documentation: Zip
      • zip

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T1,​@NonNull T2,​@NonNull T3,​@NonNull T4,​@NonNull T5,​@NonNull T6,​@NonNull T7,​@NonNull T8,​@NonNull R> @NonNull Observable<R> zip​(@NonNull
                                                                                                                                                                                                              @NonNull ObservableSource<? extends @NonNull T1> source1,
                                                                                                                                                                                                              @NonNull
                                                                                                                                                                                                              @NonNull ObservableSource<? extends @NonNull T2> source2,
                                                                                                                                                                                                              @NonNull
                                                                                                                                                                                                              @NonNull ObservableSource<? extends @NonNull T3> source3,
                                                                                                                                                                                                              @NonNull
                                                                                                                                                                                                              @NonNull ObservableSource<? extends @NonNull T4> source4,
                                                                                                                                                                                                              @NonNull
                                                                                                                                                                                                              @NonNull ObservableSource<? extends @NonNull T5> source5,
                                                                                                                                                                                                              @NonNull
                                                                                                                                                                                                              @NonNull ObservableSource<? extends @NonNull T6> source6,
                                                                                                                                                                                                              @NonNull
                                                                                                                                                                                                              @NonNull ObservableSource<? extends @NonNull T7> source7,
                                                                                                                                                                                                              @NonNull
                                                                                                                                                                                                              @NonNull ObservableSource<? extends @NonNull T8> source8,
                                                                                                                                                                                                              @NonNull
                                                                                                                                                                                                              @NonNull Function8<? super @NonNull T1,​? super @NonNull T2,​? super @NonNull T3,​? super @NonNull T4,​? super @NonNull T5,​? super @NonNull T6,​? super @NonNull T7,​? super @NonNull T8,​? extends @NonNull R> zipper)
        Returns an Observable that emits the results of a specified combiner function applied to combinations of eight items emitted, in sequence, by eight other ObservableSources.

        zip applies this function in strict sequence, so the first item emitted by the resulting Observable will be the result of the function applied to the first item emitted by each source ObservableSource, the second item emitted by the resulting Observable will be the result of the function applied to the second item emitted by each of those ObservableSources, and so forth.

        The resulting Observable<R> returned from zip will invoke onNext as many times as the number of onNext invocations of the ObservableSource that emits the fewest items.

        The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling doOnComplete()). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will dispose B immediately. For example:

        zip(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2), ..., (a, b, c, d, e, f, g, h) -> a + b)
        action1 will be called but action2 won't.
        To work around this termination property, use doOnDispose(Action) as well or use using() to do cleanup in case of completion or a dispose() call.
        Scheduler:
        zip does not operate by default on a particular Scheduler.
        Type Parameters:
        T1 - the value type of the first source
        T2 - the value type of the second source
        T3 - the value type of the third source
        T4 - the value type of the fourth source
        T5 - the value type of the fifth source
        T6 - the value type of the sixth source
        T7 - the value type of the seventh source
        T8 - the value type of the eighth source
        R - the zipped result type
        Parameters:
        source1 - the first source ObservableSource
        source2 - a second source ObservableSource
        source3 - a third source ObservableSource
        source4 - a fourth source ObservableSource
        source5 - a fifth source ObservableSource
        source6 - a sixth source ObservableSource
        source7 - a seventh source ObservableSource
        source8 - an eighth source ObservableSource
        zipper - a function that, when applied to an item emitted by each of the ObservableSources, results in an item that will be emitted by the resulting Observable
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if source1, source2, source3, source4, source5, source6, source7, source8 or zipper is null
        See Also:
        ReactiveX operators documentation: Zip
      • zip

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T1,​@NonNull T2,​@NonNull T3,​@NonNull T4,​@NonNull T5,​@NonNull T6,​@NonNull T7,​@NonNull T8,​@NonNull T9,​@NonNull R> @NonNull Observable<R> zip​(@NonNull
                                                                                                                                                                                                                                @NonNull ObservableSource<? extends @NonNull T1> source1,
                                                                                                                                                                                                                                @NonNull
                                                                                                                                                                                                                                @NonNull ObservableSource<? extends @NonNull T2> source2,
                                                                                                                                                                                                                                @NonNull
                                                                                                                                                                                                                                @NonNull ObservableSource<? extends @NonNull T3> source3,
                                                                                                                                                                                                                                @NonNull
                                                                                                                                                                                                                                @NonNull ObservableSource<? extends @NonNull T4> source4,
                                                                                                                                                                                                                                @NonNull
                                                                                                                                                                                                                                @NonNull ObservableSource<? extends @NonNull T5> source5,
                                                                                                                                                                                                                                @NonNull
                                                                                                                                                                                                                                @NonNull ObservableSource<? extends @NonNull T6> source6,
                                                                                                                                                                                                                                @NonNull
                                                                                                                                                                                                                                @NonNull ObservableSource<? extends @NonNull T7> source7,
                                                                                                                                                                                                                                @NonNull
                                                                                                                                                                                                                                @NonNull ObservableSource<? extends @NonNull T8> source8,
                                                                                                                                                                                                                                @NonNull
                                                                                                                                                                                                                                @NonNull ObservableSource<? extends @NonNull T9> source9,
                                                                                                                                                                                                                                @NonNull
                                                                                                                                                                                                                                @NonNull Function9<? super @NonNull T1,​? super @NonNull T2,​? super @NonNull T3,​? super @NonNull T4,​? super @NonNull T5,​? super @NonNull T6,​? super @NonNull T7,​? super @NonNull T8,​? super @NonNull T9,​? extends @NonNull R> zipper)
        Returns an Observable that emits the results of a specified combiner function applied to combinations of nine items emitted, in sequence, by nine other ObservableSources.

        zip applies this function in strict sequence, so the first item emitted by the resulting Observable will be the result of the function applied to the first item emitted by each source ObservableSource, the second item emitted by the resulting Observable will be the result of the function applied to the second item emitted by each of those ObservableSources, and so forth.

        The resulting Observable<R> returned from zip will invoke onNext as many times as the number of onNext invocations of the ObservableSource that emits the fewest items.

        The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling doOnComplete()). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will dispose B immediately. For example:

        zip(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2), ..., (a, b, c, d, e, f, g, h, i) -> a + b)
        action1 will be called but action2 won't.
        To work around this termination property, use doOnDispose(Action) as well or use using() to do cleanup in case of completion or a dispose() call.
        Scheduler:
        zip does not operate by default on a particular Scheduler.
        Type Parameters:
        T1 - the value type of the first source
        T2 - the value type of the second source
        T3 - the value type of the third source
        T4 - the value type of the fourth source
        T5 - the value type of the fifth source
        T6 - the value type of the sixth source
        T7 - the value type of the seventh source
        T8 - the value type of the eighth source
        T9 - the value type of the ninth source
        R - the zipped result type
        Parameters:
        source1 - the first source ObservableSource
        source2 - a second source ObservableSource
        source3 - a third source ObservableSource
        source4 - a fourth source ObservableSource
        source5 - a fifth source ObservableSource
        source6 - a sixth source ObservableSource
        source7 - a seventh source ObservableSource
        source8 - an eighth source ObservableSource
        source9 - a ninth source ObservableSource
        zipper - a function that, when applied to an item emitted by each of the ObservableSources, results in an item that will be emitted by the resulting Observable
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if source1, source2, source3, source4, source5, source6, source7, source8, source9 or zipper is null
        See Also:
        ReactiveX operators documentation: Zip
      • zipArray

        @CheckReturnValue
        @SchedulerSupport("none")
        @SafeVarargs
        @NonNull
        public static <@NonNull T,​@NonNull R> @NonNull Observable<R> zipArray​(@NonNull
                                                                                    @NonNull Function<? super java.lang.Object[],​? extends @NonNull R> zipper,
                                                                                    boolean delayError,
                                                                                    int bufferSize,
                                                                                    @NonNull
                                                                                    @NonNull ObservableSource<? extends @NonNull T>... sources)
        Returns an Observable that emits the results of a specified combiner function applied to combinations of items emitted, in sequence, by an array of other ObservableSources.

        zip applies this function in strict sequence, so the first item emitted by the resulting Observable will be the result of the function applied to the first item emitted by each of the ObservableSources; the second item emitted by the resulting Observable will be the result of the function applied to the second item emitted by each of those ObservableSources; and so forth.

        The resulting Observable<R> returned from zip will invoke onNext as many times as the number of onNext invocations of the ObservableSource that emits the fewest items.

        The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling doOnComplete()). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will dispose B immediately. For example:

        zip(new ObservableSource[]{range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2)}, (a) ->
         a)
        action1 will be called but action2 won't.
        To work around this termination property, use doOnDispose(Action) as well or use using() to do cleanup in case of completion or a dispose() call.

        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.

        Scheduler:
        zipArray does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the common element type
        R - the result type
        Parameters:
        sources - an array of source ObservableSources
        zipper - a function that, when applied to an item emitted by each of the ObservableSources, results in an item that will be emitted by the resulting Observable
        delayError - delay errors signaled by any of the ObservableSource until all ObservableSources terminate
        bufferSize - the number of elements expected from each source ObservableSource to be buffered
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if sources or zipper is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        See Also:
        ReactiveX operators documentation: Zip
      • ambWith

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> ambWith​(@NonNull
                                                    @NonNull ObservableSource<? extends @NonNull T> other)
        Mirrors the current Observable or the other ObservableSource provided of which the first either emits an item or sends a termination notification.

        When the current Observable signals an item or terminates first, the subscription to the other ObservableSource is disposed. If the other ObservableSource signals an item or terminates first, the subscription to the current Observable is disposed.

        Scheduler:
        ambWith does not operate by default on a particular Scheduler.
        Error handling:
        If the losing ObservableSource signals an error, the error is routed to the global error handler via RxJavaPlugins.onError(Throwable).
        Parameters:
        other - an ObservableSource competing to react first. A subscription to this provided source will occur after subscribing to the current source.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if other is null
        See Also:
        ReactiveX operators documentation: Amb
      • blockingFirst

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final T blockingFirst()
        Returns the first item emitted by the current Observable, or throws NoSuchElementException if it emits no items.

        Scheduler:
        blockingFirst does not operate by default on a particular Scheduler.
        Error handling:
        If the source signals an error, the operator wraps a checked Exception into RuntimeException and throws that. Otherwise, RuntimeExceptions and Errors are rethrown as they are.
        Returns:
        the first item emitted by the current Observable
        Throws:
        java.util.NoSuchElementException - if the current Observable emits no items
        See Also:
        ReactiveX documentation: First
      • blockingFirst

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final T blockingFirst​(@NonNull
                                     @NonNull T defaultItem)
        Returns the first item emitted by the current Observable, or a default value if it emits no items.

        Scheduler:
        blockingFirst does not operate by default on a particular Scheduler.
        Error handling:
        If the source signals an error, the operator wraps a checked Exception into RuntimeException and throws that. Otherwise, RuntimeExceptions and Errors are rethrown as they are.
        Parameters:
        defaultItem - a default value to return if the current Observable emits no items
        Returns:
        the first item emitted by the current Observable, or the default value if it emits no items
        Throws:
        java.lang.NullPointerException - if defaultItem is null
        See Also:
        ReactiveX documentation: First
      • blockingForEach

        @SchedulerSupport("none")
        public final void blockingForEach​(@NonNull
                                          @NonNull Consumer<? super @NonNull T> onNext)
        Consumes the current Observable in a blocking fashion and invokes the given Consumer with each upstream item on the current thread until the upstream terminates.

        Note: the method will only return if the upstream terminates or the current thread is interrupted.

        This method executes the Consumer on the current thread while subscribe(Consumer) executes the consumer on the original caller thread of the sequence.

        Scheduler:
        blockingForEach does not operate by default on a particular Scheduler.
        Error handling:
        If the source signals an error, the operator wraps a checked Exception into RuntimeException and throws that. Otherwise, RuntimeExceptions and Errors are rethrown as they are.
        Parameters:
        onNext - the Consumer to invoke for each item emitted by the Observable
        Throws:
        java.lang.NullPointerException - if onNext is null
        java.lang.RuntimeException - if an error occurs
        See Also:
        ReactiveX documentation: Subscribe, subscribe(Consumer), blockingForEach(Consumer, int)
      • blockingForEach

        @SchedulerSupport("none")
        public final void blockingForEach​(@NonNull
                                          @NonNull Consumer<? super @NonNull T> onNext,
                                          int capacityHint)
        Consumes the current Observable in a blocking fashion and invokes the given Consumer with each upstream item on the current thread until the upstream terminates.

        Note: the method will only return if the upstream terminates or the current thread is interrupted.

        This method executes the Consumer on the current thread while subscribe(Consumer) executes the consumer on the original caller thread of the sequence.

        Scheduler:
        blockingForEach does not operate by default on a particular Scheduler.
        Error handling:
        If the source signals an error, the operator wraps a checked Exception into RuntimeException and throws that. Otherwise, RuntimeExceptions and Errors are rethrown as they are.
        Parameters:
        onNext - the Consumer to invoke for each item emitted by the Observable
        capacityHint - the number of items expected to be buffered (allows reducing buffer reallocations)
        Throws:
        java.lang.NullPointerException - if onNext is null
        java.lang.IllegalArgumentException - if capacityHint is non-positive
        java.lang.RuntimeException - if an error occurs; Errors and RuntimeExceptions are rethrown as they are, checked Exceptions are wrapped into RuntimeExceptions
        See Also:
        ReactiveX documentation: Subscribe, subscribe(Consumer)
      • blockingIterable

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull java.lang.Iterable<T> blockingIterable()
        Exposes the current Observable as an Iterable which, when iterated, subscribes to the current Observable and blocks until the current Observable emits items or terminates.

        Scheduler:
        blockingIterable does not operate by default on a particular Scheduler.
        Returns:
        the new Iterable instance
        See Also:
        ReactiveX documentation: To
      • blockingIterable

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull java.lang.Iterable<T> blockingIterable​(int capacityHint)
        Exposes the current Observable as an Iterable which, when iterated, subscribes to the current Observable and blocks until the current Observable emits items or terminates.

        Scheduler:
        blockingIterable does not operate by default on a particular Scheduler.
        Parameters:
        capacityHint - the expected number of items to be buffered
        Returns:
        the new Iterable instance
        Throws:
        java.lang.IllegalArgumentException - if capacityHint is non-positive
        See Also:
        ReactiveX documentation: To
      • blockingLast

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final T blockingLast()
        Returns the last item emitted by the current Observable, or throws NoSuchElementException if the current Observable emits no items.

        Scheduler:
        blockingLast does not operate by default on a particular Scheduler.
        Error handling:
        If the source signals an error, the operator wraps a checked Exception into RuntimeException and throws that. Otherwise, RuntimeExceptions and Errors are rethrown as they are.
        Returns:
        the last item emitted by the current Observable
        Throws:
        java.util.NoSuchElementException - if the current Observable emits no items
        See Also:
        ReactiveX documentation: Last
      • blockingLast

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final T blockingLast​(@NonNull
                                    @NonNull T defaultItem)
        Returns the last item emitted by the current Observable, or a default value if it emits no items.

        Scheduler:
        blockingLast does not operate by default on a particular Scheduler.
        Error handling:
        If the source signals an error, the operator wraps a checked Exception into RuntimeException and throws that. Otherwise, RuntimeExceptions and Errors are rethrown as they are.
        Parameters:
        defaultItem - a default value to return if the current Observable emits no items
        Returns:
        the last item emitted by the Observable, or the default value if it emits no items
        Throws:
        java.lang.NullPointerException - if defaultItem is null
        See Also:
        ReactiveX documentation: Last
      • blockingLatest

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull java.lang.Iterable<T> blockingLatest()
        Returns an Iterable that returns the latest item emitted by the current Observable, waiting if necessary for one to become available.

        If the current Observable produces items faster than Iterator.next takes them, onNext events might be skipped, but onError or onComplete events are not.

        Note also that an onNext directly followed by onComplete might hide the onNext event.

        Scheduler:
        blockingLatest does not operate by default on a particular Scheduler.
        Returns:
        the new Iterable instance
        See Also:
        ReactiveX documentation: First
      • blockingMostRecent

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull java.lang.Iterable<T> blockingMostRecent​(@NonNull
                                                                       @NonNull T initialItem)
        Returns an Iterable that always returns the item most recently emitted by the current Observable.

        Scheduler:
        blockingMostRecent does not operate by default on a particular Scheduler.
        Parameters:
        initialItem - the initial value that the Iterable sequence will yield if the current Observable has not yet emitted an item
        Returns:
        the new Iterable instance
        Throws:
        java.lang.NullPointerException - if initialItem is null
        See Also:
        ReactiveX documentation: First
      • blockingSingle

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final T blockingSingle()
        If the current Observable completes after emitting a single item, return that item, otherwise throw a NoSuchElementException.

        Scheduler:
        blockingSingle does not operate by default on a particular Scheduler.
        Error handling:
        If the source signals an error, the operator wraps a checked Exception into RuntimeException and throws that. Otherwise, RuntimeExceptions and Errors are rethrown as they are.
        Returns:
        the single item emitted by the current Observable
        See Also:
        ReactiveX documentation: First
      • blockingSingle

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final T blockingSingle​(@NonNull
                                      @NonNull T defaultItem)
        If the current Observable completes after emitting a single item, return that item; if it emits more than one item, throw an IllegalArgumentException; if it emits no items, return a default value.

        Scheduler:
        blockingSingle does not operate by default on a particular Scheduler.
        Error handling:
        If the source signals an error, the operator wraps a checked Exception into RuntimeException and throws that. Otherwise, RuntimeExceptions and Errors are rethrown as they are.
        Parameters:
        defaultItem - a default value to return if the current Observable emits no items
        Returns:
        the single item emitted by the current Observable, or the default value if it emits no items
        Throws:
        java.lang.NullPointerException - if defaultItem is null
        See Also:
        ReactiveX documentation: First
      • toFuture

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull java.util.concurrent.Future<T> toFuture()
        Returns a Future representing the only value emitted by the current Observable.

        If the Observable emits more than one item, Future will receive an IndexOutOfBoundsException. If the Observable is empty, Future will receive an NoSuchElementException. The Observable source has to terminate in order for the returned Future to terminate as well.

        If the Observable may emit more than one item, use Observable.toList().toFuture().

        Scheduler:
        toFuture does not operate by default on a particular Scheduler.
        Returns:
        the new Future instance
        See Also:
        ReactiveX documentation: To, singleOrErrorStage()
      • blockingSubscribe

        @SchedulerSupport("none")
        public final void blockingSubscribe​(@NonNull
                                            @NonNull Consumer<? super @NonNull T> onNext,
                                            @NonNull
                                            @NonNull Consumer<? super java.lang.Throwable> onError)
        Subscribes to the source and calls the given callbacks on the current thread.

        Note that calling this method will block the caller thread until the upstream terminates normally or with an error. Therefore, calling this method from special threads such as the Android Main Thread or the Swing Event Dispatch Thread is not recommended.

        Scheduler:
        blockingSubscribe does not operate by default on a particular Scheduler.
        Parameters:
        onNext - the callback action for each source value
        onError - the callback action for an error event
        Throws:
        java.lang.NullPointerException - if onNext or onError is null
        Since:
        2.0
        See Also:
        blockingSubscribe(Consumer, Consumer, Action)
      • blockingSubscribe

        @SchedulerSupport("none")
        public final void blockingSubscribe​(@NonNull
                                            @NonNull Consumer<? super @NonNull T> onNext,
                                            @NonNull
                                            @NonNull Consumer<? super java.lang.Throwable> onError,
                                            @NonNull
                                            @NonNull Action onComplete)
        Subscribes to the source and calls the given callbacks on the current thread.

        Note that calling this method will block the caller thread until the upstream terminates normally or with an error. Therefore, calling this method from special threads such as the Android Main Thread or the Swing Event Dispatch Thread is not recommended.

        Scheduler:
        blockingSubscribe does not operate by default on a particular Scheduler.
        Parameters:
        onNext - the callback action for each source value
        onError - the callback action for an error event
        onComplete - the callback action for the completion event.
        Throws:
        java.lang.NullPointerException - if onNext, onError or onComplete is null
        Since:
        2.0
      • blockingSubscribe

        @SchedulerSupport("none")
        public final void blockingSubscribe​(@NonNull
                                            @NonNull Observer<? super @NonNull T> observer)
        Subscribes to the source and calls the Observer methods on the current thread.

        Note that calling this method will block the caller thread until the upstream terminates normally, with an error or the Observer disposes the Disposable it receives via Observer.onSubscribe(Disposable). Therefore, calling this method from special threads such as the Android Main Thread or the Swing Event Dispatch Thread is not recommended.

        Scheduler:
        blockingSubscribe does not operate by default on a particular Scheduler.
        The a dispose() call is composed through.
        Parameters:
        observer - the Observer instance to forward events and calls to in the current thread
        Throws:
        java.lang.NullPointerException - if observer is null
        Since:
        2.0
      • buffer

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<@NonNull java.util.List<T>> buffer​(int count)
        Returns an Observable that emits buffers of items it collects from the current Observable. The resulting Observable emits connected, non-overlapping buffers, each containing count items. When the current Observable completes, the resulting Observable emits the current buffer and propagates the notification from the current Observable. Note that if the current Observable issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.

        Scheduler:
        This version of buffer does not operate by default on a particular Scheduler.
        Parameters:
        count - the maximum number of items in each buffer before it should be emitted
        Returns:
        the new Observable instance
        Throws:
        java.lang.IllegalArgumentException - if count is non-positive
        See Also:
        ReactiveX operators documentation: Buffer
      • buffer

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<@NonNull java.util.List<T>> buffer​(int count,
                                                                            int skip)
        Returns an Observable that emits buffers of items it collects from the current Observable. The resulting Observable emits buffers every skip items, each containing count items. When the current Observable completes, the resulting Observable emits the current buffer and propagates the notification from the current Observable. Note that if the current Observable issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.

        Scheduler:
        This version of buffer does not operate by default on a particular Scheduler.
        Parameters:
        count - the maximum size of each buffer before it should be emitted
        skip - how many items emitted by the current Observable should be skipped before starting a new buffer. Note that when skip and count are equal, this is the same operation as buffer(int).
        Returns:
        the new Observable instance
        Throws:
        java.lang.IllegalArgumentException - if count or skip is non-positive
        See Also:
        ReactiveX operators documentation: Buffer
      • buffer

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull U extends java.util.Collection<? super @NonNull T>> @NonNull Observable<U> buffer​(int count,
                                                                                                                 int skip,
                                                                                                                 @NonNull
                                                                                                                 @NonNull Supplier<@NonNull U> bufferSupplier)
        Returns an Observable that emits buffers of items it collects from the current Observable. The resulting Observable emits buffers every skip items, each containing count items. When the current Observable completes, the resulting Observable emits the current buffer and propagates the notification from the current Observable. Note that if the current Observable issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.

        Scheduler:
        This version of buffer does not operate by default on a particular Scheduler.
        Type Parameters:
        U - the collection subclass type to buffer into
        Parameters:
        count - the maximum size of each buffer before it should be emitted
        skip - how many items emitted by the current Observable should be skipped before starting a new buffer. Note that when skip and count are equal, this is the same operation as buffer(int).
        bufferSupplier - a factory function that returns an instance of the collection subclass to be used and returned as the buffer
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if bufferSupplier is null
        java.lang.IllegalArgumentException - if count or skip is non-positive
        See Also:
        ReactiveX operators documentation: Buffer
      • buffer

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull U extends java.util.Collection<? super @NonNull T>> @NonNull Observable<U> buffer​(int count,
                                                                                                                 @NonNull
                                                                                                                 @NonNull Supplier<@NonNull U> bufferSupplier)
        Returns an Observable that emits buffers of items it collects from the current Observable. The resulting Observable emits connected, non-overlapping buffers, each containing count items. When the current Observable completes, the resulting Observable emits the current buffer and propagates the notification from the current Observable. Note that if the current Observable issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.

        Scheduler:
        This version of buffer does not operate by default on a particular Scheduler.
        Type Parameters:
        U - the collection subclass type to buffer into
        Parameters:
        count - the maximum number of items in each buffer before it should be emitted
        bufferSupplier - a factory function that returns an instance of the collection subclass to be used and returned as the buffer
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if bufferSupplier is null
        java.lang.IllegalArgumentException - if count is non-positive
        See Also:
        ReactiveX operators documentation: Buffer
      • buffer

        @CheckReturnValue
        @SchedulerSupport("io.reactivex:computation")
        @NonNull
        public final @NonNull Observable<@NonNull java.util.List<T>> buffer​(long timespan,
                                                                            long timeskip,
                                                                            @NonNull
                                                                            @NonNull java.util.concurrent.TimeUnit unit)
        Returns an Observable that emits buffers of items it collects from the current Observable. The resulting Observable starts a new buffer periodically, as determined by the timeskip argument. It emits each buffer after a fixed timespan, specified by the timespan argument. When the current Observable completes, the resulting Observable emits the current buffer and propagates the notification from the current Observable. Note that if the current Observable issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.

        Scheduler:
        This version of buffer operates by default on the computation Scheduler.
        Parameters:
        timespan - the period of time each buffer collects items before it is emitted
        timeskip - the period of time after which a new buffer will be created
        unit - the unit of time that applies to the timespan and timeskip arguments
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit is null
        See Also:
        ReactiveX operators documentation: Buffer
      • buffer

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<@NonNull java.util.List<T>> buffer​(long timespan,
                                                                            long timeskip,
                                                                            @NonNull
                                                                            @NonNull java.util.concurrent.TimeUnit unit,
                                                                            @NonNull
                                                                            @NonNull Scheduler scheduler)
        Returns an Observable that emits buffers of items it collects from the current Observable. The resulting Observable starts a new buffer periodically, as determined by the timeskip argument, and on the specified scheduler. It emits each buffer after a fixed timespan, specified by the timespan argument. When the current Observable completes, the resulting Observable emits the current buffer and propagates the notification from the current Observable. Note that if the current Observable issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.

        Scheduler:
        You specify which Scheduler this operator will use.
        Parameters:
        timespan - the period of time each buffer collects items before it is emitted
        timeskip - the period of time after which a new buffer will be created
        unit - the unit of time that applies to the timespan and timeskip arguments
        scheduler - the Scheduler to use when determining the end and start of a buffer
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null
        See Also:
        ReactiveX operators documentation: Buffer
      • buffer

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final <@NonNull U extends java.util.Collection<? super @NonNull T>> @NonNull Observable<U> buffer​(long timespan,
                                                                                                                 long timeskip,
                                                                                                                 @NonNull
                                                                                                                 @NonNull java.util.concurrent.TimeUnit unit,
                                                                                                                 @NonNull
                                                                                                                 @NonNull Scheduler scheduler,
                                                                                                                 @NonNull
                                                                                                                 @NonNull Supplier<@NonNull U> bufferSupplier)
        Returns an Observable that emits buffers of items it collects from the current Observable. The resulting Observable starts a new buffer periodically, as determined by the timeskip argument, and on the specified scheduler. It emits each buffer after a fixed timespan, specified by the timespan argument. When the current Observable completes, the resulting Observable emits the current buffer and propagates the notification from the current Observable. Note that if the current Observable issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.

        Scheduler:
        You specify which Scheduler this operator will use.
        Type Parameters:
        U - the collection subclass type to buffer into
        Parameters:
        timespan - the period of time each buffer collects items before it is emitted
        timeskip - the period of time after which a new buffer will be created
        unit - the unit of time that applies to the timespan and timeskip arguments
        scheduler - the Scheduler to use when determining the end and start of a buffer
        bufferSupplier - a factory function that returns an instance of the collection subclass to be used and returned as the buffer
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit, scheduler or bufferSupplier is null
        See Also:
        ReactiveX operators documentation: Buffer
      • buffer

        @CheckReturnValue
        @SchedulerSupport("io.reactivex:computation")
        @NonNull
        public final @NonNull Observable<@NonNull java.util.List<T>> buffer​(long timespan,
                                                                            @NonNull
                                                                            @NonNull java.util.concurrent.TimeUnit unit)
        Returns an Observable that emits buffers of items it collects from the current Observable. The resulting Observable emits connected, non-overlapping buffers, each of a fixed duration specified by the timespan argument. When the current Observable completes, the resulting Observable emits the current buffer and propagates the notification from the current Observable. Note that if the current Observable issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.

        Scheduler:
        This version of buffer operates by default on the computation Scheduler.
        Parameters:
        timespan - the period of time each buffer collects items before it is emitted and replaced with a new buffer
        unit - the unit of time that applies to the timespan argument
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit is null
        See Also:
        ReactiveX operators documentation: Buffer
      • buffer

        @CheckReturnValue
        @SchedulerSupport("io.reactivex:computation")
        @NonNull
        public final @NonNull Observable<@NonNull java.util.List<T>> buffer​(long timespan,
                                                                            @NonNull
                                                                            @NonNull java.util.concurrent.TimeUnit unit,
                                                                            int count)
        Returns an Observable that emits buffers of items it collects from the current Observable. The resulting Observable emits connected, non-overlapping buffers, each of a fixed duration specified by the timespan argument or a maximum size specified by the count argument (whichever is reached first). When the current Observable completes, the resulting Observable emits the current buffer and propagates the notification from the current Observable. Note that if the current Observable issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.

        Scheduler:
        This version of buffer operates by default on the computation Scheduler.
        Parameters:
        timespan - the period of time each buffer collects items before it is emitted and replaced with a new buffer
        unit - the unit of time which applies to the timespan argument
        count - the maximum size of each buffer before it is emitted
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit is null
        java.lang.IllegalArgumentException - if count is non-positive
        See Also:
        ReactiveX operators documentation: Buffer
      • buffer

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<@NonNull java.util.List<T>> buffer​(long timespan,
                                                                            @NonNull
                                                                            @NonNull java.util.concurrent.TimeUnit unit,
                                                                            @NonNull
                                                                            @NonNull Scheduler scheduler,
                                                                            int count)
        Returns an Observable that emits buffers of items it collects from the current Observable. The resulting Observable emits connected, non-overlapping buffers, each of a fixed duration specified by the timespan argument as measured on the specified scheduler, or a maximum size specified by the count argument (whichever is reached first). When the current Observable completes, the resulting Observable emits the current buffer and propagates the notification from the current Observable. Note that if the current Observable issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.

        Scheduler:
        You specify which Scheduler this operator will use.
        Parameters:
        timespan - the period of time each buffer collects items before it is emitted and replaced with a new buffer
        unit - the unit of time which applies to the timespan argument
        scheduler - the Scheduler to use when determining the end and start of a buffer
        count - the maximum size of each buffer before it is emitted
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null
        java.lang.IllegalArgumentException - if count is non-positive
        See Also:
        ReactiveX operators documentation: Buffer
      • buffer

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final <@NonNull U extends java.util.Collection<? super @NonNull T>> @NonNull Observable<U> buffer​(long timespan,
                                                                                                                 @NonNull
                                                                                                                 @NonNull java.util.concurrent.TimeUnit unit,
                                                                                                                 @NonNull
                                                                                                                 @NonNull Scheduler scheduler,
                                                                                                                 int count,
                                                                                                                 @NonNull
                                                                                                                 @NonNull Supplier<@NonNull U> bufferSupplier,
                                                                                                                 boolean restartTimerOnMaxSize)
        Returns an Observable that emits buffers of items it collects from the current Observable. The resulting Observable emits connected, non-overlapping buffers, each of a fixed duration specified by the timespan argument as measured on the specified scheduler, or a maximum size specified by the count argument (whichever is reached first). When the current Observable completes, the resulting Observable emits the current buffer and propagates the notification from the current Observable. Note that if the current Observable issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.

        Scheduler:
        You specify which Scheduler this operator will use.
        Type Parameters:
        U - the collection subclass type to buffer into
        Parameters:
        timespan - the period of time each buffer collects items before it is emitted and replaced with a new buffer
        unit - the unit of time which applies to the timespan argument
        scheduler - the Scheduler to use when determining the end and start of a buffer
        count - the maximum size of each buffer before it is emitted
        bufferSupplier - a factory function that returns an instance of the collection subclass to be used and returned as the buffer
        restartTimerOnMaxSize - if true, the time window is restarted when the max capacity of the current buffer is reached
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit, scheduler or bufferSupplier is null
        java.lang.IllegalArgumentException - if count is non-positive
        See Also:
        ReactiveX operators documentation: Buffer
      • buffer

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<@NonNull java.util.List<T>> buffer​(long timespan,
                                                                            @NonNull
                                                                            @NonNull java.util.concurrent.TimeUnit unit,
                                                                            @NonNull
                                                                            @NonNull Scheduler scheduler)
        Returns an Observable that emits buffers of items it collects from the current Observable. The resulting Observable emits connected, non-overlapping buffers, each of a fixed duration specified by the timespan argument and on the specified scheduler. When the current Observable completes, the resulting Observable emits the current buffer and propagates the notification from the current Observable. Note that if the current Observable issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.

        Scheduler:
        You specify which Scheduler this operator will use.
        Parameters:
        timespan - the period of time each buffer collects items before it is emitted and replaced with a new buffer
        unit - the unit of time which applies to the timespan argument
        scheduler - the Scheduler to use when determining the end and start of a buffer
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null
        See Also:
        ReactiveX operators documentation: Buffer
      • buffer

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull TOpening,​@NonNull TClosing> @NonNull Observable<@NonNull java.util.List<T>> buffer​(@NonNull
                                                                                                                        @NonNull ObservableSource<? extends @NonNull TOpening> openingIndicator,
                                                                                                                        @NonNull
                                                                                                                        @NonNull Function<? super @NonNull TOpening,​? extends ObservableSource<? extends @NonNull TClosing>> closingIndicator)
        Returns an Observable that emits buffers of items it collects from the current Observable. The resulting Observable emits buffers that it creates when the specified openingIndicator ObservableSource emits an item, and closes when the ObservableSource returned from closingIndicator emits an item. If any of the current Observable, openingIndicator or closingIndicator issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.

        Scheduler:
        This version of buffer does not operate by default on a particular Scheduler.
        Type Parameters:
        TOpening - the element type of the buffer-opening ObservableSource
        TClosing - the element type of the individual buffer-closing ObservableSources
        Parameters:
        openingIndicator - the ObservableSource that, when it emits an item, causes a new buffer to be created
        closingIndicator - the Function that is used to produce an ObservableSource for every buffer created. When this indicator ObservableSource emits an item, the associated buffer is emitted.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if openingIndicator or closingIndicator is null
        See Also:
        ReactiveX operators documentation: Buffer
      • buffer

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull TOpening,​@NonNull TClosing,​@NonNull U extends java.util.Collection<? super @NonNull T>> @NonNull Observable<U> buffer​(@NonNull
                                                                                                                                                                 @NonNull ObservableSource<? extends @NonNull TOpening> openingIndicator,
                                                                                                                                                                 @NonNull
                                                                                                                                                                 @NonNull Function<? super @NonNull TOpening,​? extends ObservableSource<? extends @NonNull TClosing>> closingIndicator,
                                                                                                                                                                 @NonNull
                                                                                                                                                                 @NonNull Supplier<@NonNull U> bufferSupplier)
        Returns an Observable that emits buffers of items it collects from the current Observable. The resulting Observable emits buffers that it creates when the specified openingIndicator ObservableSource emits an item, and closes when the ObservableSource returned from closingIndicator emits an item. If any of the current Observable, openingIndicator or closingIndicator issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.

        Scheduler:
        This version of buffer does not operate by default on a particular Scheduler.
        Type Parameters:
        U - the collection subclass type to buffer into
        TOpening - the element type of the buffer-opening ObservableSource
        TClosing - the element type of the individual buffer-closing ObservableSources
        Parameters:
        openingIndicator - the ObservableSource that, when it emits an item, causes a new buffer to be created
        closingIndicator - the Function that is used to produce an ObservableSource for every buffer created. When this indicator ObservableSource emits an item, the associated buffer is emitted.
        bufferSupplier - a factory function that returns an instance of the collection subclass to be used and returned as the buffer
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if openingIndicator, closingIndicator or bufferSupplier is null
        See Also:
        ReactiveX operators documentation: Buffer
      • buffer

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull B> @NonNull Observable<@NonNull java.util.List<T>> buffer​(@NonNull
                                                                                         @NonNull ObservableSource<@NonNull B> boundaryIndicator)
        Returns an Observable that emits non-overlapping buffered items from the current Observable each time the specified boundary ObservableSource emits an item.

        Completion of either the source or the boundary ObservableSource causes the returned ObservableSource to emit the latest buffer and complete. If either the current Observable or the boundary ObservableSource issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.

        Scheduler:
        This version of buffer does not operate by default on a particular Scheduler.
        Type Parameters:
        B - the boundary value type (ignored)
        Parameters:
        boundaryIndicator - the boundary ObservableSource
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if boundaryIndicator is null
        See Also:
        buffer(ObservableSource, int), ReactiveX operators documentation: Buffer
      • buffer

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull B> @NonNull Observable<@NonNull java.util.List<T>> buffer​(@NonNull
                                                                                         @NonNull ObservableSource<@NonNull B> boundaryIndicator,
                                                                                         int initialCapacity)
        Returns an Observable that emits non-overlapping buffered items from the current Observable each time the specified boundary ObservableSource emits an item.

        Completion of either the source or the boundary ObservableSource causes the returned ObservableSource to emit the latest buffer and complete. If either the current Observable or the boundary ObservableSource issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.

        Scheduler:
        This version of buffer does not operate by default on a particular Scheduler.
        Type Parameters:
        B - the boundary value type (ignored)
        Parameters:
        boundaryIndicator - the boundary ObservableSource
        initialCapacity - the initial capacity of each buffer chunk
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if boundaryIndicator is null
        java.lang.IllegalArgumentException - if initialCapacity is non-positive
        See Also:
        ReactiveX operators documentation: Buffer, buffer(ObservableSource)
      • buffer

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull B,​@NonNull U extends java.util.Collection<? super @NonNull T>> @NonNull Observable<U> buffer​(@NonNull
                                                                                                                                  @NonNull ObservableSource<@NonNull B> boundaryIndicator,
                                                                                                                                  @NonNull
                                                                                                                                  @NonNull Supplier<@NonNull U> bufferSupplier)
        Returns an Observable that emits non-overlapping buffered items from the current Observable each time the specified boundary ObservableSource emits an item.

        Completion of either the source or the boundary ObservableSource causes the returned ObservableSource to emit the latest buffer and complete. If either the current Observable or the boundary ObservableSource issues an onError notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.

        Scheduler:
        This version of buffer does not operate by default on a particular Scheduler.
        Type Parameters:
        U - the collection subclass type to buffer into
        B - the boundary value type (ignored)
        Parameters:
        boundaryIndicator - the boundary ObservableSource
        bufferSupplier - a factory function that returns an instance of the collection subclass to be used and returned as the buffer
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if boundaryIndicator or bufferSupplier is null
        See Also:
        buffer(ObservableSource, int), ReactiveX operators documentation: Buffer
      • cache

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> cache()
        Returns an Observable that subscribes to the current Observable lazily, caches all of its events and replays them, in the same order as received, to all the downstream observers.

        This is useful when you want an Observable to cache responses and you can't control the subscribe/dispose behavior of all the Observers.

        The operator subscribes only when the first downstream observer subscribes and maintains a single subscription towards the current Observable. In contrast, the operator family of replay() that return a ConnectableObservable require an explicit call to ConnectableObservable.connect().

        Note: You sacrifice the ability to dispose the origin when you use the cache operator so be careful not to use this operator on Observables that emit an infinite or very large number of items that will use up memory. A possible workaround is to apply takeUntil with a predicate or another source before (and perhaps after) the application of cache().

        
         AtomicBoolean shouldStop = new AtomicBoolean();
        
         source.takeUntil(v -> shouldStop.get())
               .cache()
               .takeUntil(v -> shouldStop.get())
               .subscribe(...);
         
        Since the operator doesn't allow clearing the cached values either, the possible workaround is to forget all references to it via onTerminateDetach() applied along with the previous workaround:
        
         AtomicBoolean shouldStop = new AtomicBoolean();
        
         source.takeUntil(v -> shouldStop.get())
               .onTerminateDetach()
               .cache()
               .takeUntil(v -> shouldStop.get())
               .onTerminateDetach()
               .subscribe(...);
         
        Scheduler:
        cache does not operate by default on a particular Scheduler.
        Returns:
        the new Observable instance
        See Also:
        ReactiveX operators documentation: Replay, takeUntil(Predicate), takeUntil(ObservableSource)
      • cacheWithInitialCapacity

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> cacheWithInitialCapacity​(int initialCapacity)
        Returns an Observable that subscribes to the current Observable lazily, caches all of its events and replays them, in the same order as received, to all the downstream observers.

        This is useful when you want an Observable to cache responses and you can't control the subscribe/dispose behavior of all the Observers.

        The operator subscribes only when the first downstream observer subscribes and maintains a single subscription towards the current Observable. In contrast, the operator family of replay() that return a ConnectableObservable require an explicit call to ConnectableObservable.connect().

        Note: You sacrifice the ability to dispose the origin when you use the cache operator so be careful not to use this operator on Observables that emit an infinite or very large number of items that will use up memory. A possible workaround is to apply `takeUntil` with a predicate or another source before (and perhaps after) the application of cache().

        
         AtomicBoolean shouldStop = new AtomicBoolean();
        
         source.takeUntil(v -> shouldStop.get())
               .cache()
               .takeUntil(v -> shouldStop.get())
               .subscribe(...);
         
        Since the operator doesn't allow clearing the cached values either, the possible workaround is to forget all references to it via onTerminateDetach() applied along with the previous workaround:
        
         AtomicBoolean shouldStop = new AtomicBoolean();
        
         source.takeUntil(v -> shouldStop.get())
               .onTerminateDetach()
               .cache()
               .takeUntil(v -> shouldStop.get())
               .onTerminateDetach()
               .subscribe(...);
         
        Scheduler:
        cacheWithInitialCapacity does not operate by default on a particular Scheduler.

        Note: The capacity hint is not an upper bound on cache size. For that, consider replay(int) in combination with ConnectableObservable.autoConnect() or similar.

        Parameters:
        initialCapacity - hint for number of items to cache (for optimizing underlying data structure)
        Returns:
        the new Observable instance
        Throws:
        java.lang.IllegalArgumentException - if initialCapacity is non-positive
        See Also:
        ReactiveX operators documentation: Replay, takeUntil(Predicate), takeUntil(ObservableSource)
      • cast

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull U> @NonNull Observable<U> cast​(@NonNull
                                                              @NonNull java.lang.Class<@NonNull U> clazz)
        Returns an Observable that emits the upstream items while they can be cast via Class.cast(Object) until the upstream terminates, or until the upstream signals an item which can't be cast, resulting in a ClassCastException to be signaled to the downstream.

        Scheduler:
        cast does not operate by default on a particular Scheduler.
        Type Parameters:
        U - the output value type cast to
        Parameters:
        clazz - the target class to use to try and cast the upstream items into
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if clazz is null
        See Also:
        ReactiveX operators documentation: Map
      • collect

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull U> @NonNull Single<U> collect​(@NonNull
                                                             @NonNull Supplier<? extends @NonNull U> initialItemSupplier,
                                                             @NonNull
                                                             @NonNull BiConsumer<? super @NonNull U,​? super @NonNull T> collector)
        Collects items emitted by the finite source Observable into a single mutable data structure and returns a Single that emits this structure.

        This is a simplified version of reduce that does not need to return the state on each pass.

        Note that this operator requires the upstream to signal onComplete for the accumulator object to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatal OutOfMemoryError.

        Scheduler:
        collect does not operate by default on a particular Scheduler.
        Type Parameters:
        U - the accumulator and output type
        Parameters:
        initialItemSupplier - the mutable data structure that will collect the items
        collector - a function that accepts the state and an emitted item, and modifies the accumulator accordingly accordingly
        Returns:
        the new Single instance
        Throws:
        java.lang.NullPointerException - if initialItemSupplier or collector is null
        See Also:
        ReactiveX operators documentation: Reduce
      • collectInto

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull U> @NonNull Single<U> collectInto​(@NonNull
                                                                 @NonNull U initialItem,
                                                                 @NonNull
                                                                 @NonNull BiConsumer<? super @NonNull U,​? super @NonNull T> collector)
        Collects items emitted by the finite source Observable into a single mutable data structure and returns a Single that emits this structure.

        This is a simplified version of reduce that does not need to return the state on each pass.

        Note that this operator requires the upstream to signal onComplete for the accumulator object to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatal OutOfMemoryError.

        Scheduler:
        collectInto does not operate by default on a particular Scheduler.
        Type Parameters:
        U - the accumulator and output type
        Parameters:
        initialItem - the mutable data structure that will collect the items
        collector - a function that accepts the state and an emitted item, and modifies the accumulator accordingly accordingly
        Returns:
        the new Single instance
        Throws:
        java.lang.NullPointerException - if initialItem or collector is null
        See Also:
        ReactiveX operators documentation: Reduce
      • concatMap

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> concatMap​(@NonNull
                                                                   @NonNull Function<? super @NonNull T,​? extends ObservableSource<? extends @NonNull R>> mapper)
        Returns a new Observable that emits items resulting from applying a function that you supply to each item emitted by the current Observable, where that function returns an ObservableSource, and then emitting the items that result from concatenating those returned ObservableSources.

        Note that there is no guarantee where the given mapper function will be executed; it could be on the subscribing thread, on the upstream thread signaling the new item to be mapped or on the thread where the inner source terminates. To ensure the mapper function is confined to a known thread, use the concatMap(Function, int, Scheduler) overload.

        Scheduler:
        concatMap does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the type of the inner ObservableSource sources and thus the output type
        Parameters:
        mapper - a function that, when applied to an item emitted by the current Observable, returns an ObservableSource
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
        See Also:
        ReactiveX operators documentation: FlatMap, concatMap(Function, int, Scheduler)
      • concatMap

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> concatMap​(@NonNull
                                                                   @NonNull Function<? super @NonNull T,​? extends ObservableSource<? extends @NonNull R>> mapper,
                                                                   int bufferSize)
        Returns a new Observable that emits items resulting from applying a function that you supply to each item emitted by the current Observable, where that function returns an ObservableSource, and then emitting the items that result from concatenating those returned ObservableSources.

        Note that there is no guarantee where the given mapper function will be executed; it could be on the subscribing thread, on the upstream thread signaling the new item to be mapped or on the thread where the inner source terminates. To ensure the mapper function is confined to a known thread, use the concatMap(Function, int, Scheduler) overload.

        Scheduler:
        concatMap does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the type of the inner ObservableSource sources and thus the output type
        Parameters:
        mapper - a function that, when applied to an item emitted by the current Observable, returns an ObservableSource
        bufferSize - the number of elements expected from the current Observable to be buffered
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        See Also:
        ReactiveX operators documentation: FlatMap, concatMap(Function, int, Scheduler)
      • concatMap

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> concatMap​(@NonNull
                                                                   @NonNull Function<? super @NonNull T,​? extends ObservableSource<? extends @NonNull R>> mapper,
                                                                   int bufferSize,
                                                                   @NonNull
                                                                   @NonNull Scheduler scheduler)
        Returns a new Observable that emits items resulting from applying a function that you supply to each item emitted by the current Observable, where that function returns an ObservableSource, and then emitting the items that result from concatenating those returned ObservableSources.

        The difference between concatMap(Function, int) and this operator is that this operator guarantees the mapper function is executed on the specified scheduler.

        Scheduler:
        concatMap executes the given mapper function on the provided Scheduler.
        Type Parameters:
        R - the type of the inner ObservableSource sources and thus the output type
        Parameters:
        mapper - a function that, when applied to an item emitted by the current Observable, returns an ObservableSource
        bufferSize - the number of elements expected from the current Observable to be buffered
        scheduler - the scheduler where the mapper function will be executed
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if mapper or scheduler is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        Since:
        3.0.0
        See Also:
        ReactiveX operators documentation: FlatMap
      • concatMapDelayError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> concatMapDelayError​(@NonNull
                                                                             @NonNull Function<? super @NonNull T,​? extends ObservableSource<? extends @NonNull R>> mapper)
        Maps each of the items into an ObservableSource, subscribes to them one after the other, one at a time and emits their values in order while delaying any error from either this or any of the inner ObservableSources till all of them terminate.

        Note that there is no guarantee where the given mapper function will be executed; it could be on the subscribing thread, on the upstream thread signaling the new item to be mapped or on the thread where the inner source terminates. To ensure the mapper function is confined to a known thread, use the concatMapDelayError(Function, boolean, int, Scheduler) overload.

        Scheduler:
        concatMapDelayError does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the result value type
        Parameters:
        mapper - the function that maps the items of the current Observable into the inner ObservableSources.
        Returns:
        the new Observable instance with the concatenation behavior
        Throws:
        java.lang.NullPointerException - if mapper is null
        See Also:
        concatMapDelayError(Function, boolean, int, Scheduler)
      • concatMapDelayError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> concatMapDelayError​(@NonNull
                                                                             @NonNull Function<? super @NonNull T,​? extends ObservableSource<? extends @NonNull R>> mapper,
                                                                             boolean tillTheEnd,
                                                                             int bufferSize)
        Maps each of the items into an ObservableSource, subscribes to them one after the other, one at a time and emits their values in order while delaying any error from either this or any of the inner ObservableSources till all of them terminate.

        Note that there is no guarantee where the given mapper function will be executed; it could be on the subscribing thread, on the upstream thread signaling the new item to be mapped or on the thread where the inner source terminates. To ensure the mapper function is confined to a known thread, use the concatMapDelayError(Function, boolean, int, Scheduler) overload.

        Scheduler:
        concatMapDelayError does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the result value type
        Parameters:
        mapper - the function that maps the items of the current Observable into the inner ObservableSources.
        tillTheEnd - if true, all errors from the outer and inner ObservableSource sources are delayed until the end, if false, an error from the main source is signaled when the current Observable source terminates
        bufferSize - the number of elements expected from the current Observable to be buffered
        Returns:
        the new Observable instance with the concatenation behavior
        Throws:
        java.lang.NullPointerException - if mapper is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        See Also:
        concatMapDelayError(Function, boolean, int, Scheduler)
      • concatMapDelayError

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> concatMapDelayError​(@NonNull
                                                                             @NonNull Function<? super @NonNull T,​? extends ObservableSource<? extends @NonNull R>> mapper,
                                                                             boolean tillTheEnd,
                                                                             int bufferSize,
                                                                             @NonNull
                                                                             @NonNull Scheduler scheduler)
        Maps each of the items into an ObservableSource, subscribes to them one after the other, one at a time and emits their values in order while delaying any error from either this or any of the inner ObservableSources till all of them terminate.

        Scheduler:
        concatMapDelayError does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the result value type
        Parameters:
        mapper - the function that maps the items of the current Observable into the inner ObservableSources.
        tillTheEnd - if true, all errors from the outer and inner ObservableSource sources are delayed until the end, if false, an error from the main source is signaled when the current Observable source terminates
        bufferSize - the number of elements expected from the current Observable to be buffered
        scheduler - the scheduler where the mapper function will be executed
        Returns:
        the new Observable instance with the concatenation behavior
        Throws:
        java.lang.NullPointerException - if mapper or scheduler is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        Since:
        3.0.0
        See Also:
        concatMapDelayError(Function, boolean, int)
      • concatMapEager

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> concatMapEager​(@NonNull
                                                                        @NonNull Function<? super @NonNull T,​? extends ObservableSource<? extends @NonNull R>> mapper)
        Maps a sequence of values into ObservableSources and concatenates these ObservableSources eagerly into a single Observable sequence.

        Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the current Observables. The operator buffers the values emitted by these ObservableSources and then drains them in order, each one after the previous one completes.

        Scheduler:
        This method does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the value type
        Parameters:
        mapper - the function that maps a sequence of values into a sequence of ObservableSources that will be eagerly concatenated
        Returns:
        the new Observable instance with the specified concatenation behavior
        Throws:
        java.lang.NullPointerException - if mapper is null
        Since:
        2.0
      • concatMapEager

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> concatMapEager​(@NonNull
                                                                        @NonNull Function<? super @NonNull T,​? extends ObservableSource<? extends @NonNull R>> mapper,
                                                                        int maxConcurrency,
                                                                        int bufferSize)
        Maps a sequence of values into ObservableSources and concatenates these ObservableSources eagerly into a single Observable sequence.

        Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the current Observables. The operator buffers the values emitted by these ObservableSources and then drains them in order, each one after the previous one completes.

        Scheduler:
        This method does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the value type
        Parameters:
        mapper - the function that maps a sequence of values into a sequence of ObservableSources that will be eagerly concatenated
        maxConcurrency - the maximum number of concurrent subscribed ObservableSources
        bufferSize - hints about the number of expected items from each inner ObservableSource, must be positive
        Returns:
        the new Observable instance with the specified concatenation behavior
        Throws:
        java.lang.NullPointerException - if mapper is null
        java.lang.IllegalArgumentException - if maxConcurrency or bufferSize is non-positive
        Since:
        2.0
      • concatMapEagerDelayError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> concatMapEagerDelayError​(@NonNull
                                                                                  @NonNull Function<? super @NonNull T,​? extends ObservableSource<? extends @NonNull R>> mapper,
                                                                                  boolean tillTheEnd)
        Maps a sequence of values into ObservableSources and concatenates these ObservableSources eagerly into a single Observable sequence.

        Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the current Observables. The operator buffers the values emitted by these ObservableSources and then drains them in order, each one after the previous one completes.

        Scheduler:
        This method does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the value type
        Parameters:
        mapper - the function that maps a sequence of values into a sequence of ObservableSources that will be eagerly concatenated
        tillTheEnd - if true, all errors from the outer and inner ObservableSource sources are delayed until the end, if false, an error from the main source is signaled when the current Observable source terminates
        Returns:
        the new Observable instance with the specified concatenation behavior
        Throws:
        java.lang.NullPointerException - if mapper is null
        Since:
        2.0
      • concatMapEagerDelayError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> concatMapEagerDelayError​(@NonNull
                                                                                  @NonNull Function<? super @NonNull T,​? extends ObservableSource<? extends @NonNull R>> mapper,
                                                                                  boolean tillTheEnd,
                                                                                  int maxConcurrency,
                                                                                  int bufferSize)
        Maps a sequence of values into ObservableSources and concatenates these ObservableSources eagerly into a single Observable sequence.

        Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the current Observables. The operator buffers the values emitted by these ObservableSources and then drains them in order, each one after the previous one completes.

        Scheduler:
        This method does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the value type
        Parameters:
        mapper - the function that maps a sequence of values into a sequence of ObservableSources that will be eagerly concatenated
        tillTheEnd - if true, exceptions from the current Observable and all the inner ObservableSources are delayed until all of them terminate, if false, exception from the current Observable is delayed until the currently running ObservableSource terminates
        maxConcurrency - the maximum number of concurrent subscribed ObservableSources
        bufferSize - the number of elements expected from the current Observable and each inner ObservableSource to be buffered
        Returns:
        the new Observable instance with the specified concatenation behavior
        Throws:
        java.lang.NullPointerException - if mapper is null
        java.lang.IllegalArgumentException - if maxConcurrency or bufferSize is non-positive
        Since:
        2.0
      • concatMapCompletable

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Completable concatMapCompletable​(@NonNull
                                                               @NonNull Function<? super @NonNull T,​? extends CompletableSource> mapper)
        Maps each element of the current Observable into CompletableSources, subscribes to them one at a time in order and waits until the upstream and all CompletableSources complete.

        Scheduler:
        concatMapCompletable does not operate by default on a particular Scheduler.

        History: 2.1.6 - experimental

        Parameters:
        mapper - a function that, when applied to an item emitted by the current Observable, returns a CompletableSource
        Returns:
        the new Completable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
        Since:
        2.2
      • concatMapCompletable

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Completable concatMapCompletable​(@NonNull
                                                               @NonNull Function<? super @NonNull T,​? extends CompletableSource> mapper,
                                                               int capacityHint)
        Maps each element of the current Observable into CompletableSources, subscribes to them one at a time in order and waits until the upstream and all CompletableSources complete.

        Scheduler:
        concatMapCompletable does not operate by default on a particular Scheduler.

        History: 2.1.6 - experimental

        Parameters:
        mapper - a function that, when applied to an item emitted by the current Observable, returns a CompletableSource
        capacityHint - the number of upstream items expected to be buffered until the current CompletableSource, mapped from the current item, completes.
        Returns:
        the new Completable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
        java.lang.IllegalArgumentException - if capacityHint is non-positive
        Since:
        2.2
      • concatMapCompletableDelayError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Completable concatMapCompletableDelayError​(@NonNull
                                                                         @NonNull Function<? super @NonNull T,​? extends CompletableSource> mapper,
                                                                         boolean tillTheEnd)
        Maps the upstream items into CompletableSources and subscribes to them one after the other terminates, optionally delaying all errors till both the current Observable and all inner CompletableSources terminate.

        Scheduler:
        concatMapCompletableDelayError does not operate by default on a particular Scheduler.

        History: 2.1.11 - experimental

        Parameters:
        mapper - the function called with the upstream item and should return a CompletableSource to become the next source to be subscribed to
        tillTheEnd - If true, errors from the current Observable or any of the inner CompletableSources are delayed until all of them terminate. If false, an error from the current Observable is delayed until the current inner CompletableSource terminates and only then is it emitted to the downstream.
        Returns:
        the new Completable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
        Since:
        2.2
        See Also:
        concatMapCompletable(Function)
      • concatMapCompletableDelayError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Completable concatMapCompletableDelayError​(@NonNull
                                                                         @NonNull Function<? super @NonNull T,​? extends CompletableSource> mapper,
                                                                         boolean tillTheEnd,
                                                                         int bufferSize)
        Maps the upstream items into CompletableSources and subscribes to them one after the other terminates, optionally delaying all errors till both the current Observable and all inner CompletableSources terminate.

        Scheduler:
        concatMapCompletableDelayError does not operate by default on a particular Scheduler.

        History: 2.1.11 - experimental

        Parameters:
        mapper - the function called with the upstream item and should return a CompletableSource to become the next source to be subscribed to
        tillTheEnd - If true, errors from the current Observable or any of the inner CompletableSources are delayed until all of them terminate. If false, an error from the current Observable is delayed until the current inner CompletableSource terminates and only then is it emitted to the downstream.
        bufferSize - The number of upstream items expected to be buffered so that fresh items are ready to be mapped when a previous CompletableSource terminates.
        Returns:
        the new Completable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        Since:
        2.2
        See Also:
        concatMapCompletable(Function, int)
      • concatMapIterable

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull U> @NonNull Observable<U> concatMapIterable​(@NonNull
                                                                           @NonNull Function<? super @NonNull T,​? extends java.lang.Iterable<? extends @NonNull U>> mapper)
        Returns an Observable that concatenate each item emitted by the current Observable with the values in an Iterable corresponding to that item that is generated by a selector.

        Scheduler:
        concatMapIterable does not operate by default on a particular Scheduler.
        Type Parameters:
        U - the type of item emitted by the resulting Observable
        Parameters:
        mapper - a function that returns an Iterable sequence of values for when given an item emitted by the current Observable
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
        See Also:
        ReactiveX operators documentation: FlatMap
      • concatMapMaybe

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> concatMapMaybe​(@NonNull
                                                                        @NonNull Function<? super @NonNull T,​? extends MaybeSource<? extends @NonNull R>> mapper,
                                                                        int bufferSize)
        Maps the upstream items into MaybeSources and subscribes to them one after the other succeeds or completes, emits their success value if available or terminates immediately if either the current Observable or the current inner MaybeSource fail.

        Scheduler:
        concatMapMaybe does not operate by default on a particular Scheduler.

        History: 2.1.11 - experimental

        Type Parameters:
        R - the result type of the inner MaybeSources
        Parameters:
        mapper - the function called with the upstream item and should return a MaybeSource to become the next source to be subscribed to
        bufferSize - The number of upstream items expected to be buffered so that fresh items are ready to be mapped when a previous MaybeSource terminates.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        Since:
        2.2
        See Also:
        concatMapMaybe(Function), concatMapMaybeDelayError(Function, boolean, int)
      • concatMapMaybeDelayError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> concatMapMaybeDelayError​(@NonNull
                                                                                  @NonNull Function<? super @NonNull T,​? extends MaybeSource<? extends @NonNull R>> mapper,
                                                                                  boolean tillTheEnd)
        Maps the upstream items into MaybeSources and subscribes to them one after the other terminates, emits their success value if available and optionally delaying all errors till both the current Observable and all inner MaybeSources terminate.

        Scheduler:
        concatMapMaybeDelayError does not operate by default on a particular Scheduler.

        History: 2.1.11 - experimental

        Type Parameters:
        R - the result type of the inner MaybeSources
        Parameters:
        mapper - the function called with the upstream item and should return a MaybeSource to become the next source to be subscribed to
        tillTheEnd - If true, errors from the current Observable or any of the inner MaybeSources are delayed until all of them terminate. If false, an error from the current Observable is delayed until the current inner MaybeSource terminates and only then is it emitted to the downstream.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
        Since:
        2.2
        See Also:
        concatMapMaybe(Function, int), concatMapMaybeDelayError(Function, boolean, int)
      • concatMapMaybeDelayError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> concatMapMaybeDelayError​(@NonNull
                                                                                  @NonNull Function<? super @NonNull T,​? extends MaybeSource<? extends @NonNull R>> mapper,
                                                                                  boolean tillTheEnd,
                                                                                  int bufferSize)
        Maps the upstream items into MaybeSources and subscribes to them one after the other terminates, emits their success value if available and optionally delaying all errors till both the current Observable and all inner MaybeSources terminate.

        Scheduler:
        concatMapMaybeDelayError does not operate by default on a particular Scheduler.

        History: 2.1.11 - experimental

        Type Parameters:
        R - the result type of the inner MaybeSources
        Parameters:
        mapper - the function called with the upstream item and should return a MaybeSource to become the next source to be subscribed to
        tillTheEnd - If true, errors from the current Observable or any of the inner MaybeSources are delayed until all of them terminate. If false, an error from the current Observable is delayed until the current inner MaybeSource terminates and only then is it emitted to the downstream.
        bufferSize - The number of upstream items expected to be buffered so that fresh items are ready to be mapped when a previous MaybeSource terminates.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        Since:
        2.2
        See Also:
        concatMapMaybe(Function, int)
      • concatMapSingle

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> concatMapSingle​(@NonNull
                                                                         @NonNull Function<? super @NonNull T,​? extends SingleSource<? extends @NonNull R>> mapper,
                                                                         int bufferSize)
        Maps the upstream items into SingleSources and subscribes to them one after the other succeeds, emits their success values or terminates immediately if either the current Observable or the current inner SingleSource fail.

        Scheduler:
        concatMapSingle does not operate by default on a particular Scheduler.

        History: 2.1.11 - experimental

        Type Parameters:
        R - the result type of the inner SingleSources
        Parameters:
        mapper - the function called with the upstream item and should return a SingleSource to become the next source to be subscribed to
        bufferSize - The number of upstream items expected to be buffered so that fresh items are ready to be mapped when a previous SingleSource terminates.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        Since:
        2.2
        See Also:
        concatMapSingle(Function), concatMapSingleDelayError(Function, boolean, int)
      • concatMapSingleDelayError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> concatMapSingleDelayError​(@NonNull
                                                                                   @NonNull Function<? super @NonNull T,​? extends SingleSource<? extends @NonNull R>> mapper,
                                                                                   boolean tillTheEnd)
        Maps the upstream items into SingleSources and subscribes to them one after the other succeeds or fails, emits their success values and optionally delays all errors till both the current Observable and all inner SingleSources terminate.

        Scheduler:
        concatMapSingleDelayError does not operate by default on a particular Scheduler.

        History: 2.1.11 - experimental

        Type Parameters:
        R - the result type of the inner SingleSources
        Parameters:
        mapper - the function called with the upstream item and should return a SingleSource to become the next source to be subscribed to
        tillTheEnd - If true, errors from the current Observable or any of the inner SingleSources are delayed until all of them terminate. If false, an error from the current Observable is delayed until the current inner SingleSource terminates and only then is it emitted to the downstream.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
        Since:
        2.2
        See Also:
        concatMapSingle(Function, int), concatMapSingleDelayError(Function, boolean, int)
      • concatMapSingleDelayError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> concatMapSingleDelayError​(@NonNull
                                                                                   @NonNull Function<? super @NonNull T,​? extends SingleSource<? extends @NonNull R>> mapper,
                                                                                   boolean tillTheEnd,
                                                                                   int bufferSize)
        Maps the upstream items into SingleSources and subscribes to them one after the other succeeds or fails, emits their success values and optionally delays errors till both the current Observable and all inner SingleSources terminate.

        Scheduler:
        concatMapSingleDelayError does not operate by default on a particular Scheduler.

        History: 2.1.11 - experimental

        Type Parameters:
        R - the result type of the inner SingleSources
        Parameters:
        mapper - the function called with the upstream item and should return a SingleSource to become the next source to be subscribed to
        tillTheEnd - If true, errors from the current Observable or any of the inner SingleSources are delayed until all of them terminate. If false, an error from the current Observable is delayed until the current inner SingleSource terminates and only then is it emitted to the downstream.
        bufferSize - The number of upstream items expected to be buffered so that fresh items are ready to be mapped when a previous SingleSource terminates.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        Since:
        2.2
        See Also:
        concatMapSingle(Function, int)
      • concatWith

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> concatWith​(@NonNull
                                                       @NonNull SingleSource<? extends @NonNull T> other)
        Returns an Observable that emits the items from the current Observable followed by the success item or error event of the other SingleSource.

        Scheduler:
        concatWith does not operate by default on a particular Scheduler.

        History: 2.1.10 - experimental

        Parameters:
        other - the SingleSource whose signal should be emitted after the current Observable completes normally.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if other is null
        Since:
        2.2
      • concatWith

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> concatWith​(@NonNull
                                                       @NonNull MaybeSource<? extends @NonNull T> other)
        Returns an Observable that emits the items from the current Observable followed by the success item or terminal events of the other MaybeSource.

        Scheduler:
        concatWith does not operate by default on a particular Scheduler.

        History: 2.1.10 - experimental

        Parameters:
        other - the MaybeSource whose signal should be emitted after the current Observable completes normally.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if other is null
        Since:
        2.2
      • concatWith

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> concatWith​(@NonNull
                                                       @NonNull CompletableSource other)
        Returns an Observable that emits items from the current Observable and when it completes normally, the other CompletableSource is subscribed to and the returned Observable emits its terminal events.

        Scheduler:
        concatWith does not operate by default on a particular Scheduler.

        History: 2.1.10 - experimental

        Parameters:
        other - the CompletableSource to subscribe to once the current Observable completes normally
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if other is null
        Since:
        2.2
      • debounce

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull U> @NonNull Observable<T> debounce​(@NonNull
                                                                  @NonNull Function<? super @NonNull T,​? extends ObservableSource<@NonNull U>> debounceIndicator)
        Returns an Observable that mirrors the current Observable, except that it drops items emitted by the current Observable that are followed by another item within a computed debounce duration denoted by an item emission or completion from a generated inner ObservableSource for that original item.

        The delivery of the item happens on the thread of the first onNext or onComplete signal of the generated ObservableSource sequence, which if takes too long, a newer item may arrive from the upstream, causing the generated sequence to get disposed, which may also interrupt any downstream blocking operation (yielding an InterruptedException). It is recommended processing items that may take long time to be moved to another thread via observeOn(io.reactivex.rxjava3.core.Scheduler) applied after debounce itself.

        Scheduler:
        This version of debounce does not operate by default on a particular Scheduler.
        Type Parameters:
        U - the debounce value type (ignored)
        Parameters:
        debounceIndicator - function to return a sequence that indicates the throttle duration for each item via its own emission or completion
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if debounceIndicator is null
        See Also:
        ReactiveX operators documentation: Debounce
      • debounce

        @CheckReturnValue
        @SchedulerSupport("io.reactivex:computation")
        @NonNull
        public final @NonNull Observable<T> debounce​(long timeout,
                                                     @NonNull
                                                     @NonNull java.util.concurrent.TimeUnit unit)
        Returns an Observable that mirrors the current Observable, except that it drops items emitted by the current Observable that are followed by newer items before a timeout value expires. The timer resets on each emission.

        Note: If items keep being emitted by the current Observable faster than the timeout then no items will be emitted by the resulting Observable.

        Delivery of the item after the grace period happens on the computation Scheduler's Worker which if takes too long, a newer item may arrive from the upstream, causing the Worker's task to get disposed, which may also interrupt any downstream blocking operation (yielding an InterruptedException). It is recommended processing items that may take long time to be moved to another thread via observeOn(io.reactivex.rxjava3.core.Scheduler) applied after debounce itself.

        Scheduler:
        debounce operates by default on the computation Scheduler.
        Parameters:
        timeout - the length of the window of time that must pass after the emission of an item from the current Observable in which the Observable emits no items in order for the item to be emitted by the resulting Observable
        unit - the unit of time for the specified timeout
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit is null
        See Also:
        ReactiveX operators documentation: Debounce, throttleWithTimeout(long, TimeUnit)
      • debounce

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<T> debounce​(long timeout,
                                                     @NonNull
                                                     @NonNull java.util.concurrent.TimeUnit unit,
                                                     @NonNull
                                                     @NonNull Scheduler scheduler)
        Returns an Observable that mirrors the current Observable, except that it drops items emitted by the current Observable that are followed by newer items before a timeout value expires on a specified Scheduler. The timer resets on each emission.

        Note: If items keep being emitted by the current Observable faster than the timeout then no items will be emitted by the resulting Observable.

        Delivery of the item after the grace period happens on the given Scheduler's Worker which if takes too long, a newer item may arrive from the upstream, causing the Worker's task to get disposed, which may also interrupt any downstream blocking operation (yielding an InterruptedException). It is recommended processing items that may take long time to be moved to another thread via observeOn(io.reactivex.rxjava3.core.Scheduler) applied after debounce itself.

        Scheduler:
        You specify which Scheduler this operator will use.
        Parameters:
        timeout - the time each item has to be "the most recent" of those emitted by the current Observable to ensure that it's not dropped
        unit - the unit of time for the specified timeout
        scheduler - the Scheduler to use internally to manage the timers that handle the timeout for each item
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null
        See Also:
        ReactiveX operators documentation: Debounce, throttleWithTimeout(long, TimeUnit, Scheduler)
      • debounce

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<T> debounce​(long timeout,
                                                     @NonNull
                                                     @NonNull java.util.concurrent.TimeUnit unit,
                                                     @NonNull
                                                     @NonNull Scheduler scheduler,
                                                     @NonNull
                                                     @NonNull Consumer<? super @NonNull T> onDropped)
        Returns an Observable that mirrors the current Observable, except that it drops items emitted by the current Observable that are followed by newer items before a timeout value expires on a specified Scheduler. The timer resets on each emission.

        Note: If items keep being emitted by the current Observable faster than the timeout then no items will be emitted by the resulting Observable.

        Delivery of the item after the grace period happens on the given Scheduler's Worker which if takes too long, a newer item may arrive from the upstream, causing the Worker's task to get disposed, which may also interrupt any downstream blocking operation (yielding an InterruptedException). It is recommended processing items that may take long time to be moved to another thread via observeOn(io.reactivex.rxjava3.core.Scheduler) applied after debounce itself.

        Scheduler:
        You specify which Scheduler this operator will use.
        Parameters:
        timeout - the time each item has to be "the most recent" of those emitted by the current Observable to ensure that it's not dropped
        unit - the unit of time for the specified timeout
        scheduler - the Scheduler to use internally to manage the timers that handle the timeout for each item
        onDropped - called with the current entry when it has been replaced by a new one
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null } or onDropped is null
        Since:
        3.1.6 - Experimental
        See Also:
        ReactiveX operators documentation: Debounce, throttleWithTimeout(long, TimeUnit, Scheduler, Consumer)
      • delay

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull U> @NonNull Observable<T> delay​(@NonNull
                                                               @NonNull Function<? super @NonNull T,​? extends ObservableSource<@NonNull U>> itemDelayIndicator)
        Returns an Observable that delays the emissions of the current Observable via a per-item derived ObservableSource's item emission or termination, on a per source item basis.

        Note: the resulting Observable will immediately propagate any onError notification from the current Observable.

        Scheduler:
        This version of delay does not operate by default on a particular Scheduler.
        Type Parameters:
        U - the item delay value type (ignored)
        Parameters:
        itemDelayIndicator - a function that returns an ObservableSource for each item emitted by the current Observable, which is then used to delay the emission of that item by the resulting Observable until the ObservableSource returned from itemDelay emits an item
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if itemDelayIndicator is null
        See Also:
        ReactiveX operators documentation: Delay
      • delay

        @CheckReturnValue
        @SchedulerSupport("io.reactivex:computation")
        @NonNull
        public final @NonNull Observable<T> delay​(long time,
                                                  @NonNull
                                                  @NonNull java.util.concurrent.TimeUnit unit,
                                                  boolean delayError)
        Returns an Observable that emits the items emitted by the current Observable shifted forward in time by a specified delay. If delayError is true, error notifications will also be delayed.

        Scheduler:
        This version of delay operates by default on the computation Scheduler.
        Parameters:
        time - the delay to shift the source by
        unit - the TimeUnit in which period is defined
        delayError - if true, the upstream exception is signaled with the given delay, after all preceding normal elements, if false, the upstream exception is signaled immediately
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit is null
        See Also:
        ReactiveX operators documentation: Delay, delay(long, TimeUnit, Scheduler, boolean)
      • delay

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<T> delay​(long time,
                                                  @NonNull
                                                  @NonNull java.util.concurrent.TimeUnit unit,
                                                  @NonNull
                                                  @NonNull Scheduler scheduler,
                                                  boolean delayError)
        Returns an Observable that emits the items emitted by the current Observable shifted forward in time by a specified delay. If delayError is true, error notifications will also be delayed.

        Scheduler:
        You specify which Scheduler this operator will use.
        Parameters:
        time - the delay to shift the source by
        unit - the time unit of delay
        scheduler - the Scheduler to use for delaying
        delayError - if true, the upstream exception is signaled with the given delay, after all preceding normal elements, if false, the upstream exception is signaled immediately
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null
        See Also:
        ReactiveX operators documentation: Delay
      • delay

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull U,​@NonNull V> @NonNull Observable<T> delay​(@NonNull
                                                                                @NonNull ObservableSource<@NonNull U> subscriptionIndicator,
                                                                                @NonNull
                                                                                @NonNull Function<? super @NonNull T,​? extends ObservableSource<@NonNull V>> itemDelayIndicator)
        Returns an Observable that delays the subscription to and emissions from the current Observable via ObservableSources for the subscription itself and on a per-item basis.

        Note: the resulting Observable will immediately propagate any onError notification from the current Observable.

        Scheduler:
        This version of delay does not operate by default on a particular Scheduler.
        Type Parameters:
        U - the subscription delay value type (ignored)
        V - the item delay value type (ignored)
        Parameters:
        subscriptionIndicator - a function that returns an ObservableSource that triggers the subscription to the current Observable once it emits any item
        itemDelayIndicator - a function that returns an ObservableSource for each item emitted by the current Observable, which is then used to delay the emission of that item by the resulting Observable until the ObservableSource returned from itemDelay emits an item
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if subscriptionIndicator or itemDelayIndicator is null
        See Also:
        ReactiveX operators documentation: Delay
      • delaySubscription

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull U> @NonNull Observable<T> delaySubscription​(@NonNull
                                                                           @NonNull ObservableSource<@NonNull U> subscriptionIndicator)
        Returns an Observable that delays the subscription to the current Observable until the other ObservableSource emits an element or completes normally.

        Scheduler:
        This method does not operate by default on a particular Scheduler.
        Type Parameters:
        U - the value type of the other Observable, irrelevant
        Parameters:
        subscriptionIndicator - the other ObservableSource that should trigger the subscription to the current Observable.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if subscriptionIndicator is null
        Since:
        2.0
      • delaySubscription

        @CheckReturnValue
        @SchedulerSupport("io.reactivex:computation")
        @NonNull
        public final @NonNull Observable<T> delaySubscription​(long time,
                                                              @NonNull
                                                              @NonNull java.util.concurrent.TimeUnit unit)
        Returns an Observable that delays the subscription to the current Observable by a given amount of time.

        Scheduler:
        This version of delaySubscription operates by default on the computation Scheduler.
        Parameters:
        time - the time to delay the subscription
        unit - the time unit of delay
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit is null
        See Also:
        ReactiveX operators documentation: Delay
      • delaySubscription

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<T> delaySubscription​(long time,
                                                              @NonNull
                                                              @NonNull java.util.concurrent.TimeUnit unit,
                                                              @NonNull
                                                              @NonNull Scheduler scheduler)
        Returns an Observable that delays the subscription to the current Observable by a given amount of time, both waiting and subscribing on a given Scheduler.

        Scheduler:
        You specify which Scheduler this operator will use.
        Parameters:
        time - the time to delay the subscription
        unit - the time unit of delay
        scheduler - the Scheduler on which the waiting and subscription will happen
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null
        See Also:
        ReactiveX operators documentation: Delay
      • dematerialize

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> dematerialize​(@NonNull
                                                                       @NonNull Function<? super @NonNull T,​Notification<@NonNull R>> selector)
        Returns an Observable that reverses the effect of materialize by transforming the Notification objects extracted from the source items via a selector function into their respective Observer signal types.

        The intended use of the selector function is to perform a type-safe identity mapping (see example) on a source that is already of type Notification<T>. The Java language doesn't allow limiting instance methods to a certain generic argument shape, therefore, a function is used to ensure the conversion remains type safe.

        When the upstream signals an onError or onComplete item, the returned Observable disposes of the flow and terminates with that type of terminal event:

        
         Observable.just(createOnNext(1), createOnComplete(), createOnNext(2))
         .doOnDispose(() -> System.out.println("Disposed!"));
         .dematerialize(notification -> notification)
         .test()
         .assertResult(1);
         
        If the upstream signals onError or onComplete directly, the flow is terminated with the same event.
        
         Observable.just(createOnNext(1), createOnNext(2))
         .dematerialize(notification -> notification)
         .test()
         .assertResult(1, 2);
         
        If this behavior is not desired, the completion can be suppressed by applying concatWith(ObservableSource) with a never() source.
        Scheduler:
        dematerialize does not operate by default on a particular Scheduler.

        History: 2.2.4 - experimental

        Type Parameters:
        R - the output value type
        Parameters:
        selector - function that returns the upstream item and should return a Notification to signal the corresponding Observer event to the downstream.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if selector is null
        Since:
        3.0.0
        See Also:
        ReactiveX operators documentation: Dematerialize
      • distinct

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> distinct()
        Returns an Observable that emits all items emitted by the current Observable that are distinct based on Object.equals(Object) comparison.

        It is recommended the elements' class T in the flow overrides the default Object.equals() and Object.hashCode() to provide meaningful comparison between items as the default Java implementation only considers reference equivalence.

        By default, distinct() uses an internal HashSet per Observer to remember previously seen items and uses Set.add(Object) returning false as the indicator for duplicates.

        Note that this internal HashSet may grow unbounded as items won't be removed from it by the operator. Therefore, using very long or infinite upstream (with very distinct elements) may lead to OutOfMemoryError.

        Customizing the retention policy can happen only by providing a custom Collection implementation to the distinct(Function, Supplier) overload.

        Scheduler:
        distinct does not operate by default on a particular Scheduler.
        Returns:
        the new Observable instance
        See Also:
        ReactiveX operators documentation: Distinct, distinct(Function), distinct(Function, Supplier)
      • distinct

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull K> @NonNull Observable<T> distinct​(@NonNull
                                                                  @NonNull Function<? super @NonNull T,​@NonNull K> keySelector)
        Returns an Observable that emits all items emitted by the current Observable that are distinct according to a key selector function and based on Object.equals(Object) comparison of the objects returned by the key selector function.

        It is recommended the keys' class K overrides the default Object.equals() and Object.hashCode() to provide meaningful comparison between the key objects as the default Java implementation only considers reference equivalence.

        By default, distinct() uses an internal HashSet per Observer to remember previously seen keys and uses Set.add(Object) returning false as the indicator for duplicates.

        Note that this internal HashSet may grow unbounded as keys won't be removed from it by the operator. Therefore, using very long or infinite upstream (with very distinct keys) may lead to OutOfMemoryError.

        Customizing the retention policy can happen only by providing a custom Collection implementation to the distinct(Function, Supplier) overload.

        Scheduler:
        distinct does not operate by default on a particular Scheduler.
        Type Parameters:
        K - the key type
        Parameters:
        keySelector - a function that projects an emitted item to a key value that is used to decide whether an item is distinct from another one or not
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if keySelector is null
        See Also:
        ReactiveX operators documentation: Distinct, distinct(Function, Supplier)
      • distinct

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull K> @NonNull Observable<T> distinct​(@NonNull
                                                                  @NonNull Function<? super @NonNull T,​@NonNull K> keySelector,
                                                                  @NonNull
                                                                  @NonNull Supplier<? extends java.util.Collection<? super @NonNull K>> collectionSupplier)
        Returns an Observable that emits all items emitted by the current Observable that are distinct according to a key selector function and based on Object.equals(Object) comparison of the objects returned by the key selector function.

        It is recommended the keys' class K overrides the default Object.equals() and Object.hashCode() to provide meaningful comparison between the key objects as the default Java implementation only considers reference equivalence.

        Scheduler:
        distinct does not operate by default on a particular Scheduler.
        Type Parameters:
        K - the key type
        Parameters:
        keySelector - a function that projects an emitted item to a key value that is used to decide whether an item is distinct from another one or not
        collectionSupplier - function called for each individual Observer to return a Collection subtype for holding the extracted keys and whose add() method's return indicates uniqueness.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if keySelector or collectionSupplier is null
        See Also:
        ReactiveX operators documentation: Distinct
      • distinctUntilChanged

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> distinctUntilChanged()
        Returns an Observable that emits all items emitted by the current Observable that are distinct from their immediate predecessors based on Object.equals(Object) comparison.

        It is recommended the elements' class T in the flow overrides the default Object.equals() to provide meaningful comparison between items as the default Java implementation only considers reference equivalence. Alternatively, use the distinctUntilChanged(BiPredicate) overload and provide a comparison function in case the class T can't be overridden with custom equals() or the comparison itself should happen on different terms or properties of the class T.

        Note that the operator always retains the latest item from upstream regardless of the comparison result and uses it in the next comparison with the next upstream item.

        Note that if element type T in the flow is mutable, the comparison of the previous and current item may yield unexpected results if the items are mutated externally. Common cases are mutable CharSequences or Lists where the objects will actually have the same references when they are modified and distinctUntilChanged will evaluate subsequent items as same. To avoid such situation, it is recommended that mutable data is converted to an immutable one, for example using map(CharSequence::toString) or map(list -> Collections.unmodifiableList(new ArrayList<>(list))).

        Scheduler:
        distinctUntilChanged does not operate by default on a particular Scheduler.
        Returns:
        the new Observable instance
        See Also:
        ReactiveX operators documentation: Distinct, distinctUntilChanged(BiPredicate)
      • distinctUntilChanged

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull K> @NonNull Observable<T> distinctUntilChanged​(@NonNull
                                                                              @NonNull Function<? super @NonNull T,​@NonNull K> keySelector)
        Returns an Observable that emits all items emitted by the current Observable that are distinct from their immediate predecessors, according to a key selector function and based on Object.equals(Object) comparison of those objects returned by the key selector function.

        It is recommended the keys' class K overrides the default Object.equals() to provide meaningful comparison between the key objects as the default Java implementation only considers reference equivalence. Alternatively, use the distinctUntilChanged(BiPredicate) overload and provide a comparison function in case the class K can't be overridden with custom equals() or the comparison itself should happen on different terms or properties of the item class T (for which the keys can be derived via a similar selector).

        Note that the operator always retains the latest key from upstream regardless of the comparison result and uses it in the next comparison with the next key derived from the next upstream item.

        Note that if element type T in the flow is mutable, the comparison of the previous and current item may yield unexpected results if the items are mutated externally. Common cases are mutable CharSequences or Lists where the objects will actually have the same references when they are modified and distinctUntilChanged will evaluate subsequent items as same. To avoid such situation, it is recommended that mutable data is converted to an immutable one, for example using map(CharSequence::toString) or map(list -> Collections.unmodifiableList(new ArrayList<>(list))).

        Scheduler:
        distinctUntilChanged does not operate by default on a particular Scheduler.
        Type Parameters:
        K - the key type
        Parameters:
        keySelector - a function that projects an emitted item to a key value that is used to decide whether an item is distinct from another one or not
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if keySelector is null
        See Also:
        ReactiveX operators documentation: Distinct
      • distinctUntilChanged

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> distinctUntilChanged​(@NonNull
                                                                 @NonNull BiPredicate<? super @NonNull T,​? super @NonNull T> comparer)
        Returns an Observable that emits all items emitted by the current Observable that are distinct from their immediate predecessors when compared with each other via the provided comparator function.

        Note that the operator always retains the latest item from upstream regardless of the comparison result and uses it in the next comparison with the next upstream item.

        Note that if element type T in the flow is mutable, the comparison of the previous and current item may yield unexpected results if the items are mutated externally. Common cases are mutable CharSequences or Lists where the objects will actually have the same references when they are modified and distinctUntilChanged will evaluate subsequent items as same. To avoid such situation, it is recommended that mutable data is converted to an immutable one, for example using map(CharSequence::toString) or map(list -> Collections.unmodifiableList(new ArrayList<>(list))).

        Scheduler:
        distinctUntilChanged does not operate by default on a particular Scheduler.
        Parameters:
        comparer - the function that receives the previous item and the current item and is expected to return true if the two are equal, thus skipping the current value.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if comparer is null
        Since:
        2.0
        See Also:
        ReactiveX operators documentation: Distinct
      • doAfterNext

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> doAfterNext​(@NonNull
                                                        @NonNull Consumer<? super @NonNull T> onAfterNext)
        Calls the specified Consumer with the current item after this item has been emitted to the downstream.

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

        Scheduler:
        doAfterNext does not operate by default on a particular Scheduler.
        Operator-fusion:
        This operator supports boundary-limited synchronous or asynchronous queue-fusion.

        History: 2.0.1 - experimental

        Parameters:
        onAfterNext - the Consumer that will be called after emitting an item from upstream to the downstream
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if onAfterNext is null
        Since:
        2.1
      • doFinally

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> doFinally​(@NonNull
                                                      @NonNull Action onFinally)
        Calls the specified action after the current Observable signals onError or onCompleted 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.
        Operator-fusion:
        This operator supports boundary-limited synchronous or asynchronous queue-fusion.

        History: 2.0.1 - experimental

        Parameters:
        onFinally - the action called when the current Observable terminates or gets disposed
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if onFinally is null
        Since:
        2.1
      • doOnDispose

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> doOnDispose​(@NonNull
                                                        @NonNull Action onDispose)
        Calls the given shared Action if the downstream disposes the sequence.

        The action is shared between subscriptions and thus may be called concurrently from multiple threads; the action must be thread safe.

        If the action throws a runtime exception, that exception is rethrown by the dispose() call, sometimes as a CompositeException if there were multiple exceptions along the way.

        Scheduler:
        doOnDispose does not operate by default on a particular Scheduler.
        Parameters:
        onDispose - the action that gets called when the current Observable's Disposable is disposed
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if onDispose is null
        See Also:
        ReactiveX operators documentation: Do
      • doOnEach

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> doOnEach​(@NonNull
                                                     @NonNull Observer<? super @NonNull T> observer)
        Returns an Observable that forwards the items and terminal events of the current Observable to its Observers and to the given shared Observer instance.

        In case the onError of the supplied observer throws, the downstream will receive a composite exception containing the original exception and the exception thrown by onError. If either the onNext or the onComplete method of the supplied observer throws, the downstream will be terminated and will receive this thrown exception.

        Scheduler:
        doOnEach does not operate by default on a particular Scheduler.
        Parameters:
        observer - the observer to be notified about onNext, onError and onComplete events on its respective methods before the actual downstream Observer gets notified.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if observer is null
        See Also:
        ReactiveX operators documentation: Do
      • doOnError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> doOnError​(@NonNull
                                                      @NonNull Consumer<? super java.lang.Throwable> onError)
        Calls the given Consumer with the error Throwable if the current Observable failed before forwarding it to the downstream.

        In case the onError action throws, the downstream will receive a composite exception containing the original exception and the exception thrown by onError.

        Scheduler:
        doOnError does not operate by default on a particular Scheduler.
        Parameters:
        onError - the action to invoke if the current Observable calls onError
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if onError is null
        See Also:
        ReactiveX operators documentation: Do
      • doOnSubscribe

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> doOnSubscribe​(@NonNull
                                                          @NonNull Consumer<? super Disposable> onSubscribe)
        Returns an Observable so that it invokes the given Consumer when the current Observable is subscribed from its Observers. Each subscription will result in an invocation of the given action except when the current Observable is reference counted, in which case the current Observable will invoke the given action for the first subscription.

        Scheduler:
        doOnSubscribe does not operate by default on a particular Scheduler.
        Parameters:
        onSubscribe - the Consumer that gets called when an Observer subscribes to the current Observable
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if onSubscribe is null
        See Also:
        ReactiveX operators documentation: Do
      • elementAt

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Maybe<T> elementAt​(long index)
        Returns a Maybe that emits the single item at a specified index in a sequence of emissions from the current Observable or completes if the current Observable signals fewer elements than index.

        Scheduler:
        elementAt does not operate by default on a particular Scheduler.
        Parameters:
        index - the zero-based index of the item to retrieve
        Returns:
        the new Maybe instance
        Throws:
        java.lang.IndexOutOfBoundsException - if index is negative
        See Also:
        ReactiveX operators documentation: ElementAt
      • elementAt

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Single<T> elementAt​(long index,
                                                  @NonNull
                                                  @NonNull T defaultItem)
        Returns a Single that emits the item found at a specified index in a sequence of emissions from the current Observable, or a default item if that index is out of range.

        Scheduler:
        elementAt does not operate by default on a particular Scheduler.
        Parameters:
        index - the zero-based index of the item to retrieve
        defaultItem - the default item
        Returns:
        the new Single instance
        Throws:
        java.lang.NullPointerException - if defaultItem is null
        java.lang.IndexOutOfBoundsException - if index is negative
        See Also:
        ReactiveX operators documentation: ElementAt
      • elementAtOrError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Single<T> elementAtOrError​(long index)
        Returns a Single that emits the item found at a specified index in a sequence of emissions from the current Observable or signals a NoSuchElementException if the current Observable signals fewer elements than index.

        Scheduler:
        elementAtOrError does not operate by default on a particular Scheduler.
        Parameters:
        index - the zero-based index of the item to retrieve
        Returns:
        the new Single instance
        Throws:
        java.lang.IndexOutOfBoundsException - if index is negative
        See Also:
        ReactiveX operators documentation: ElementAt
      • flatMap

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> flatMap​(@NonNull
                                                                 @NonNull Function<? super @NonNull T,​? extends ObservableSource<? extends @NonNull R>> mapper,
                                                                 boolean delayErrors)
        Returns an Observable that emits items based on applying a function that you supply to each item emitted by the current Observable, where that function returns an ObservableSource, and then merging those returned ObservableSources and emitting the results of this merger.

        Scheduler:
        flatMap does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the value type of the inner ObservableSources and the output type
        Parameters:
        mapper - a function that, when applied to an item emitted by the current Observable, returns an ObservableSource
        delayErrors - if true, exceptions from the current Observable and all inner ObservableSources are delayed until all of them terminate if false, the first one signaling an exception will terminate the whole sequence immediately
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
        See Also:
        ReactiveX operators documentation: FlatMap
      • flatMap

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> flatMap​(@NonNull
                                                                 @NonNull Function<? super @NonNull T,​? extends ObservableSource<? extends @NonNull R>> mapper,
                                                                 boolean delayErrors,
                                                                 int maxConcurrency)
        Returns an Observable that emits items based on applying a function that you supply to each item emitted by the current Observable, where that function returns an ObservableSource, and then merging those returned ObservableSources and emitting the results of this merger, while limiting the maximum number of concurrent subscriptions to these ObservableSources.

        Scheduler:
        flatMap does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the value type of the inner ObservableSources and the output type
        Parameters:
        mapper - a function that, when applied to an item emitted by the current Observable, returns an ObservableSource
        maxConcurrency - the maximum number of ObservableSources that may be subscribed to concurrently
        delayErrors - if true, exceptions from the current Observable and all inner ObservableSources are delayed until all of them terminate if false, the first one signaling an exception will terminate the whole sequence immediately
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
        java.lang.IllegalArgumentException - if maxConcurrency is non-positive
        Since:
        2.0
        See Also:
        ReactiveX operators documentation: FlatMap
      • flatMap

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> flatMap​(@NonNull
                                                                 @NonNull Function<? super @NonNull T,​? extends ObservableSource<? extends @NonNull R>> mapper,
                                                                 boolean delayErrors,
                                                                 int maxConcurrency,
                                                                 int bufferSize)
        Returns an Observable that emits items based on applying a function that you supply to each item emitted by the current Observable, where that function returns an ObservableSource, and then merging those returned ObservableSources and emitting the results of this merger, while limiting the maximum number of concurrent subscriptions to these ObservableSources.

        Scheduler:
        flatMap does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the value type of the inner ObservableSources and the output type
        Parameters:
        mapper - a function that, when applied to an item emitted by the current Observable, returns an ObservableSource
        maxConcurrency - the maximum number of ObservableSources that may be subscribed to concurrently
        delayErrors - if true, exceptions from the current Observable and all inner ObservableSources are delayed until all of them terminate if false, the first one signaling an exception will terminate the whole sequence immediately
        bufferSize - the number of elements expected from each inner ObservableSource to be buffered
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
        java.lang.IllegalArgumentException - if maxConcurrency or bufferSize is non-positive
        Since:
        2.0
        See Also:
        ReactiveX operators documentation: FlatMap
      • flatMap

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> flatMap​(@NonNull
                                                                 @NonNull Function<? super @NonNull T,​? extends ObservableSource<? extends @NonNull R>> onNextMapper,
                                                                 @NonNull
                                                                 @NonNull Function<java.lang.Throwable,​? extends ObservableSource<? extends @NonNull R>> onErrorMapper,
                                                                 @NonNull
                                                                 @NonNull Supplier<? extends ObservableSource<? extends @NonNull R>> onCompleteSupplier,
                                                                 int maxConcurrency)
        Returns an Observable that applies a function to each item emitted or notification raised by the current Observable and then flattens the ObservableSources returned from these functions and emits the resulting items, while limiting the maximum number of concurrent subscriptions to these ObservableSources.

        Scheduler:
        flatMap does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the result type
        Parameters:
        onNextMapper - a function that returns an ObservableSource to merge for each item emitted by the current Observable
        onErrorMapper - a function that returns an ObservableSource to merge for an onError notification from the current Observable
        onCompleteSupplier - a function that returns an ObservableSource to merge for an onComplete notification from the current Observable
        maxConcurrency - the maximum number of ObservableSources that may be subscribed to concurrently
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if onNextMapper or onErrorMapper or onCompleteSupplier is null
        java.lang.IllegalArgumentException - if maxConcurrency is non-positive
        Since:
        2.0
        See Also:
        ReactiveX operators documentation: FlatMap
      • flatMap

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> flatMap​(@NonNull
                                                                 @NonNull Function<? super @NonNull T,​? extends ObservableSource<? extends @NonNull R>> mapper,
                                                                 int maxConcurrency)
        Returns an Observable that emits items based on applying a function that you supply to each item emitted by the current Observable, where that function returns an ObservableSource, and then merging those returned ObservableSources and emitting the results of this merger, while limiting the maximum number of concurrent subscriptions to these ObservableSources.

        Scheduler:
        flatMap does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the value type of the inner ObservableSources and the output type
        Parameters:
        mapper - a function that, when applied to an item emitted by the current Observable, returns an ObservableSource
        maxConcurrency - the maximum number of ObservableSources that may be subscribed to concurrently
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
        java.lang.IllegalArgumentException - if maxConcurrency is non-positive
        Since:
        2.0
        See Also:
        ReactiveX operators documentation: FlatMap
      • flatMap

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull U,​@NonNull R> @NonNull Observable<R> flatMap​(@NonNull
                                                                                  @NonNull Function<? super @NonNull T,​? extends ObservableSource<? extends @NonNull U>> mapper,
                                                                                  @NonNull
                                                                                  @NonNull BiFunction<? super @NonNull T,​? super @NonNull U,​? extends @NonNull R> combiner,
                                                                                  boolean delayErrors)
        Returns an Observable that emits the results of a specified function to the pair of values emitted by the current Observable and the mapped inner ObservableSource.

        Scheduler:
        flatMap does not operate by default on a particular Scheduler.
        Type Parameters:
        U - the type of items emitted by the collection ObservableSource
        R - the type of items emitted by the resulting Observable
        Parameters:
        mapper - a function that returns an ObservableSource for each item emitted by the current Observable
        combiner - a function that combines one item emitted by each of the source and collection ObservableSources and returns an item to be emitted by the resulting Observable
        delayErrors - if true, exceptions from the current Observable and all inner ObservableSources are delayed until all of them terminate if false, the first one signaling an exception will terminate the whole sequence immediately
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if mapper or combiner is null
        See Also:
        ReactiveX operators documentation: FlatMap
      • flatMap

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull U,​@NonNull R> @NonNull Observable<R> flatMap​(@NonNull
                                                                                  @NonNull Function<? super @NonNull T,​? extends ObservableSource<? extends @NonNull U>> mapper,
                                                                                  @NonNull
                                                                                  @NonNull BiFunction<? super @NonNull T,​? super @NonNull U,​? extends @NonNull R> combiner,
                                                                                  boolean delayErrors,
                                                                                  int maxConcurrency)
        Returns an Observable that emits the results of a specified function to the pair of values emitted by the current Observable and the mapped inner ObservableSource, while limiting the maximum number of concurrent subscriptions to these ObservableSources.

        Scheduler:
        flatMap does not operate by default on a particular Scheduler.
        Type Parameters:
        U - the type of items emitted by the collection ObservableSource
        R - the type of items emitted by the resulting Observable
        Parameters:
        mapper - a function that returns an ObservableSource for each item emitted by the current Observable
        combiner - a function that combines one item emitted by each of the source and collection ObservableSources and returns an item to be emitted by the resulting Observable
        maxConcurrency - the maximum number of ObservableSources that may be subscribed to concurrently
        delayErrors - if true, exceptions from the current Observable and all inner ObservableSources are delayed until all of them terminate if false, the first one signaling an exception will terminate the whole sequence immediately
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if mapper or combiner is null
        java.lang.IllegalArgumentException - if maxConcurrency is non-positive
        Since:
        2.0
        See Also:
        ReactiveX operators documentation: FlatMap
      • flatMap

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull U,​@NonNull R> @NonNull Observable<R> flatMap​(@NonNull
                                                                                  @NonNull Function<? super @NonNull T,​? extends ObservableSource<? extends @NonNull U>> mapper,
                                                                                  @NonNull
                                                                                  @NonNull BiFunction<? super @NonNull T,​? super @NonNull U,​? extends @NonNull R> combiner,
                                                                                  boolean delayErrors,
                                                                                  int maxConcurrency,
                                                                                  int bufferSize)
        Returns an Observable that emits the results of a specified function to the pair of values emitted by the current Observable and the mapped inner ObservableSource, while limiting the maximum number of concurrent subscriptions to these ObservableSources.

        Scheduler:
        flatMap does not operate by default on a particular Scheduler.
        Type Parameters:
        U - the type of items emitted by the collection ObservableSource
        R - the type of items emitted by the resulting Observable
        Parameters:
        mapper - a function that returns an ObservableSource for each item emitted by the current Observable
        combiner - a function that combines one item emitted by each of the source and collection ObservableSources and returns an item to be emitted by the resulting Observable
        maxConcurrency - the maximum number of ObservableSources that may be subscribed to concurrently
        delayErrors - if true, exceptions from the current Observable and all inner ObservableSources are delayed until all of them terminate if false, the first one signaling an exception will terminate the whole sequence immediately
        bufferSize - the number of elements expected from the inner ObservableSource to be buffered
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if mapper or combiner is null
        java.lang.IllegalArgumentException - if maxConcurrency or bufferSize is non-positive
        Since:
        2.0
        See Also:
        ReactiveX operators documentation: FlatMap
      • flatMap

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull U,​@NonNull R> @NonNull Observable<R> flatMap​(@NonNull
                                                                                  @NonNull Function<? super @NonNull T,​? extends ObservableSource<? extends @NonNull U>> mapper,
                                                                                  @NonNull
                                                                                  @NonNull BiFunction<? super @NonNull T,​? super @NonNull U,​? extends @NonNull R> combiner,
                                                                                  int maxConcurrency)
        Returns an Observable that emits the results of a specified function to the pair of values emitted by the current Observable and the mapped inner ObservableSource, while limiting the maximum number of concurrent subscriptions to these ObservableSources.

        Scheduler:
        flatMap does not operate by default on a particular Scheduler.
        Type Parameters:
        U - the type of items emitted by the collection ObservableSource
        R - the type of items emitted by the resulting Observable
        Parameters:
        mapper - a function that returns an ObservableSource for each item emitted by the current Observable
        combiner - a function that combines one item emitted by each of the source and collection ObservableSources and returns an item to be emitted by the resulting Observable
        maxConcurrency - the maximum number of ObservableSources that may be subscribed to concurrently
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if mapper or combiner is null
        java.lang.IllegalArgumentException - if maxConcurrency is non-positive
        Since:
        2.0
        See Also:
        ReactiveX operators documentation: FlatMap
      • flatMapCompletable

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Completable flatMapCompletable​(@NonNull
                                                             @NonNull Function<? super @NonNull T,​? extends CompletableSource> mapper,
                                                             boolean delayErrors)
        Maps each element of the current Observable into CompletableSources, subscribes to them and waits until the upstream and all CompletableSources complete, optionally delaying all errors.

        Scheduler:
        flatMapCompletable does not operate by default on a particular Scheduler.
        Parameters:
        mapper - the function that received each source value and transforms them into CompletableSources.
        delayErrors - if true, errors from the upstream and inner CompletableSources are delayed until all of them terminate.
        Returns:
        the new Completable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
      • flatMapIterable

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull U,​@NonNull V> @NonNull Observable<V> flatMapIterable​(@NonNull
                                                                                          @NonNull Function<? super @NonNull T,​? extends java.lang.Iterable<? extends @NonNull U>> mapper,
                                                                                          @NonNull
                                                                                          @NonNull BiFunction<? super @NonNull T,​? super @NonNull U,​? extends @NonNull V> combiner)
        Merges Iterables generated by a mapper Function for each individual item emitted by the current Observable into a single Observable sequence where the resulting items will be the combination of the original item and each inner item of the respective Iterable as returned by the resultSelector BiFunction.

        Scheduler:
        flatMapIterable does not operate by default on a particular Scheduler.
        Type Parameters:
        U - the element type of the Iterables
        V - the output type as determined by the resultSelector function
        Parameters:
        mapper - a function that returns an Iterable sequence of values for each item emitted by the current Observable
        combiner - a function that returns an item based on the item emitted by the current Observable and the next item of the Iterable returned for that original item by the mapper
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if mapper or combiner is null
        See Also:
        ReactiveX operators documentation: FlatMap
      • flatMapMaybe

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> flatMapMaybe​(@NonNull
                                                                      @NonNull Function<? super @NonNull T,​? extends MaybeSource<? extends @NonNull R>> mapper)
        Maps each element of the current Observable into MaybeSources, subscribes to all of them and merges their onSuccess values, in no particular order, into a single Observable sequence.

        Scheduler:
        flatMapMaybe does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the result value type
        Parameters:
        mapper - the function that received each source value and transforms them into MaybeSources.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
      • flatMapMaybe

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> flatMapMaybe​(@NonNull
                                                                      @NonNull Function<? super @NonNull T,​? extends MaybeSource<? extends @NonNull R>> mapper,
                                                                      boolean delayErrors)
        Maps each element of the current Observable into MaybeSources, subscribes to them and merges their onSuccess values, in no particular order, into a single Observable sequence, optionally delaying all errors.

        Scheduler:
        flatMapMaybe does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the result value type
        Parameters:
        mapper - the function that received each source value and transforms them into MaybeSources.
        delayErrors - if true, errors from the upstream and inner MaybeSources are delayed until all of them terminate.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
      • flatMapSingle

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> flatMapSingle​(@NonNull
                                                                       @NonNull Function<? super @NonNull T,​? extends SingleSource<? extends @NonNull R>> mapper)
        Maps each element of the current Observable into SingleSources, subscribes to all of them and merges their onSuccess values, in no particular order, into a single Observable sequence.

        Scheduler:
        flatMapSingle does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the result value type
        Parameters:
        mapper - the function that received each source value and transforms them into SingleSources.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
      • flatMapSingle

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> flatMapSingle​(@NonNull
                                                                       @NonNull Function<? super @NonNull T,​? extends SingleSource<? extends @NonNull R>> mapper,
                                                                       boolean delayErrors)
        Maps each element of the current Observable into SingleSources, subscribes to them and merges their onSuccess values, in no particular order, into a single Observable sequence, optionally delaying all errors.

        Scheduler:
        flatMapSingle does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the result value type
        Parameters:
        mapper - the function that received each source value and transforms them into SingleSources.
        delayErrors - if true, errors from the upstream and inner SingleSources are delayed until each of them terminates.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
      • groupBy

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull K> @NonNull Observable<GroupedObservable<K,​T>> groupBy​(@NonNull
                                                                                            @NonNull Function<? super @NonNull T,​? extends @NonNull K> keySelector)
        Groups the items emitted by the current Observable according to a specified criterion, and emits these grouped items as GroupedObservables.

        Each emitted GroupedObservable allows only a single Observer to subscribe to it during its lifetime and if this Observer calls dispose() before the source terminates, the next emission by the source having the same key will trigger a new GroupedObservable emission.

        Note: A GroupedObservable will cache the items it is to emit until such time as it is subscribed to. For this reason, in order to avoid memory leaks, you should not simply ignore those GroupedObservables that do not concern you. Instead, you can signal to them that they may discard their buffers by applying an operator like ignoreElements() to them.

        Note also that ignoring groups or subscribing later (i.e., on another thread) will result in so-called group abandonment where a group will only contain one element and the group will be re-created over and over as new upstream items trigger a new group. The behavior is a trade-off between no-dataloss, upstream cancellation and excessive group creation.

        Scheduler:
        groupBy does not operate by default on a particular Scheduler.
        Type Parameters:
        K - the key type
        Parameters:
        keySelector - a function that extracts the key for each item
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if keySelector is null
        See Also:
        ReactiveX operators documentation: GroupBy
      • groupBy

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull K> @NonNull Observable<GroupedObservable<K,​T>> groupBy​(@NonNull
                                                                                            @NonNull Function<? super @NonNull T,​? extends @NonNull K> keySelector,
                                                                                            boolean delayError)
        Groups the items emitted by the current Observable according to a specified criterion, and emits these grouped items as GroupedObservables.

        Each emitted GroupedObservable allows only a single Observer to subscribe to it during its lifetime and if this Observer calls dispose() before the source terminates, the next emission by the source having the same key will trigger a new GroupedObservable emission.

        Note: A GroupedObservable will cache the items it is to emit until such time as it is subscribed to. For this reason, in order to avoid memory leaks, you should not simply ignore those GroupedObservables that do not concern you. Instead, you can signal to them that they may discard their buffers by applying an operator like ignoreElements() to them.

        Note also that ignoring groups or subscribing later (i.e., on another thread) will result in so-called group abandonment where a group will only contain one element and the group will be re-created over and over as new upstream items trigger a new group. The behavior is a trade-off between no-dataloss, upstream cancellation and excessive group creation.

        Scheduler:
        groupBy does not operate by default on a particular Scheduler.
        Type Parameters:
        K - the key type
        Parameters:
        keySelector - a function that extracts the key for each item
        delayError - if true, the exception from the current Observable is delayed in each group until that specific group emitted the normal values; if false, the exception bypasses values in the groups and is reported immediately.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if keySelector is null
        See Also:
        ReactiveX operators documentation: GroupBy
      • groupBy

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull K,​@NonNull V> @NonNull Observable<GroupedObservable<K,​V>> groupBy​(@NonNull
                                                                                                             @NonNull Function<? super @NonNull T,​? extends @NonNull K> keySelector,
                                                                                                             Function<? super @NonNull T,​? extends @NonNull V> valueSelector)
        Groups the items emitted by the current Observable according to a specified criterion, and emits these grouped items as GroupedObservables.

        Each emitted GroupedObservable allows only a single Observer to subscribe to it during its lifetime and if this Observer calls dispose() before the source terminates, the next emission by the source having the same key will trigger a new GroupedObservable emission.

        Note: A GroupedObservable will cache the items it is to emit until such time as it is subscribed to. For this reason, in order to avoid memory leaks, you should not simply ignore those GroupedObservables that do not concern you. Instead, you can signal to them that they may discard their buffers by applying an operator like ignoreElements() to them.

        Note also that ignoring groups or subscribing later (i.e., on another thread) will result in so-called group abandonment where a group will only contain one element and the group will be re-created over and over as new upstream items trigger a new group. The behavior is a trade-off between no-dataloss, upstream cancellation and excessive group creation.

        Scheduler:
        groupBy does not operate by default on a particular Scheduler.
        Type Parameters:
        K - the key type
        V - the element type
        Parameters:
        keySelector - a function that extracts the key for each item
        valueSelector - a function that extracts the return element for each item
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if keySelector or valueSelector is null
        See Also:
        ReactiveX operators documentation: GroupBy
      • groupBy

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull K,​@NonNull V> @NonNull Observable<GroupedObservable<K,​V>> groupBy​(@NonNull
                                                                                                             @NonNull Function<? super @NonNull T,​? extends @NonNull K> keySelector,
                                                                                                             @NonNull
                                                                                                             @NonNull Function<? super @NonNull T,​? extends @NonNull V> valueSelector,
                                                                                                             boolean delayError)
        Groups the items emitted by the current Observable according to a specified criterion, and emits these grouped items as GroupedObservables.

        Each emitted GroupedObservable allows only a single Observer to subscribe to it during its lifetime and if this Observer calls dispose() before the source terminates, the next emission by the source having the same key will trigger a new GroupedObservable emission.

        Note: A GroupedObservable will cache the items it is to emit until such time as it is subscribed to. For this reason, in order to avoid memory leaks, you should not simply ignore those GroupedObservables that do not concern you. Instead, you can signal to them that they may discard their buffers by applying an operator like ignoreElements() to them.

        Note also that ignoring groups or subscribing later (i.e., on another thread) will result in so-called group abandonment where a group will only contain one element and the group will be re-created over and over as new upstream items trigger a new group. The behavior is a trade-off between no-dataloss, upstream cancellation and excessive group creation.

        Scheduler:
        groupBy does not operate by default on a particular Scheduler.
        Type Parameters:
        K - the key type
        V - the element type
        Parameters:
        keySelector - a function that extracts the key for each item
        valueSelector - a function that extracts the return element for each item
        delayError - if true, the exception from the current Observable is delayed in each group until that specific group emitted the normal values; if false, the exception bypasses values in the groups and is reported immediately.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if keySelector or valueSelector is null
        See Also:
        ReactiveX operators documentation: GroupBy
      • groupBy

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull K,​@NonNull V> @NonNull Observable<GroupedObservable<K,​V>> groupBy​(@NonNull
                                                                                                             @NonNull Function<? super @NonNull T,​? extends @NonNull K> keySelector,
                                                                                                             @NonNull
                                                                                                             @NonNull Function<? super @NonNull T,​? extends @NonNull V> valueSelector,
                                                                                                             boolean delayError,
                                                                                                             int bufferSize)
        Groups the items emitted by the current Observable according to a specified criterion, and emits these grouped items as GroupedObservables.

        Each emitted GroupedObservable allows only a single Observer to subscribe to it during its lifetime and if this Observer calls dispose() before the source terminates, the next emission by the source having the same key will trigger a new GroupedObservable emission.

        Note: A GroupedObservable will cache the items it is to emit until such time as it is subscribed to. For this reason, in order to avoid memory leaks, you should not simply ignore those GroupedObservables that do not concern you. Instead, you can signal to them that they may discard their buffers by applying an operator like ignoreElements() to them.

        Note also that ignoring groups or subscribing later (i.e., on another thread) will result in so-called group abandonment where a group will only contain one element and the group will be re-created over and over as new upstream items trigger a new group. The behavior is a trade-off between no-dataloss, upstream cancellation and excessive group creation.

        Scheduler:
        groupBy does not operate by default on a particular Scheduler.
        Type Parameters:
        K - the key type
        V - the element type
        Parameters:
        keySelector - a function that extracts the key for each item
        valueSelector - a function that extracts the return element for each item
        delayError - if true, the exception from the current Observable is delayed in each group until that specific group emitted the normal values; if false, the exception bypasses values in the groups and is reported immediately.
        bufferSize - the hint for how many GroupedObservables and element in each GroupedObservable should be buffered
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if keySelector or valueSelector is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        See Also:
        ReactiveX operators documentation: GroupBy
      • groupJoin

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull TRight,​@NonNull TLeftEnd,​@NonNull TRightEnd,​@NonNull R> @NonNull Observable<R> groupJoin​(@NonNull
                                                                                                                                          @NonNull ObservableSource<? extends @NonNull TRight> other,
                                                                                                                                          @NonNull
                                                                                                                                          @NonNull Function<? super @NonNull T,​? extends ObservableSource<@NonNull TLeftEnd>> leftEnd,
                                                                                                                                          @NonNull
                                                                                                                                          @NonNull Function<? super @NonNull TRight,​? extends ObservableSource<@NonNull TRightEnd>> rightEnd,
                                                                                                                                          @NonNull
                                                                                                                                          @NonNull BiFunction<? super @NonNull T,​? super Observable<@NonNull TRight>,​? extends @NonNull R> resultSelector)
        Returns an Observable that correlates two ObservableSources when they overlap in time and groups the results.

        There are no guarantees in what order the items get combined when multiple items from one or both source ObservableSources overlap.

        Scheduler:
        groupJoin does not operate by default on a particular Scheduler.
        Type Parameters:
        TRight - the value type of the right ObservableSource source
        TLeftEnd - the element type of the left duration ObservableSources
        TRightEnd - the element type of the right duration ObservableSources
        R - the result type
        Parameters:
        other - the other ObservableSource to correlate items from the current Observable with
        leftEnd - a function that returns an ObservableSource whose emissions indicate the duration of the values of the current Observable
        rightEnd - a function that returns an ObservableSource whose emissions indicate the duration of the values of the right ObservableSource
        resultSelector - a function that takes an item emitted by each ObservableSource and returns the value to be emitted by the resulting Observable
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if other, leftEnd, rightEnd or resultSelector is null
        See Also:
        ReactiveX operators documentation: Join
      • lift

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> lift​(@NonNull
                                                              @NonNull ObservableOperator<? extends @NonNull R,​? super @NonNull T> lifter)
        This method requires advanced knowledge about building operators, please consider other standard composition methods first; Returns an Observable which, when subscribed to, invokes the apply(Observer) method of the provided ObservableOperator for each individual downstream Observer and allows the insertion of a custom operator by accessing the downstream's Observer during this subscription phase and providing a new Observer, containing the custom operator's intended business logic, that will be used in the subscription process going further upstream.

        Generally, such a new Observer will wrap the downstream's Observer and forwards the onNext, onError and onComplete events from the upstream directly or according to the emission pattern the custom operator's business logic requires. In addition, such operator can intercept the flow control calls of dispose and isDisposed that would have traveled upstream and perform additional actions depending on the same business logic requirements.

        Example:

        
         // Step 1: Create the consumer type that will be returned by the ObservableOperator.apply():
        
         public final class CustomObserver<T> implements Observer<T>, Disposable {
        
             // The downstream's Observer that will receive the onXXX events
             final Observer<? super String> downstream;
        
             // The connection to the upstream source that will call this class' onXXX methods
             Disposable upstream;
        
             // The constructor takes the downstream subscriber and usually any other parameters
             public CustomObserver(Observer<? super String> downstream) {
                 this.downstream = downstream;
             }
        
             // In the subscription phase, the upstream sends a Disposable to this class
             // and subsequently this class has to send a Disposable to the downstream.
             // Note that relaying the upstream's Disposable directly is not allowed in RxJava
             @Override
             public void onSubscribe(Disposable d) {
                 if (upstream != null) {
                     d.dispose();
                 } else {
                     upstream = d;
                     downstream.onSubscribe(this);
                 }
             }
        
             // The upstream calls this with the next item and the implementation's
             // responsibility is to emit an item to the downstream based on the intended
             // business logic, or if it can't do so for the particular item,
             // request more from the upstream
             @Override
             public void onNext(T item) {
                 String str = item.toString();
                 if (str.length() < 2) {
                     downstream.onNext(str);
                 }
                 // Observable doesn't support backpressure, therefore, there is no
                 // need or opportunity to call upstream.request(1) if an item
                 // is not produced to the downstream
             }
        
             // Some operators may handle the upstream's error while others
             // could just forward it to the downstream.
             @Override
             public void onError(Throwable throwable) {
                 downstream.onError(throwable);
             }
        
             // When the upstream completes, usually the downstream should complete as well.
             @Override
             public void onComplete() {
                 downstream.onComplete();
             }
        
             // Some operators may use their own resources which should be cleaned up if
             // the downstream disposes the flow before it completed. Operators without
             // resources can simply forward the dispose to the upstream.
             // In some cases, a disposed flag may be set by this method so that other parts
             // of this class may detect the dispose and stop sending events
             // to the downstream.
             @Override
             public void dispose() {
                 upstream.dispose();
             }
        
             // Some operators may simply forward the call to the upstream while others
             // can return the disposed flag set in dispose().
             @Override
             public boolean isDisposed() {
                 return upstream.isDisposed();
             }
         }
        
         // Step 2: Create a class that implements the ObservableOperator interface and
         //         returns the custom consumer type from above in its apply() method.
         //         Such class may define additional parameters to be submitted to
         //         the custom consumer type.
        
         final class CustomOperator<T> implements ObservableOperator<String, T> {
             @Override
             public Observer<T> apply(Observer<? super String> downstream) {
                 return new CustomObserver<T>(downstream);
             }
         }
        
         // Step 3: Apply the custom operator via lift() in a flow by creating an instance of it
         //         or reusing an existing one.
        
         Observable.range(5, 10)
         .lift(new CustomOperator<Integer>())
         .test()
         .assertResult("5", "6", "7", "8", "9");
         

        Creating custom operators can be complicated and it is recommended one consults the RxJava wiki: Writing operators page about the tools, requirements, rules, considerations and pitfalls of implementing them.

        Note that implementing custom operators via this lift() method adds slightly more overhead by requiring an additional allocation and indirection per assembled flows. Instead, extending the abstract Observable class and creating an ObservableTransformer with it is recommended.

        Note also that it is not possible to stop the subscription phase in lift() as the apply() method requires a non-null Observer instance to be returned, which is then unconditionally subscribed to the current Observable. For example, if the operator decided there is no reason to subscribe to the upstream source because of some optimization possibility or a failure to prepare the operator, it still has to return an Observer that should immediately dispose the upstream's Disposable in its onSubscribe method. Again, using an ObservableTransformer and extending the Observable is a better option as subscribeActual(io.reactivex.rxjava3.core.Observer<? super T>) can decide to not subscribe to its upstream after all.

        Scheduler:
        lift does not operate by default on a particular Scheduler, however, the ObservableOperator may use a Scheduler to support its own asynchronous behavior.
        Type Parameters:
        R - the output value type
        Parameters:
        lifter - the ObservableOperator that receives the downstream's Observer and should return an Observer with custom behavior to be used as the consumer for the current Observable.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if lifter is null
        See Also:
        RxJava wiki: Writing operators, compose(ObservableTransformer)
      • mergeWith

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> mergeWith​(@NonNull
                                                      @NonNull SingleSource<? extends @NonNull T> other)
        Merges the sequence of items of the current Observable with the success value of the other SingleSource.

        The success value of the other SingleSource can get interleaved at any point of the current Observable sequence.

        Scheduler:
        mergeWith does not operate by default on a particular Scheduler.

        History: 2.1.10 - experimental

        Parameters:
        other - the SingleSource whose success value to merge with
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if other is null
        Since:
        2.2
      • mergeWith

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> mergeWith​(@NonNull
                                                      @NonNull MaybeSource<? extends @NonNull T> other)
        Merges the sequence of items of the current Observable with the success value of the other MaybeSource or waits both to complete normally if the MaybeSource is empty.

        The success value of the other MaybeSource can get interleaved at any point of the current Observable sequence.

        Scheduler:
        mergeWith does not operate by default on a particular Scheduler.

        History: 2.1.10 - experimental

        Parameters:
        other - the MaybeSource which provides a success value to merge with or completes
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if other is null
        Since:
        2.2
      • observeOn

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<T> observeOn​(@NonNull
                                                      @NonNull Scheduler scheduler,
                                                      boolean delayError)
        Returns an Observable to perform the current Observable's emissions and notifications on a specified Scheduler, asynchronously with an unbounded buffer with Flowable.bufferSize() "island size" and optionally delays onError notifications.

        This operator keeps emitting as many signals as it can on the given Scheduler's worker thread, which may result in a longer than expected occupation of this thread. In other terms, it does not allow per-signal fairness in case the worker runs on a shared underlying thread. If such fairness and signal/work interleaving is preferred, use the delay operator with zero time instead.

        Scheduler:
        You specify which Scheduler this operator will use.

        "Island size" indicates how large chunks the unbounded buffer allocates to store the excess elements waiting to be consumed on the other side of the asynchronous boundary.

        Parameters:
        scheduler - the Scheduler to notify Observers on
        delayError - indicates if the onError notification may not cut ahead of onNext notification on the other side of the scheduling boundary. If true, a sequence ending in onError will be replayed in the same order as was received from the current Observable
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if scheduler is null
        See Also:
        ReactiveX operators documentation: ObserveOn, RxJava Threading Examples, subscribeOn(io.reactivex.rxjava3.core.Scheduler), observeOn(Scheduler), observeOn(Scheduler, boolean, int), delay(long, TimeUnit, Scheduler, boolean)
      • observeOn

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<T> observeOn​(@NonNull
                                                      @NonNull Scheduler scheduler,
                                                      boolean delayError,
                                                      int bufferSize)
        Returns an Observable to perform the current Observable's emissions and notifications on a specified Scheduler, asynchronously with an unbounded buffer of configurable "island size" and optionally delays onError notifications.

        This operator keeps emitting as many signals as it can on the given Scheduler's worker thread, which may result in a longer than expected occupation of this thread. In other terms, it does not allow per-signal fairness in case the worker runs on a shared underlying thread. If such fairness and signal/work interleaving is preferred, use the delay operator with zero time instead.

        Scheduler:
        You specify which Scheduler this operator will use.

        "Island size" indicates how large chunks the unbounded buffer allocates to store the excess elements waiting to be consumed on the other side of the asynchronous boundary. Values below 16 are not recommended in performance sensitive scenarios.

        Parameters:
        scheduler - the Scheduler to notify Observers on
        delayError - indicates if the onError notification may not cut ahead of onNext notification on the other side of the scheduling boundary. If true a sequence ending in onError will be replayed in the same order as was received from upstream
        bufferSize - the size of the buffer.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if scheduler is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        See Also:
        ReactiveX operators documentation: ObserveOn, RxJava Threading Examples, subscribeOn(io.reactivex.rxjava3.core.Scheduler), observeOn(Scheduler), observeOn(Scheduler, boolean), delay(long, TimeUnit, Scheduler, boolean)
      • onErrorComplete

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> onErrorComplete()
        Returns an Observable instance that if the current Observable emits an error, it will emit an onComplete and swallow the throwable.

        Scheduler:
        onErrorComplete does not operate by default on a particular Scheduler.
        Returns:
        the new Observable instance
        Since:
        3.0.0
      • onErrorComplete

        @CheckReturnValue
        @NonNull
        @SchedulerSupport("none")
        public final @NonNull Observable<T> onErrorComplete​(@NonNull
                                                            @NonNull Predicate<? super java.lang.Throwable> predicate)
        Returns an Observable instance that if the current Observable emits an error and the predicate returns true, it will emit an onComplete and swallow the throwable.

        Scheduler:
        onErrorComplete does not operate by default on a particular Scheduler.
        Parameters:
        predicate - the predicate to call when an Throwable is emitted which should return true if the Throwable should be swallowed and replaced with an onComplete.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if predicate is null
        Since:
        3.0.0
      • onErrorResumeNext

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> onErrorResumeNext​(@NonNull
                                                              @NonNull Function<? super java.lang.Throwable,​? extends ObservableSource<? extends @NonNull T>> fallbackSupplier)
        Resumes the flow with an ObservableSource returned for the failure Throwable of the current Observable by a function instead of signaling the error via onError.

        By default, when an ObservableSource encounters an error that prevents it from emitting the expected item to its Observer, the ObservableSource invokes its Observer's onError method, and then quits without invoking any more of its Observer's methods. The onErrorResumeNext method changes this behavior. If you pass a function that returns an ObservableSource (resumeFunction) to onErrorResumeNext, if the original ObservableSource encounters an error, instead of invoking its Observer's onError method, it will instead relinquish control to the ObservableSource returned from resumeFunction, which will invoke the Observer's onNext method if it is able to do so. In such a case, because no ObservableSource necessarily invokes onError, the Observer 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:
        fallbackSupplier - a function that returns an ObservableSource that will take over if the current Observable encounters an error
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if fallbackSupplier is null
        See Also:
        ReactiveX operators documentation: Catch
      • onErrorResumeWith

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> onErrorResumeWith​(@NonNull
                                                              @NonNull ObservableSource<? extends @NonNull T> fallback)
        Resumes the flow with the given ObservableSource when the current Observable fails instead of signaling the error via onError.

        By default, when an ObservableSource encounters an error that prevents it from emitting the expected item to its Observer, the ObservableSource invokes its Observer's onError method, and then quits without invoking any more of its Observer's methods. The onErrorResumeWith method changes this behavior. If you pass another ObservableSource (next) to an ObservableSource's onErrorResumeWith method, if the original ObservableSource encounters an error, instead of invoking its Observer's onError method, it will instead relinquish control to next which will invoke the Observer's onNext method if it is able to do so. In such a case, because no ObservableSource necessarily invokes onError, the Observer 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:
        onErrorResumeWith does not operate by default on a particular Scheduler.
        Parameters:
        fallback - the next ObservableSource source that will take over if the current Observable encounters an error
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if fallback is null
        See Also:
        ReactiveX operators documentation: Catch
      • onErrorReturn

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> onErrorReturn​(@NonNull
                                                          @NonNull Function<? super java.lang.Throwable,​? extends @NonNull T> itemSupplier)
        Ends the flow with a last item returned by a function for the Throwable error signaled by the current Observable instead of signaling the error via onError.

        By default, when an ObservableSource encounters an error that prevents it from emitting the expected item to its Observer, the ObservableSource invokes its Observer's onError method, and then quits without invoking any more of its Observer's methods. The onErrorReturn method changes this behavior. If you pass a function (resumeFunction) to an ObservableSource's onErrorReturn method, if the original ObservableSource encounters an error, instead of invoking its Observer's onError 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:
        itemSupplier - a function that returns a single value that will be emitted along with a regular onComplete in case the current Observable signals an onError event
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if itemSupplier is null
        See Also:
        ReactiveX operators documentation: Catch
      • onErrorReturnItem

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> onErrorReturnItem​(@NonNull
                                                              @NonNull T item)
        Ends the flow with the given last item when the current Observable fails instead of signaling the error via onError.

        By default, when an ObservableSource encounters an error that prevents it from emitting the expected item to its Observer, the ObservableSource invokes its Observer's onError method, and then quits without invoking any more of its Observer's methods. The onErrorReturn method changes this behavior. If you pass a function (resumeFunction) to an ObservableSource's onErrorReturn method, if the original ObservableSource encounters an error, instead of invoking its Observer's onError 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:
        onErrorReturnItem does not operate by default on a particular Scheduler.
        Parameters:
        item - the value that is emitted along with a regular onComplete in case the current Observable signals an exception
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if item is null
        See Also:
        ReactiveX operators documentation: Catch
      • onTerminateDetach

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> onTerminateDetach()
        Nulls out references to the upstream producer and downstream Observer if the sequence is terminated or downstream calls dispose().

        Scheduler:
        onTerminateDetach does not operate by default on a particular Scheduler.
        Returns:
        the new Observable instance the sequence is terminated or downstream calls dispose()
        Since:
        2.0
      • reduce

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Maybe<T> reduce​(@NonNull
                                              @NonNull BiFunction<@NonNull T,​@NonNull T,​@NonNull T> reducer)
        Returns a Maybe that applies a specified accumulator function to the first item emitted by the current Observable, then feeds the result of that function along with the second item emitted by the current Observable into the same function, and so on until all items have been emitted by the current and finite Observable, and emits the final result from the final call to your function as its sole item.

        This technique, which is called "reduce" here, is sometimes called "aggregate," "fold," "accumulate," "compress," or "inject" in other programming contexts. Groovy, for instance, has an inject method that does a similar operation on lists.

        Note that this operator requires the upstream to signal onComplete for the accumulator object to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatal OutOfMemoryError.

        Scheduler:
        reduce does not operate by default on a particular Scheduler.
        Parameters:
        reducer - an accumulator function to be invoked on each item emitted by the current Observable, whose result will be used in the next accumulator call
        Returns:
        the new Maybe instance
        Throws:
        java.lang.NullPointerException - if reducer is null
        See Also:
        ReactiveX operators documentation: Reduce, Wikipedia: Fold (higher-order function)
      • reduce

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Single<R> reduce​(@NonNull R seed,
                                                            @NonNull
                                                            @NonNull BiFunction<@NonNull R,​? super @NonNull T,​@NonNull R> reducer)
        Returns a Single that applies a specified accumulator function to the first item emitted by the current Observable and a specified seed value, then feeds the result of that function along with the second item emitted by the current Observable into the same function, and so on until all items have been emitted by the current and finite Observable, emitting the final result from the final call to your function as its sole item.

        This technique, which is called "reduce" here, is sometimes called "aggregate," "fold," "accumulate," "compress," or "inject" in other programming contexts. Groovy, for instance, has an inject method that does a similar operation on lists.

        Note that the seed is shared among all subscribers to the resulting Observable and may cause problems if it is mutable. To make sure each subscriber gets its own value, defer the application of this operator via defer(Supplier):

        
         ObservableSource<T> source = ...
         Single.defer(() -> source.reduce(new ArrayList<>(), (list, item) -> list.add(item)));
        
         // alternatively, by using compose to stay fluent
        
         source.compose(o ->
             Observable.defer(() -> o.reduce(new ArrayList<>(), (list, item) -> list.add(item)).toObservable())
         ).firstOrError();
        
         // or, by using reduceWith instead of reduce
        
         source.reduceWith(() -> new ArrayList<>(), (list, item) -> list.add(item)));
         

        Note that this operator requires the upstream to signal onComplete for the accumulator object to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatal OutOfMemoryError.

        Scheduler:
        reduce does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the accumulator and output value type
        Parameters:
        seed - the initial (seed) accumulator value
        reducer - an accumulator function to be invoked on each item emitted by the current Observable, the result of which will be used in the next accumulator call
        Returns:
        the new Single instance
        Throws:
        java.lang.NullPointerException - if seed or reducer is null
        See Also:
        ReactiveX operators documentation: Reduce, Wikipedia: Fold (higher-order function), reduceWith(Supplier, BiFunction)
      • reduceWith

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Single<R> reduceWith​(@NonNull
                                                                @NonNull Supplier<@NonNull R> seedSupplier,
                                                                @NonNull
                                                                @NonNull BiFunction<@NonNull R,​? super @NonNull T,​@NonNull R> reducer)
        Returns a Single that applies a specified accumulator function to the first item emitted by the current Observable and a seed value derived from calling a specified seedSupplier, then feeds the result of that function along with the second item emitted by the current Observable into the same function, and so on until all items have been emitted by the current and finite Observable, emitting the final result from the final call to your function as its sole item.

        This technique, which is called "reduce" here, is sometimes called "aggregate," "fold," "accumulate," "compress," or "inject" in other programming contexts. Groovy, for instance, has an inject method that does a similar operation on lists.

        Note that this operator requires the upstream to signal onComplete for the accumulator object to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatal OutOfMemoryError.

        Scheduler:
        reduceWith does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the accumulator and output value type
        Parameters:
        seedSupplier - the Supplier that provides the initial (seed) accumulator value for each individual Observer
        reducer - an accumulator function to be invoked on each item emitted by the current Observable, the result of which will be used in the next accumulator call
        Returns:
        the new Single instance
        Throws:
        java.lang.NullPointerException - if seedSupplier or reducer is null
        See Also:
        ReactiveX operators documentation: Reduce, Wikipedia: Fold (higher-order function)
      • repeat

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> repeat​(long times)
        Returns an Observable that repeats the sequence of items emitted by the current Observable at most count times.

        Scheduler:
        repeat does not operate by default on a particular Scheduler.
        Parameters:
        times - the number of times the current Observable items are repeated, a count of 0 will yield an empty sequence
        Returns:
        the new Observable instance
        Throws:
        java.lang.IllegalArgumentException - if times is negative
        See Also:
        ReactiveX operators documentation: Repeat
      • repeatUntil

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> repeatUntil​(@NonNull
                                                        @NonNull BooleanSupplier stop)
        Returns an Observable that repeats the sequence of items emitted by the current Observable until the provided stop function returns true.

        Scheduler:
        repeatUntil does not operate by default on a particular Scheduler.
        Parameters:
        stop - a boolean supplier that is called when the current Observable completes; if it returns true, the returned Observable completes; if it returns false, the current Observable is resubscribed.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if stop is null
        See Also:
        ReactiveX operators documentation: Repeat
      • repeatWhen

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> repeatWhen​(@NonNull
                                                       @NonNull Function<? super Observable<java.lang.Object>,​? extends ObservableSource<?>> handler)
        Returns an Observable that emits the same values as the current Observable with the exception of an onComplete. An onComplete notification from the source will result in the emission of a void item to the ObservableSource provided as an argument to the notificationHandler function. If that ObservableSource calls onComplete or onError then repeatWhen will call onComplete or onError on the child subscription. Otherwise, the current Observable will be resubscribed.

        Scheduler:
        repeatWhen does not operate by default on a particular Scheduler.
        Parameters:
        handler - receives an ObservableSource of notifications with which a user can complete or error, aborting the repeat.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if handler is null
        See Also:
        ReactiveX operators documentation: Repeat
      • replay

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> replay​(@NonNull
                                                                @NonNull Function<? super Observable<@NonNull T>,​? extends ObservableSource<@NonNull R>> selector,
                                                                int bufferSize)
        Returns an Observable that emits items that are the results of invoking a specified selector on items emitted by a ConnectableObservable that shares a single subscription to the current Observable, replaying bufferSize notifications.

        Note that due to concurrency requirements, replay(bufferSize) may hold strong references to more than bufferSize source emissions.

        Scheduler:
        This version of replay does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the type of items emitted by the resulting Observable
        Parameters:
        selector - the selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the current Observable
        bufferSize - the buffer size that limits the number of items the connectable Observable can replay
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if selector is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        See Also:
        ReactiveX operators documentation: Replay, replay(Function, int, boolean)
      • replay

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> replay​(@NonNull
                                                                @NonNull Function<? super Observable<@NonNull T>,​? extends ObservableSource<@NonNull R>> selector,
                                                                int bufferSize,
                                                                boolean eagerTruncate)
        Returns an Observable that emits items that are the results of invoking a specified selector on items emitted by a ConnectableObservable that shares a single subscription to the current Observable, replaying bufferSize notifications.

        Note that due to concurrency requirements, replay(bufferSize) may hold strong references to more than bufferSize source emissions.

        Scheduler:
        This version of replay does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the type of items emitted by the resulting Observable
        Parameters:
        selector - the selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the current Observable
        bufferSize - the buffer size that limits the number of items the connectable Observable can replay
        eagerTruncate - if true, whenever the internal buffer is truncated to the given bufferSize, the oldest item will be guaranteed dereferenced, thus avoiding unexpected retention
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if selector is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        See Also:
        ReactiveX operators documentation: Replay
      • replay

        @CheckReturnValue
        @SchedulerSupport("io.reactivex:computation")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> replay​(@NonNull
                                                                @NonNull Function<? super Observable<@NonNull T>,​? extends ObservableSource<@NonNull R>> selector,
                                                                int bufferSize,
                                                                long time,
                                                                @NonNull
                                                                @NonNull java.util.concurrent.TimeUnit unit)
        Returns an Observable that emits items that are the results of invoking a specified selector on items emitted by a ConnectableObservable that shares a single subscription to the current Observable, replaying no more than bufferSize items that were emitted within a specified time window.

        Note that due to concurrency requirements, replay(bufferSize) may hold strong references to more than bufferSize source emissions.

        Scheduler:
        This version of replay operates by default on the computation Scheduler.
        Type Parameters:
        R - the type of items emitted by the resulting Observable
        Parameters:
        selector - a selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the current Observable
        bufferSize - the buffer size that limits the number of items the connectable Observable can replay
        time - the duration of the window in which the replayed items must have been emitted
        unit - the time unit of time
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if selector or unit is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        See Also:
        ReactiveX operators documentation: Replay
      • replay

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> replay​(@NonNull
                                                                @NonNull Function<? super Observable<@NonNull T>,​? extends ObservableSource<@NonNull R>> selector,
                                                                int bufferSize,
                                                                long time,
                                                                @NonNull
                                                                @NonNull java.util.concurrent.TimeUnit unit,
                                                                @NonNull
                                                                @NonNull Scheduler scheduler)
        Returns an Observable that emits items that are the results of invoking a specified selector on items emitted by a ConnectableObservable that shares a single subscription to the current Observable, replaying no more than bufferSize items that were emitted within a specified time window.

        Note that due to concurrency requirements, replay(bufferSize) may hold strong references to more than bufferSize source emissions.

        Scheduler:
        You specify which Scheduler this operator will use.
        Type Parameters:
        R - the type of items emitted by the resulting Observable
        Parameters:
        selector - a selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the current Observable
        bufferSize - the buffer size that limits the number of items the connectable Observable can replay
        time - the duration of the window in which the replayed items must have been emitted
        unit - the time unit of time
        scheduler - the Scheduler that is the time source for the window
        Returns:
        the new Observable instance
        Throws:
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        java.lang.NullPointerException - if selector, unit or scheduler is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        See Also:
        ReactiveX operators documentation: Replay, replay(Function, int, long, TimeUnit, Scheduler, boolean)
      • replay

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> replay​(@NonNull
                                                                @NonNull Function<? super Observable<@NonNull T>,​? extends ObservableSource<@NonNull R>> selector,
                                                                int bufferSize,
                                                                long time,
                                                                @NonNull
                                                                @NonNull java.util.concurrent.TimeUnit unit,
                                                                @NonNull
                                                                @NonNull Scheduler scheduler,
                                                                boolean eagerTruncate)
        Returns an Observable that emits items that are the results of invoking a specified selector on items emitted by a ConnectableObservable that shares a single subscription to the current Observable, replaying no more than bufferSize items that were emitted within a specified time window.

        Note that due to concurrency requirements, replay(bufferSize) may hold strong references to more than bufferSize source emissions.

        Scheduler:
        You specify which Scheduler this operator will use.
        Type Parameters:
        R - the type of items emitted by the resulting Observable
        Parameters:
        selector - a selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the current Observable
        bufferSize - the buffer size that limits the number of items the connectable Observable can replay
        time - the duration of the window in which the replayed items must have been emitted
        unit - the time unit of time
        scheduler - the Scheduler that is the time source for the window
        eagerTruncate - if true, whenever the internal buffer is truncated to the given bufferSize/age, the oldest item will be guaranteed dereferenced, thus avoiding unexpected retention
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if selector, unit or scheduler is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        See Also:
        ReactiveX operators documentation: Replay
      • replay

        @CheckReturnValue
        @SchedulerSupport("io.reactivex:computation")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> replay​(@NonNull
                                                                @NonNull Function<? super Observable<@NonNull T>,​? extends ObservableSource<@NonNull R>> selector,
                                                                long time,
                                                                @NonNull
                                                                @NonNull java.util.concurrent.TimeUnit unit)
        Returns an Observable that emits items that are the results of invoking a specified selector on items emitted by a ConnectableObservable that shares a single subscription to the current Observable, replaying all items that were emitted within a specified time window.

        Scheduler:
        This version of replay operates by default on the computation Scheduler.
        Type Parameters:
        R - the type of items emitted by the resulting Observable
        Parameters:
        selector - a selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the current Observable
        time - the duration of the window in which the replayed items must have been emitted
        unit - the time unit of time
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if selector or unit is null
        See Also:
        ReactiveX operators documentation: Replay
      • replay

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> replay​(@NonNull
                                                                @NonNull Function<? super Observable<@NonNull T>,​? extends ObservableSource<@NonNull R>> selector,
                                                                long time,
                                                                @NonNull
                                                                @NonNull java.util.concurrent.TimeUnit unit,
                                                                @NonNull
                                                                @NonNull Scheduler scheduler,
                                                                boolean eagerTruncate)
        Returns an Observable that emits items that are the results of invoking a specified selector on items emitted by a ConnectableObservable that shares a single subscription to the current Observable, replaying all items that were emitted within a specified time window.

        Scheduler:
        You specify which Scheduler this operator will use.
        Type Parameters:
        R - the type of items emitted by the resulting Observable
        Parameters:
        selector - a selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the current Observable
        time - the duration of the window in which the replayed items must have been emitted
        unit - the time unit of time
        scheduler - the scheduler that is the time source for the window
        eagerTruncate - if true, whenever the internal buffer is truncated to the given age, the oldest item will be guaranteed dereferenced, thus avoiding unexpected retention
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if selector, unit or scheduler is null
        See Also:
        ReactiveX operators documentation: Replay
      • replay

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull ConnectableObservable<T> replay​(int bufferSize)
        Returns a ConnectableObservable that shares a single subscription to the current Observable that replays at most bufferSize items emitted by the current Observable. A connectable Observable resembles an ordinary Observable, except that it does not begin emitting items when it is subscribed to, but only when its connect method is called.

        Note that due to concurrency requirements, replay(bufferSize) may hold strong references to more than bufferSize source emissions. To ensure no beyond-bufferSize items are referenced, use the replay(int, boolean) overload with eagerTruncate = true.

        Scheduler:
        This version of replay does not operate by default on a particular Scheduler.
        Parameters:
        bufferSize - the buffer size that limits the number of items that can be replayed
        Returns:
        the new ConnectableObservable instance
        Throws:
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        See Also:
        ReactiveX operators documentation: Replay, replay(int, boolean)
      • replay

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull ConnectableObservable<T> replay​(int bufferSize,
                                                              boolean eagerTruncate)
        Returns a ConnectableObservable that shares a single subscription to the current Observable that replays at most bufferSize items emitted by the current Observable. A connectable Observable resembles an ordinary Observable, except that it does not begin emitting items when it is subscribed to, but only when its connect method is called.

        Note that due to concurrency requirements, replay(bufferSize) may hold strong references to more than bufferSize source emissions. To ensure no beyond-bufferSize items are referenced, set eagerTruncate = true.

        Scheduler:
        This version of replay does not operate by default on a particular Scheduler.
        Parameters:
        bufferSize - the buffer size that limits the number of items that can be replayed
        eagerTruncate - if true, whenever the internal buffer is truncated to the given bufferSize/age, the oldest item will be guaranteed dereferenced, thus avoiding unexpected retention
        Returns:
        the new ConnectableObservable instance
        Throws:
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        See Also:
        ReactiveX operators documentation: Replay
      • replay

        @CheckReturnValue
        @SchedulerSupport("io.reactivex:computation")
        @NonNull
        public final @NonNull ConnectableObservable<T> replay​(int bufferSize,
                                                              long time,
                                                              @NonNull
                                                              @NonNull java.util.concurrent.TimeUnit unit)
        Returns a ConnectableObservable that shares a single subscription to the current Observable and replays at most bufferSize items that were emitted during a specified time window. A connectable Observable resembles an ordinary Observable, except that it does not begin emitting items when it is subscribed to, but only when its connect method is called.

        Note that due to concurrency requirements, replay(bufferSize) may hold strong references to more than bufferSize source emissions. To ensure no out-of-date or beyond-bufferSize items are referenced, use the replay(int, long, TimeUnit, Scheduler, boolean) overload with eagerTruncate = true.

        Scheduler:
        This version of replay operates by default on the computation Scheduler.
        Parameters:
        bufferSize - the buffer size that limits the number of items that can be replayed
        time - the duration of the window in which the replayed items must have been emitted
        unit - the time unit of time
        Returns:
        the new ConnectableObservable instance
        Throws:
        java.lang.NullPointerException - if unit is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        See Also:
        ReactiveX operators documentation: Replay, replay(int, long, TimeUnit, Scheduler, boolean)
      • replay

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull ConnectableObservable<T> replay​(int bufferSize,
                                                              long time,
                                                              @NonNull
                                                              @NonNull java.util.concurrent.TimeUnit unit,
                                                              @NonNull
                                                              @NonNull Scheduler scheduler)
        Returns a ConnectableObservable that shares a single subscription to the current Observable and that replays a maximum of bufferSize items that are emitted within a specified time window. A connectable Observable resembles an ordinary Observable, except that it does not begin emitting items when it is subscribed to, but only when its connect method is called.

        Note that due to concurrency requirements, replay(bufferSize) may hold strong references to more than bufferSize source emissions. To ensure no out-of-date or beyond-bufferSize items are referenced, use the replay(int, long, TimeUnit, Scheduler, boolean) overload with eagerTruncate = true.

        Scheduler:
        You specify which Scheduler this operator will use.
        Parameters:
        bufferSize - the buffer size that limits the number of items that can be replayed
        time - the duration of the window in which the replayed items must have been emitted
        unit - the time unit of time
        scheduler - the scheduler that is used as a time source for the window
        Returns:
        the new ConnectableObservable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        See Also:
        ReactiveX operators documentation: Replay, replay(int, long, TimeUnit, Scheduler, boolean)
      • replay

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull ConnectableObservable<T> replay​(int bufferSize,
                                                              long time,
                                                              @NonNull
                                                              @NonNull java.util.concurrent.TimeUnit unit,
                                                              @NonNull
                                                              @NonNull Scheduler scheduler,
                                                              boolean eagerTruncate)
        Returns a ConnectableObservable that shares a single subscription to the current Observable and that replays a maximum of bufferSize items that are emitted within a specified time window. A connectable Observable resembles an ordinary Observable, except that it does not begin emitting items when it is subscribed to, but only when its connect method is called.

        Note that due to concurrency requirements, replay(bufferSize) may hold strong references to more than bufferSize source emissions. To ensure no out-of-date or beyond-bufferSize items are referenced, set eagerTruncate = true.

        Scheduler:
        You specify which Scheduler this operator will use.
        Parameters:
        bufferSize - the buffer size that limits the number of items that can be replayed
        time - the duration of the window in which the replayed items must have been emitted
        unit - the time unit of time
        scheduler - the scheduler that is used as a time source for the window
        eagerTruncate - if true, whenever the internal buffer is truncated to the given bufferSize/age, the oldest item will be guaranteed dereferenced, thus avoiding unexpected retention
        Returns:
        the new ConnectableObservable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        See Also:
        ReactiveX operators documentation: Replay
      • replay

        @CheckReturnValue
        @SchedulerSupport("io.reactivex:computation")
        @NonNull
        public final @NonNull ConnectableObservable<T> replay​(long time,
                                                              @NonNull
                                                              @NonNull java.util.concurrent.TimeUnit unit)
        Returns a ConnectableObservable that shares a single subscription to the current Observable and replays all items emitted by the current Observable within a specified time window. A connectable Observable resembles an ordinary Observable, except that it does not begin emitting items when it is subscribed to, but only when its connect method is called.

        Scheduler:
        This version of replay operates by default on the computation Scheduler.
        Parameters:
        time - the duration of the window in which the replayed items must have been emitted
        unit - the time unit of time
        Returns:
        the new ConnectableObservable instance
        Throws:
        java.lang.NullPointerException - if unit is null
        See Also:
        ReactiveX operators documentation: Replay
      • replay

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull ConnectableObservable<T> replay​(long time,
                                                              @NonNull
                                                              @NonNull java.util.concurrent.TimeUnit unit,
                                                              @NonNull
                                                              @NonNull Scheduler scheduler,
                                                              boolean eagerTruncate)
        Returns a ConnectableObservable that shares a single subscription to the current Observable and replays all items emitted by the current Observable within a specified time window. A connectable Observable resembles an ordinary Observable, except that it does not begin emitting items when it is subscribed to, but only when its connect method is called.

        Note that the internal buffer may retain strong references to the oldest item. To ensure no out-of-date items are referenced, set eagerTruncate = true.

        Scheduler:
        You specify which Scheduler this operator will use.
        Parameters:
        time - the duration of the window in which the replayed items must have been emitted
        unit - the time unit of time
        scheduler - the Scheduler that is the time source for the window
        eagerTruncate - if true, whenever the internal buffer is truncated to the given bufferSize/age, the oldest item will be guaranteed dereferenced, thus avoiding unexpected retention
        Returns:
        the new ConnectableObservable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null
        See Also:
        ReactiveX operators documentation: Replay
      • retry

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> retry()
        Returns an Observable that mirrors the current Observable, resubscribing to it if it calls onError (infinite retry count).

        If the current Observable calls Observer.onError(java.lang.Throwable), this method will resubscribe to the current Observable rather than propagating the onError call.

        Any and all items emitted by the current Observable will be emitted by the resulting Observable, even those emitted during failed subscriptions. For example, if the current Observable fails at first but emits [1, 2] then succeeds the second time and emits [1, 2, 3, 4, 5] then the complete sequence of emissions and notifications would be [1, 2, 1, 2, 3, 4, 5, onComplete].

        Scheduler:
        retry does not operate by default on a particular Scheduler.
        Returns:
        the new Observable instance
        See Also:
        ReactiveX operators documentation: Retry
      • retry

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> retry​(@NonNull
                                                  @NonNull BiPredicate<? super java.lang.Integer,​? super java.lang.Throwable> predicate)
        Returns an Observable that mirrors the current Observable, resubscribing to it if it calls onError and the predicate returns true for that specific exception and retry count.

        Scheduler:
        retry does not operate by default on a particular Scheduler.
        Parameters:
        predicate - the predicate that determines if a resubscription may happen in case of a specific exception and retry count
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if predicate is null
        See Also:
        retry(), ReactiveX operators documentation: Retry
      • retry

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> retry​(long times)
        Returns an Observable that mirrors the current Observable, resubscribing to it if it calls onError up to a specified number of retries.

        If the current Observable calls Observer.onError(java.lang.Throwable), this method will resubscribe to the current Observable for a maximum of count resubscriptions rather than propagating the onError call.

        Any and all items emitted by the current Observable will be emitted by the resulting Observable, even those emitted during failed subscriptions. For example, if the current Observable fails at first but emits [1, 2] then succeeds the second time and emits [1, 2, 3, 4, 5] then the complete sequence of emissions and notifications would be [1, 2, 1, 2, 3, 4, 5, onComplete].

        Scheduler:
        retry does not operate by default on a particular Scheduler.
        Parameters:
        times - the number of times to resubscribe if the current Observable fails
        Returns:
        the new Observable instance
        Throws:
        java.lang.IllegalArgumentException - if times is negative
        See Also:
        ReactiveX operators documentation: Retry
      • retry

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> retry​(long times,
                                                  @NonNull
                                                  @NonNull Predicate<? super java.lang.Throwable> predicate)
        Retries at most times or until the predicate returns false, whichever happens first.

        Scheduler:
        retry does not operate by default on a particular Scheduler.
        Parameters:
        times - the number of times to resubscribe if the current Observable fails
        predicate - the predicate called with the failure Throwable and should return true to trigger a retry.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if predicate is null
        java.lang.IllegalArgumentException - if times is negative
      • retry

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> retry​(@NonNull
                                                  @NonNull Predicate<? super java.lang.Throwable> predicate)
        Retries the current Observable if the predicate returns true.

        Scheduler:
        retry does not operate by default on a particular Scheduler.
        Parameters:
        predicate - the predicate that receives the failure Throwable and should return true to trigger a retry.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if predicate is null
      • retryWhen

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> retryWhen​(@NonNull
                                                      @NonNull Function<? super Observable<java.lang.Throwable>,​? extends ObservableSource<?>> handler)
        Returns an Observable that emits the same values as the current Observable with the exception of an onError. An onError notification from the source will result in the emission of a Throwable item to the Observable provided as an argument to the notificationHandler function. If that Observable calls onComplete or onError then retry will call onComplete or onError on the child subscription. Otherwise, the current Observable will be resubscribed.

        Example: This retries 3 times, each time incrementing the number of seconds it waits.

        
          Observable.create((ObservableEmitter<? super String> s) -> {
              System.out.println("subscribing");
              s.onError(new RuntimeException("always fails"));
          }).retryWhen(attempts -> {
              return attempts.zipWith(Observable.range(1, 3), (n, i) -> i).flatMap(i -> {
                  System.out.println("delay retry by " + i + " second(s)");
                  return Observable.timer(i, TimeUnit.SECONDS);
              });
          }).blockingForEach(System.out::println);
         
        Output is:
         
         subscribing
         delay retry by 1 second(s)
         subscribing
         delay retry by 2 second(s)
         subscribing
         delay retry by 3 second(s)
         subscribing
          

        Note that the inner ObservableSource returned by the handler function should signal either onNext, onError or onComplete in response to the received Throwable to indicate the operator should retry or terminate. If the upstream to the operator is asynchronous, signaling onNext followed by onComplete immediately may result in the sequence to be completed immediately. Similarly, if this inner ObservableSource signals onError or onComplete while the upstream is active, the sequence is terminated with the same signal immediately.

        The following example demonstrates how to retry an asynchronous source with a delay:

        
         Observable.timer(1, TimeUnit.SECONDS)
             .doOnSubscribe(s -> System.out.println("subscribing"))
             .map(v -> { throw new RuntimeException(); })
             .retryWhen(errors -> {
                 AtomicInteger counter = new AtomicInteger();
                 return errors
                           .takeWhile(e -> counter.getAndIncrement() != 3)
                           .flatMap(e -> {
                               System.out.println("delay retry by " + counter.get() + " second(s)");
                               return Observable.timer(counter.get(), TimeUnit.SECONDS);
                           });
             })
             .blockingSubscribe(System.out::println, System.out::println);
         
        Scheduler:
        retryWhen does not operate by default on a particular Scheduler.
        Parameters:
        handler - receives an Observable of notifications with which a user can complete or error, aborting the retry
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if handler is null
        See Also:
        ReactiveX operators documentation: Retry
      • safeSubscribe

        @SchedulerSupport("none")
        public final void safeSubscribe​(@NonNull
                                        @NonNull Observer<? super @NonNull T> observer)
        Subscribes to the current Observable and wraps the given Observer into a SafeObserver (if not already a SafeObserver) that deals with exceptions thrown by a misbehaving Observer (that doesn't follow the Reactive Streams specification).
        Scheduler:
        safeSubscribe does not operate by default on a particular Scheduler.
        Parameters:
        observer - the incoming Observer instance
        Throws:
        java.lang.NullPointerException - if observer is null
      • sample

        @CheckReturnValue
        @SchedulerSupport("io.reactivex:computation")
        @NonNull
        public final @NonNull Observable<T> sample​(long period,
                                                   @NonNull
                                                   @NonNull java.util.concurrent.TimeUnit unit,
                                                   boolean emitLast)
        Returns an Observable that emits the most recently emitted item (if any) emitted by the current Observable within periodic time intervals and optionally emit the very last upstream item when the upstream completes.

        Scheduler:
        sample operates by default on the computation Scheduler.

        History: 2.0.5 - experimental

        Parameters:
        period - the sampling rate
        unit - the TimeUnit in which period is defined
        emitLast - if true and the upstream completes while there is still an unsampled item available, that item is emitted to downstream before completion if false, an unsampled last item is ignored.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit is null
        Since:
        2.1
        See Also:
        ReactiveX operators documentation: Sample, throttleLast(long, TimeUnit)
      • sample

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<T> sample​(long period,
                                                   @NonNull
                                                   @NonNull java.util.concurrent.TimeUnit unit,
                                                   @NonNull
                                                   @NonNull Scheduler scheduler,
                                                   boolean emitLast)
        Returns an Observable that emits the most recently emitted item (if any) emitted by the current Observable within periodic time intervals, where the intervals are defined on a particular Scheduler and optionally emit the very last upstream item when the upstream completes.

        Scheduler:
        You specify which Scheduler this operator will use.

        History: 2.0.5 - experimental

        Parameters:
        period - the sampling rate
        unit - the TimeUnit in which period is defined
        scheduler - the Scheduler to use when sampling
        emitLast - if true and the upstream completes while there is still an unsampled item available, that item is emitted to downstream before completion if false, an unsampled last item is ignored.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null
        Since:
        2.1
        See Also:
        ReactiveX operators documentation: Sample, throttleLast(long, TimeUnit, Scheduler)
      • sample

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<T> sample​(long period,
                                                   @NonNull
                                                   @NonNull java.util.concurrent.TimeUnit unit,
                                                   @NonNull
                                                   @NonNull Scheduler scheduler,
                                                   boolean emitLast,
                                                   @NonNull
                                                   @NonNull Consumer<? super @NonNull T> onDropped)
        Returns an Observable that emits the most recently emitted item (if any) emitted by the current Observable within periodic time intervals, where the intervals are defined on a particular Scheduler.

        Scheduler:
        You specify which Scheduler this operator will use.
        Parameters:
        period - the sampling rate
        unit - the TimeUnit in which period is defined
        scheduler - the Scheduler to use when sampling
        emitLast - if true and the upstream completes while there is still an unsampled item available, that item is emitted to downstream before completion if false, an unsampled last item is ignored.
        onDropped - called with the current entry when it has been replaced by a new one
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null or onDropped is null
        Since:
        3.1.6 - Experimental
        See Also:
        ReactiveX operators documentation: Sample, throttleLast(long, TimeUnit, Scheduler)
      • sample

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull U> @NonNull Observable<T> sample​(@NonNull
                                                                @NonNull ObservableSource<@NonNull U> sampler,
                                                                boolean emitLast)
        Returns an Observable that, when the specified sampler ObservableSource emits an item or completes, emits the most recently emitted item (if any) emitted by the current Observable since the previous emission from the sampler ObservableSource and optionally emit the very last upstream item when the upstream or other ObservableSource complete.

        Scheduler:
        This version of sample does not operate by default on a particular Scheduler.

        History: 2.0.5 - experimental

        Type Parameters:
        U - the element type of the sampler ObservableSource
        Parameters:
        sampler - the ObservableSource to use for sampling the current Observable
        emitLast - if true and the upstream completes while there is still an unsampled item available, that item is emitted to downstream before completion if false, an unsampled last item is ignored.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if sampler is null
        Since:
        2.1
        See Also:
        ReactiveX operators documentation: Sample
      • scan

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> scan​(@NonNull
                                                 @NonNull BiFunction<@NonNull T,​@NonNull T,​@NonNull T> accumulator)
        Returns an Observable that emits the first value emitted by the current Observable, then emits one value for each subsequent value emitted by the current Observable. Each emission after the first is the result of applying the specified accumulator function to the previous emission and the corresponding value from the current Observable.

        This sort of function is sometimes called an accumulator.

        Scheduler:
        scan does not operate by default on a particular Scheduler.
        Parameters:
        accumulator - an accumulator function to be invoked on each item emitted by the current Observable, whose result will be emitted to Observers via onNext and used in the next accumulator call
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if accumulator is null
        See Also:
        ReactiveX operators documentation: Scan
      • scan

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> scan​(@NonNull
                                                              @NonNull R initialValue,
                                                              @NonNull
                                                              @NonNull BiFunction<@NonNull R,​? super @NonNull T,​@NonNull R> accumulator)
        Returns an Observable that emits the provided initial (seed) value, then emits one value for each value emitted by the current Observable. Each emission after the first is the result of applying the specified accumulator function to the previous emission and the corresponding value from the current Observable.

        This sort of function is sometimes called an accumulator.

        Note that the Observable that results from this method will emit initialValue as its first emitted item.

        Note that the initialValue is shared among all subscribers to the resulting Observable and may cause problems if it is mutable. To make sure each subscriber gets its own value, defer the application of this operator via defer(Supplier):

        
         ObservableSource<T> source = ...
         Observable.defer(() -> source.scan(new ArrayList<>(), (list, item) -> list.add(item)));
        
         // alternatively, by using compose to stay fluent
        
         source.compose(o ->
             Observable.defer(() -> o.scan(new ArrayList<>(), (list, item) -> list.add(item)))
         );
         
        Scheduler:
        scan does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the initial, accumulator and result type
        Parameters:
        initialValue - the initial (seed) accumulator item
        accumulator - an accumulator function to be invoked on each item emitted by the current Observable, whose result will be emitted to Observers via onNext and used in the next accumulator call
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if initialValue or accumulator is null
        See Also:
        ReactiveX operators documentation: Scan
      • scanWith

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> scanWith​(@NonNull
                                                                  @NonNull Supplier<@NonNull R> seedSupplier,
                                                                  @NonNull
                                                                  @NonNull BiFunction<@NonNull R,​? super @NonNull T,​@NonNull R> accumulator)
        Returns an Observable that emits the provided initial (seed) value, then emits one value for each value emitted by the current Observable. Each emission after the first is the result of applying the specified accumulator function to the previous emission and the corresponding value from the current Observable.

        This sort of function is sometimes called an accumulator.

        Note that the Observable that results from this method will emit the value returned by the seedSupplier as its first item.

        Scheduler:
        scanWith does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the initial, accumulator and result type
        Parameters:
        seedSupplier - a Supplier that returns the initial (seed) accumulator item for each individual Observer
        accumulator - an accumulator function to be invoked on each item emitted by the current Observable, whose result will be emitted to Observers via onNext and used in the next accumulator call
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if seedSupplier or accumulator is null
        See Also:
        ReactiveX operators documentation: Scan
      • serialize

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> serialize()
        Forces the current Observable's emissions and notifications to be serialized and for it to obey the ObservableSource contract in other ways.

        It is possible for an Observable to invoke its Observers' methods asynchronously, perhaps from different threads. This could make such an Observable poorly-behaved, in that it might try to invoke onComplete or onError before one of its onNext invocations, or it might call onNext from two different threads concurrently. You can force such an Observable to be well-behaved and sequential by applying the serialize method to it.

        Scheduler:
        serialize does not operate by default on a particular Scheduler.
        Returns:
        the new Observable instance
        See Also:
        ReactiveX operators documentation: Serialize
      • single

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Single<T> single​(@NonNull
                                               @NonNull T defaultItem)
        Returns a Single that emits the single item emitted by the current Observable, if the current Observable emits only a single item, or a default item if the current Observable emits no items. If the current Observable emits more than one item, an IllegalArgumentException is signaled instead.

        Scheduler:
        single does not operate by default on a particular Scheduler.
        Parameters:
        defaultItem - a default value to emit if the current Observable emits no item
        Returns:
        the new Single instance
        Throws:
        java.lang.NullPointerException - if defaultItem is null
        See Also:
        ReactiveX operators documentation: First
      • singleOrError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Single<T> singleOrError()
        Returns a Single that emits the single item emitted by the current Observable if it emits only a single item, otherwise if the current Observable completes without emitting any items or emits more than one item a NoSuchElementException or IllegalArgumentException will be signaled respectively.

        Scheduler:
        singleOrError does not operate by default on a particular Scheduler.
        Returns:
        the new Single instance
        See Also:
        ReactiveX operators documentation: First
      • skip

        @CheckReturnValue
        @SchedulerSupport("io.reactivex:computation")
        @NonNull
        public final @NonNull Observable<T> skip​(long time,
                                                 @NonNull
                                                 @NonNull java.util.concurrent.TimeUnit unit)
        Returns an Observable that skips values emitted by the current Observable before a specified time window elapses.

        Scheduler:
        skip does not operate on any particular scheduler but uses the current time from the computation Scheduler.
        Parameters:
        time - the length of the time window to skip
        unit - the time unit of time
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit is null
        See Also:
        ReactiveX operators documentation: Skip
      • skipLast

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> skipLast​(int count)
        Returns an Observable that drops a specified number of items from the end of the sequence emitted by the current Observable.

        This Observer accumulates a queue long enough to store the first count items. As more items are received, items are taken from the front of the queue and emitted by the returned Observable. This causes such items to be delayed.

        Scheduler:
        This version of skipLast does not operate by default on a particular Scheduler.
        Parameters:
        count - number of items to drop from the end of the source sequence
        Returns:
        the new Observable instance
        Throws:
        java.lang.IllegalArgumentException - if count is negative
        See Also:
        ReactiveX operators documentation: SkipLast
      • skipLast

        @CheckReturnValue
        @SchedulerSupport("io.reactivex:trampoline")
        @NonNull
        public final @NonNull Observable<T> skipLast​(long time,
                                                     @NonNull
                                                     @NonNull java.util.concurrent.TimeUnit unit)
        Returns an Observable that drops items emitted by the current Observable during a specified time window before the source completes.

        Note: this action will cache the latest items arriving in the specified time window.

        Scheduler:
        skipLast does not operate on any particular scheduler but uses the current time from the trampoline Scheduler.
        Parameters:
        time - the length of the time window
        unit - the time unit of time
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit is null
        See Also:
        ReactiveX operators documentation: SkipLast
      • skipLast

        @CheckReturnValue
        @SchedulerSupport("io.reactivex:trampoline")
        @NonNull
        public final @NonNull Observable<T> skipLast​(long time,
                                                     @NonNull
                                                     @NonNull java.util.concurrent.TimeUnit unit,
                                                     boolean delayError)
        Returns an Observable that drops items emitted by the current Observable during a specified time window before the source completes.

        Note: this action will cache the latest items arriving in the specified time window.

        Scheduler:
        skipLast does not operate on any particular scheduler but uses the current time from the computation Scheduler.
        Parameters:
        time - the length of the time window
        unit - the time unit of time
        delayError - if true, an exception signaled by the current Observable is delayed until the regular elements are consumed by the downstream; if false, an exception is immediately signaled and all regular elements dropped
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit is null
        See Also:
        ReactiveX operators documentation: SkipLast
      • skipLast

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<T> skipLast​(long time,
                                                     @NonNull
                                                     @NonNull java.util.concurrent.TimeUnit unit,
                                                     @NonNull
                                                     @NonNull Scheduler scheduler)
        Returns an Observable that drops items emitted by the current Observable during a specified time window (defined on a specified scheduler) before the source completes.

        Note: this action will cache the latest items arriving in the specified time window.

        Scheduler:
        You specify which Scheduler this operator will use for tracking the current time
        Parameters:
        time - the length of the time window
        unit - the time unit of time
        scheduler - the scheduler used as the time source
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null
        See Also:
        ReactiveX operators documentation: SkipLast
      • skipLast

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<T> skipLast​(long time,
                                                     @NonNull
                                                     @NonNull java.util.concurrent.TimeUnit unit,
                                                     @NonNull
                                                     @NonNull Scheduler scheduler,
                                                     boolean delayError)
        Returns an Observable that drops items emitted by the current Observable during a specified time window (defined on a specified scheduler) before the source completes.

        Note: this action will cache the latest items arriving in the specified time window.

        Scheduler:
        You specify which Scheduler this operator will use to track the current time
        Parameters:
        time - the length of the time window
        unit - the time unit of time
        scheduler - the scheduler used as the time source
        delayError - if true, an exception signaled by the current Observable is delayed until the regular elements are consumed by the downstream; if false, an exception is immediately signaled and all regular elements dropped
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null
        See Also:
        ReactiveX operators documentation: SkipLast
      • skipLast

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<T> skipLast​(long time,
                                                     @NonNull
                                                     @NonNull java.util.concurrent.TimeUnit unit,
                                                     @NonNull
                                                     @NonNull Scheduler scheduler,
                                                     boolean delayError,
                                                     int bufferSize)
        Returns an Observable that drops items emitted by the current Observable during a specified time window (defined on a specified scheduler) before the source completes.

        Note: this action will cache the latest items arriving in the specified time window.

        Scheduler:
        You specify which Scheduler this operator will use.
        Parameters:
        time - the length of the time window
        unit - the time unit of time
        scheduler - the scheduler used as the time source
        delayError - if true, an exception signaled by the current Observable is delayed until the regular elements are consumed by the downstream; if false, an exception is immediately signaled and all regular elements dropped
        bufferSize - the hint about how many elements to expect to be skipped
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        See Also:
        ReactiveX operators documentation: SkipLast
      • sorted

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> sorted()
        Returns an Observable that emits the events emitted by the current Observable, in a sorted order. Each item emitted by the current Observable must implement Comparable with respect to all other items in the sequence.

        If any item emitted by the current Observable does not implement Comparable with respect to all other items emitted by the current Observable, no items will be emitted and the sequence is terminated with a ClassCastException.

        Note that calling sorted with long, non-terminating or infinite sources might cause OutOfMemoryError

        Scheduler:
        sorted does not operate by default on a particular Scheduler.
        Returns:
        the new Observable instance
      • sorted

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> sorted​(@NonNull
                                                   @NonNull java.util.Comparator<? super @NonNull T> comparator)
        Returns an Observable that emits the events emitted by the current Observable, in a sorted order based on a specified comparison function.

        Note that calling sorted with long, non-terminating or infinite sources might cause OutOfMemoryError

        Scheduler:
        sorted does not operate by default on a particular Scheduler.
        Parameters:
        comparator - a function that compares two items emitted by the current Observable and returns an int that indicates their sort order
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if comparator is null
      • subscribe

        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Disposable subscribe​(@NonNull
                                                   @NonNull Consumer<? super @NonNull T> onNext,
                                                   @NonNull
                                                   @NonNull Consumer<? super java.lang.Throwable> onError,
                                                   @NonNull
                                                   @NonNull Action onComplete,
                                                   @NonNull
                                                   @NonNull DisposableContainer container)
        Wraps the given onXXX callbacks into a Disposable Observer, adds it to the given DisposableContainer and ensures, that if the upstream terminates or this particular Disposable is disposed, the Observer is removed from the given container.

        The Observer will be removed after the callback for the terminal event has been invoked.

        Scheduler:
        subscribe does not operate by default on a particular Scheduler.
        Parameters:
        onNext - the callback for upstream items
        onError - the callback for an upstream error if any
        onComplete - the callback for the upstream completion if any
        container - the DisposableContainer (such as CompositeDisposable) to add and remove the created Disposable Observer
        Returns:
        the Disposable that allows disposing the particular subscription.
        Throws:
        java.lang.NullPointerException - if onNext, onError, onComplete or container is null
        Since:
        3.1.0
      • subscribeActual

        protected abstract void subscribeActual​(@NonNull
                                                @NonNull Observer<? super @NonNull T> observer)
        Operator implementations (both source and intermediate) should implement this method that performs the necessary business logic and handles the incoming Observers.

        There is no need to call any of the plugin hooks on the current Observable instance or the Observer; all hooks and basic safeguards have been applied by subscribe(Observer) before this method gets called.

        Parameters:
        observer - the incoming Observer, never null
      • subscribeWith

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull E extends Observer<? super @NonNull T>> E subscribeWith​(@NonNull E observer)
        Subscribes a given Observer (subclass) to the current Observable and returns the given Observer instance as is.

        Usage example:

        
         Observable<Integer> source = Observable.range(1, 10);
         CompositeDisposable composite = new CompositeDisposable();
        
         DisposableObserver<Integer> ds = new DisposableObserver<>() {
             // ...
         };
        
         composite.add(source.subscribeWith(ds));
         
        Scheduler:
        subscribeWith does not operate by default on a particular Scheduler.
        Type Parameters:
        E - the type of the Observer to use and return
        Parameters:
        observer - the Observer (subclass) to use and return, not null
        Returns:
        the input observer
        Throws:
        java.lang.NullPointerException - if observer is null
        Since:
        2.0
      • switchIfEmpty

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> switchIfEmpty​(@NonNull
                                                          @NonNull ObservableSource<? extends @NonNull T> other)
        Returns an Observable that emits the items emitted by the current Observable or the items of an alternate ObservableSource if the current Observable is empty.

        Scheduler:
        switchIfEmpty does not operate by default on a particular Scheduler.
        Parameters:
        other - the alternate ObservableSource to subscribe to if the source does not emit any items
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if other is null
        Since:
        1.1.0
      • switchMap

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> switchMap​(@NonNull
                                                                   @NonNull Function<? super @NonNull T,​? extends ObservableSource<? extends @NonNull R>> mapper)
        Returns a new Observable by applying a function that you supply to each item emitted by the current Observable that returns an ObservableSource, and then emitting the items emitted by the most recently emitted of these ObservableSources.

        The resulting Observable completes if both the current Observable and the last inner ObservableSource, if any, complete. If the current Observable signals an onError, the inner ObservableSource is disposed and the error delivered in-sequence.

        Scheduler:
        switchMap does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the element type of the inner ObservableSources and the output
        Parameters:
        mapper - a function that, when applied to an item emitted by the current Observable, returns an ObservableSource
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
        See Also:
        ReactiveX operators documentation: FlatMap, switchMapDelayError(Function)
      • switchMap

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> switchMap​(@NonNull
                                                                   @NonNull Function<? super @NonNull T,​? extends ObservableSource<? extends @NonNull R>> mapper,
                                                                   int bufferSize)
        Returns a new Observable by applying a function that you supply to each item emitted by the current Observable that returns an ObservableSource, and then emitting the items emitted by the most recently emitted of these ObservableSources.

        The resulting Observable completes if both the current Observable and the last inner ObservableSource, if any, complete. If the current Observable signals an onError, the inner ObservableSource is disposed and the error delivered in-sequence.

        Scheduler:
        switchMap does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the element type of the inner ObservableSources and the output
        Parameters:
        mapper - a function that, when applied to an item emitted by the current Observable, returns an ObservableSource
        bufferSize - the number of elements expected from the current active inner ObservableSource to be buffered
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        See Also:
        ReactiveX operators documentation: FlatMap, switchMapDelayError(Function, int)
      • switchMapCompletable

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Completable switchMapCompletable​(@NonNull
                                                               @NonNull Function<? super @NonNull T,​? extends CompletableSource> mapper)
        Maps the items of the current Observable into CompletableSources, subscribes to the newer one while disposing the subscription to the previous CompletableSource, thus keeping at most one active CompletableSource running.

        Since a CompletableSource doesn't produce any items, the resulting reactive type of this operator is a Completable that can only indicate successful completion or a failure in any of the inner CompletableSources or the failure of the current Observable.

        Scheduler:
        switchMapCompletable does not operate by default on a particular Scheduler.
        Error handling:
        If either the current Observable or the active CompletableSource signals an onError, the resulting Completable is terminated immediately with that Throwable. Use the switchMapCompletableDelayError(Function) to delay such inner failures until every inner CompletableSources and the main Observable terminates in some fashion. If they fail concurrently, the operator may combine the Throwables into a CompositeException and signal it to the downstream instead. If any inactivated (switched out) CompletableSource signals an onError late, the Throwables will be signaled to the global error handler via RxJavaPlugins.onError(Throwable) method as UndeliverableException errors.

        History: 2.1.11 - experimental

        Parameters:
        mapper - the function called with each upstream item and should return a CompletableSource to be subscribed to and awaited for (non blockingly) for its terminal event
        Returns:
        the new Completable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
        Since:
        2.2
        See Also:
        switchMapCompletableDelayError(Function)
      • switchMapCompletableDelayError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Completable switchMapCompletableDelayError​(@NonNull
                                                                         @NonNull Function<? super @NonNull T,​? extends CompletableSource> mapper)
        Maps the upstream values into CompletableSources, subscribes to the newer one while disposing the subscription to the previous CompletableSource, thus keeping at most one active CompletableSource running and delaying any main or inner errors until all of them terminate.

        Since a CompletableSource doesn't produce any items, the resulting reactive type of this operator is a Completable that can only indicate successful completion or a failure in any of the inner CompletableSources or the failure of the current Observable.

        Scheduler:
        switchMapCompletableDelayError does not operate by default on a particular Scheduler.
        Error handling:
        The errors of the current Observable and all the CompletableSources, who had the chance to run to their completion, are delayed until all of them terminate in some fashion. At this point, if there was only one failure, the respective Throwable is emitted to the downstream. It there were more than one failures, the operator combines all Throwables into a CompositeException and signals that to the downstream. If any inactivated (switched out) CompletableSource signals an onError late, the Throwables will be signaled to the global error handler via RxJavaPlugins.onError(Throwable) method as UndeliverableException errors.

        History: 2.1.11 - experimental

        Parameters:
        mapper - the function called with each upstream item and should return a CompletableSource to be subscribed to and awaited for (non blockingly) for its terminal event
        Returns:
        the new Completable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
        Since:
        2.2
        See Also:
        switchMapCompletable(Function)
      • switchMapMaybe

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> switchMapMaybe​(@NonNull
                                                                        @NonNull Function<? super @NonNull T,​? extends MaybeSource<? extends @NonNull R>> mapper)
        Maps the items of the current Observable into MaybeSources and switches (subscribes) to the newer ones while disposing the older ones (and ignoring their signals) and emits the latest success value of the current one if available while failing immediately if the current Observable or any of the active inner MaybeSources fail.

        Scheduler:
        switchMapMaybe does not operate by default on a particular Scheduler.
        Error handling:
        This operator terminates with an onError if the current Observable or any of the inner MaybeSources fail while they are active. When this happens concurrently, their individual Throwable errors may get combined and emitted as a single CompositeException. Otherwise, a late (i.e., inactive or switched out) onError from the current Observable or from any of the inner MaybeSources will be forwarded to the global error handler via RxJavaPlugins.onError(Throwable) as UndeliverableException

        History: 2.1.11 - experimental

        Type Parameters:
        R - the output value type
        Parameters:
        mapper - the function called with the current upstream event and should return a MaybeSource to replace the current active inner source and get subscribed to.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
        Since:
        2.2
        See Also:
        switchMapMaybeDelayError(Function)
      • switchMapMaybeDelayError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> switchMapMaybeDelayError​(@NonNull
                                                                                  @NonNull Function<? super @NonNull T,​? extends MaybeSource<? extends @NonNull R>> mapper)
        Maps the upstream items into MaybeSources and switches (subscribes) to the newer ones while disposing the older ones (and ignoring their signals) and emits the latest success value of the current one if available, delaying errors from the current Observable or the inner MaybeSources until all terminate.

        Scheduler:
        switchMapMaybeDelayError does not operate by default on a particular Scheduler.

        History: 2.1.11 - experimental

        Type Parameters:
        R - the output value type
        Parameters:
        mapper - the function called with the current upstream event and should return a MaybeSource to replace the current active inner source and get subscribed to.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
        Since:
        2.2
        See Also:
        switchMapMaybe(Function)
      • switchMapSingle

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> switchMapSingle​(@NonNull
                                                                         @NonNull Function<? super @NonNull T,​? extends SingleSource<? extends @NonNull R>> mapper)
        Returns a new Observable by applying a function that you supply to each item emitted by the current Observable that returns a SingleSource, and then emitting the item emitted by the most recently emitted of these SingleSources.

        The resulting Observable completes if both the current Observable and the last inner SingleSource, if any, complete. If the current Observable signals an onError, the inner SingleSource is disposed and the error delivered in-sequence.

        Scheduler:
        switchMapSingle does not operate by default on a particular Scheduler.

        History: 2.0.8 - experimental

        Type Parameters:
        R - the element type of the inner SingleSources and the output
        Parameters:
        mapper - a function that, when applied to an item emitted by the current Observable, returns a SingleSource
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
        Since:
        2.2
        See Also:
        ReactiveX operators documentation: FlatMap, switchMapSingleDelayError(Function)
      • switchMapSingleDelayError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> switchMapSingleDelayError​(@NonNull
                                                                                   @NonNull Function<? super @NonNull T,​? extends SingleSource<? extends @NonNull R>> mapper)
        Returns a new Observable by applying a function that you supply to each item emitted by the current Observable that returns a SingleSource, and then emitting the item emitted by the most recently emitted of these SingleSources and delays any error until all SingleSources terminate.

        The resulting Observable completes if both the current Observable and the last inner SingleSource, if any, complete. If the current Observable signals an onError, the termination of the last inner SingleSource will emit that error as is or wrapped into a CompositeException along with the other possible errors the former inner SingleSources signaled.

        Scheduler:
        switchMapSingleDelayError does not operate by default on a particular Scheduler.

        History: 2.0.8 - experimental

        Type Parameters:
        R - the element type of the inner SingleSources and the output
        Parameters:
        mapper - a function that, when applied to an item emitted by the current Observable, returns a SingleSource
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
        Since:
        2.2
        See Also:
        ReactiveX operators documentation: FlatMap, switchMapSingle(Function)
      • switchMapDelayError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> switchMapDelayError​(@NonNull
                                                                             @NonNull Function<? super @NonNull T,​? extends ObservableSource<? extends @NonNull R>> mapper)
        Returns a new Observable by applying a function that you supply to each item emitted by the current Observable that returns an ObservableSource, and then emitting the items emitted by the most recently emitted of these ObservableSources and delays any error until all ObservableSources terminate.

        The resulting Observable completes if both the current Observable and the last inner ObservableSource, if any, complete. If the current Observable signals an onError, the termination of the last inner ObservableSource will emit that error as is or wrapped into a CompositeException along with the other possible errors the former inner ObservableSources signaled.

        Scheduler:
        switchMapDelayError does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the element type of the inner ObservableSources and the output
        Parameters:
        mapper - a function that, when applied to an item emitted by the current Observable, returns an ObservableSource
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
        Since:
        2.0
        See Also:
        ReactiveX operators documentation: FlatMap, switchMap(Function)
      • switchMapDelayError

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> switchMapDelayError​(@NonNull
                                                                             @NonNull Function<? super @NonNull T,​? extends ObservableSource<? extends @NonNull R>> mapper,
                                                                             int bufferSize)
        Returns a new Observable by applying a function that you supply to each item emitted by the current Observable that returns an ObservableSource, and then emitting the items emitted by the most recently emitted of these ObservableSources and delays any error until all ObservableSources terminate.

        The resulting Observable completes if both the current Observable and the last inner ObservableSource, if any, complete. If the current Observable signals an onError, the termination of the last inner ObservableSource will emit that error as is or wrapped into a CompositeException along with the other possible errors the former inner ObservableSources signaled.

        Scheduler:
        switchMapDelayError does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the element type of the inner ObservableSources and the output
        Parameters:
        mapper - a function that, when applied to an item emitted by the current Observable, returns an ObservableSource
        bufferSize - the number of elements expected from the current active inner ObservableSource to be buffered
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        Since:
        2.0
        See Also:
        ReactiveX operators documentation: FlatMap, switchMap(Function, int)
      • take

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> take​(long count)
        Returns an Observable that emits only the first count items emitted by the current Observable. If the source emits fewer than count items then all of its items are emitted.

        This method returns an Observable that will invoke a subscribing Observer's onNext function a maximum of count times before invoking onComplete.

        Taking 0 items from the current Observable will still subscribe to it, allowing the subscription-time side-effects to happen there, but will be immediately disposed and the downstream completed without any item emission.

        Scheduler:
        This version of take does not operate by default on a particular Scheduler.
        Parameters:
        count - the maximum number of items to emit
        Returns:
        the new Observable instance
        Throws:
        java.lang.IllegalArgumentException - if count is negative
        See Also:
        ReactiveX operators documentation: Take
      • take

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> take​(long time,
                                                 @NonNull
                                                 @NonNull java.util.concurrent.TimeUnit unit)
        Returns an Observable that emits those items emitted by the current Observable before a specified time runs out.

        If time runs out before the Observable completes normally, the onComplete event will be signaled on the default computation Scheduler.

        Scheduler:
        This version of take operates by default on the computation Scheduler.
        Parameters:
        time - the length of the time window
        unit - the time unit of time
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit is null
        See Also:
        ReactiveX operators documentation: Take
      • take

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<T> take​(long time,
                                                 @NonNull
                                                 @NonNull java.util.concurrent.TimeUnit unit,
                                                 @NonNull
                                                 @NonNull Scheduler scheduler)
        Returns an Observable that emits those items emitted by the current Observable before a specified time (on a specified Scheduler) runs out.

        If time runs out before the Observable completes normally, the onComplete event will be signaled on the provided Scheduler.

        Scheduler:
        You specify which Scheduler this operator will use.
        Parameters:
        time - the length of the time window
        unit - the time unit of time
        scheduler - the Scheduler used for time source
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null
        See Also:
        ReactiveX operators documentation: Take
      • takeLast

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<T> takeLast​(int count)
        Returns an Observable that emits at most the last count items emitted by the current Observable. If the source emits fewer than count items then all of its items are emitted.

        Scheduler:
        This version of takeLast does not operate by default on a particular Scheduler.
        Parameters:
        count - the maximum number of items to emit from the end of the sequence of items emitted by the current Observable
        Returns:
        the new Observable instance
        Throws:
        java.lang.IllegalArgumentException - if count is negative
        See Also:
        ReactiveX operators documentation: TakeLast
      • takeLast

        @CheckReturnValue
        @SchedulerSupport("io.reactivex:trampoline")
        @NonNull
        public final @NonNull Observable<T> takeLast​(long count,
                                                     long time,
                                                     @NonNull
                                                     @NonNull java.util.concurrent.TimeUnit unit)
        Returns an Observable that emits at most a specified number of items from the current Observable that were emitted in a specified window of time before the current Observable completed.

        Scheduler:
        takeLast does not operate on any particular scheduler but uses the current time from the trampoline Scheduler.
        Parameters:
        count - the maximum number of items to emit
        time - the length of the time window
        unit - the time unit of time
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit is null
        java.lang.IllegalArgumentException - if count is negative
        See Also:
        ReactiveX operators documentation: TakeLast
      • takeLast

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<T> takeLast​(long count,
                                                     long time,
                                                     @NonNull
                                                     @NonNull java.util.concurrent.TimeUnit unit,
                                                     @NonNull
                                                     @NonNull Scheduler scheduler)
        Returns an Observable that emits at most a specified number of items from the current Observable that were emitted in a specified window of time before the current Observable completed, where the timing information is provided by a given Scheduler.

        Scheduler:
        You specify which Scheduler this operator will use for tracking the current time
        Parameters:
        count - the maximum number of items to emit
        time - the length of the time window
        unit - the time unit of time
        scheduler - the Scheduler that provides the timestamps for the observed items
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null
        java.lang.IllegalArgumentException - if count is negative
        See Also:
        ReactiveX operators documentation: TakeLast
      • takeLast

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<T> takeLast​(long count,
                                                     long time,
                                                     @NonNull
                                                     @NonNull java.util.concurrent.TimeUnit unit,
                                                     @NonNull
                                                     @NonNull Scheduler scheduler,
                                                     boolean delayError,
                                                     int bufferSize)
        Returns an Observable that emits at most a specified number of items from the current Observable that were emitted in a specified window of time before the current Observable completed, where the timing information is provided by a given Scheduler.

        Scheduler:
        You specify which Scheduler this operator will use for tracking the current time
        Parameters:
        count - the maximum number of items to emit
        time - the length of the time window
        unit - the time unit of time
        scheduler - the Scheduler that provides the timestamps for the observed items
        delayError - if true, an exception signaled by the current Observable is delayed until the regular elements are consumed by the downstream; if false, an exception is immediately signaled and all regular elements dropped
        bufferSize - the hint about how many elements to expect to be last
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null
        java.lang.IllegalArgumentException - if count is negative or bufferSize is non-positive
        See Also:
        ReactiveX operators documentation: TakeLast
      • takeLast

        @CheckReturnValue
        @SchedulerSupport("io.reactivex:trampoline")
        @NonNull
        public final @NonNull Observable<T> takeLast​(long time,
                                                     @NonNull
                                                     @NonNull java.util.concurrent.TimeUnit unit)
        Returns an Observable that emits the items from the current Observable that were emitted in a specified window of time before the current Observable completed.

        Scheduler:
        takeLast does not operate on any particular scheduler but uses the current time from the trampoline Scheduler.
        Parameters:
        time - the length of the time window
        unit - the time unit of time
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit is null
        See Also:
        ReactiveX operators documentation: TakeLast
      • takeLast

        @CheckReturnValue
        @SchedulerSupport("io.reactivex:trampoline")
        @NonNull
        public final @NonNull Observable<T> takeLast​(long time,
                                                     @NonNull
                                                     @NonNull java.util.concurrent.TimeUnit unit,
                                                     boolean delayError)
        Returns an Observable that emits the items from the current Observable that were emitted in a specified window of time before the current Observable completed.

        Scheduler:
        takeLast does not operate on any particular scheduler but uses the current time from the trampoline Scheduler.
        Parameters:
        time - the length of the time window
        unit - the time unit of time
        delayError - if true, an exception signaled by the current Observable is delayed until the regular elements are consumed by the downstream; if false, an exception is immediately signaled and all regular elements dropped
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit is null
        java.lang.IllegalArgumentException - if count is non-positive
        See Also:
        ReactiveX operators documentation: TakeLast
      • takeLast

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<T> takeLast​(long time,
                                                     @NonNull
                                                     @NonNull java.util.concurrent.TimeUnit unit,
                                                     @NonNull
                                                     @NonNull Scheduler scheduler)
        Returns an Observable that emits the items from the current Observable that were emitted in a specified window of time before the current Observable completed, where the timing information is provided by a specified Scheduler.

        Scheduler:
        You specify which Scheduler this operator will use.
        Parameters:
        time - the length of the time window
        unit - the time unit of time
        scheduler - the Scheduler that provides the timestamps for the observed items
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null
        See Also:
        ReactiveX operators documentation: TakeLast
      • takeLast

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<T> takeLast​(long time,
                                                     @NonNull
                                                     @NonNull java.util.concurrent.TimeUnit unit,
                                                     @NonNull
                                                     @NonNull Scheduler scheduler,
                                                     boolean delayError)
        Returns an Observable that emits the items from the current Observable that were emitted in a specified window of time before the current Observable completed, where the timing information is provided by a specified Scheduler.

        Scheduler:
        You specify which Scheduler this operator will use.
        Parameters:
        time - the length of the time window
        unit - the time unit of time
        scheduler - the Scheduler that provides the timestamps for the observed items
        delayError - if true, an exception signaled by the current Observable is delayed until the regular elements are consumed by the downstream; if false, an exception is immediately signaled and all regular elements dropped
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null
        See Also:
        ReactiveX operators documentation: TakeLast
      • takeLast

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<T> takeLast​(long time,
                                                     @NonNull
                                                     @NonNull java.util.concurrent.TimeUnit unit,
                                                     @NonNull
                                                     @NonNull Scheduler scheduler,
                                                     boolean delayError,
                                                     int bufferSize)
        Returns an Observable that emits the items from the current Observable that were emitted in a specified window of time before the current Observable completed, where the timing information is provided by a specified Scheduler.

        Scheduler:
        You specify which Scheduler this operator will use.
        Parameters:
        time - the length of the time window
        unit - the time unit of time
        scheduler - the Scheduler that provides the timestamps for the observed items
        delayError - if true, an exception signaled by the current Observable is delayed until the regular elements are consumed by the downstream; if false, an exception is immediately signaled and all regular elements dropped
        bufferSize - the hint about how many elements to expect to be last
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        See Also:
        ReactiveX operators documentation: TakeLast
      • throttleFirst

        @CheckReturnValue
        @SchedulerSupport("io.reactivex:computation")
        @NonNull
        public final @NonNull Observable<T> throttleFirst​(long windowDuration,
                                                          @NonNull
                                                          @NonNull java.util.concurrent.TimeUnit unit)
        Returns an Observable that emits only the first item emitted by the current Observable during sequential time windows of a specified duration.

        This differs from throttleLast(long, java.util.concurrent.TimeUnit) in that this only tracks passage of time whereas throttleLast ticks at scheduled intervals.

        Scheduler:
        throttleFirst operates by default on the computation Scheduler.
        Parameters:
        windowDuration - time to wait before emitting another item after emitting the last item
        unit - the unit of time of windowDuration
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit is null
        See Also:
        ReactiveX operators documentation: Sample
      • throttleFirst

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<T> throttleFirst​(long skipDuration,
                                                          @NonNull
                                                          @NonNull java.util.concurrent.TimeUnit unit,
                                                          @NonNull
                                                          @NonNull Scheduler scheduler)
        Returns an Observable that emits only the first item emitted by the current Observable during sequential time windows of a specified duration, where the windows are managed by a specified Scheduler.

        This differs from throttleLast(long, java.util.concurrent.TimeUnit) in that this only tracks passage of time whereas throttleLast ticks at scheduled intervals.

        Scheduler:
        You specify which Scheduler this operator will use.
        Parameters:
        skipDuration - time to wait before emitting another item after emitting the last item
        unit - the unit of time of skipDuration
        scheduler - the Scheduler to use internally to manage the timers that handle timeout for each event
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null
        See Also:
        ReactiveX operators documentation: Sample
      • throttleFirst

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<T> throttleFirst​(long skipDuration,
                                                          @NonNull
                                                          @NonNull java.util.concurrent.TimeUnit unit,
                                                          @NonNull
                                                          @NonNull Scheduler scheduler,
                                                          @NonNull
                                                          @NonNull Consumer<? super @NonNull T> onDropped)
        Returns an Observable that emits only the first item emitted by the current Observable during sequential time windows of a specified duration, where the windows are managed by a specified Scheduler.

        This differs from throttleLast(long, java.util.concurrent.TimeUnit) in that this only tracks passage of time whereas throttleLast ticks at scheduled intervals.

        Scheduler:
        You specify which Scheduler this operator will use.
        Parameters:
        skipDuration - time to wait before emitting another item after emitting the last item
        unit - the unit of time of skipDuration
        scheduler - the Scheduler to use internally to manage the timers that handle timeout for each event
        onDropped - called when an item doesn't get delivered to the downstream
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler or onDropped is null
        Since:
        3.1.6 - Experimental
        See Also:
        ReactiveX operators documentation: Sample
      • throttleLast

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<T> throttleLast​(long intervalDuration,
                                                         @NonNull
                                                         @NonNull java.util.concurrent.TimeUnit unit,
                                                         @NonNull
                                                         @NonNull Scheduler scheduler,
                                                         @NonNull
                                                         @NonNull Consumer<? super @NonNull T> onDropped)
        Returns an Observable that emits only the last item emitted by the current Observable during sequential time windows of a specified duration, where the duration is governed by a specified Scheduler.

        This differs from throttleFirst(long, java.util.concurrent.TimeUnit) in that this ticks along at a scheduled interval whereas throttleFirst does not tick, it just tracks passage of time.

        Scheduler:
        You specify which Scheduler this operator will use.
        Parameters:
        intervalDuration - duration of windows within which the last item emitted by the current Observable will be emitted
        unit - the unit of time of intervalDuration
        scheduler - the Scheduler to use internally to manage the timers that handle timeout for each event
        onDropped - called with the current entry when it has been replaced by a new one
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null or onDropped is null
        Since:
        3.1.6 - Experimental
        See Also:
        ReactiveX operators documentation: Sample, sample(long, TimeUnit, Scheduler)
      • throttleLatest

        @CheckReturnValue
        @SchedulerSupport("io.reactivex:computation")
        @NonNull
        public final @NonNull Observable<T> throttleLatest​(long timeout,
                                                           @NonNull
                                                           @NonNull java.util.concurrent.TimeUnit unit)
        Throttles items from the current Observable by first emitting the next item from upstream, then periodically emitting the latest item (if any) when the specified timeout elapses between them.

        Unlike the option with throttleLatest(long, TimeUnit, boolean), the very last item being held back (if any) is not emitted when the upstream completes.

        If no items were emitted from the upstream during this timeout phase, the next upstream item is emitted immediately and the timeout window starts from then.

        Scheduler:
        throttleLatest operates by default on the computation Scheduler.

        History: 2.1.14 - experimental

        Parameters:
        timeout - the time to wait after an item emission towards the downstream before trying to emit the latest item from upstream again
        unit - the time unit
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit is null
        Since:
        2.2
        See Also:
        throttleLatest(long, TimeUnit, boolean), throttleLatest(long, TimeUnit, Scheduler)
      • throttleLatest

        @CheckReturnValue
        @SchedulerSupport("io.reactivex:computation")
        @NonNull
        public final @NonNull Observable<T> throttleLatest​(long timeout,
                                                           @NonNull
                                                           @NonNull java.util.concurrent.TimeUnit unit,
                                                           boolean emitLast)
        Throttles items from the current Observable by first emitting the next item from upstream, then periodically emitting the latest item (if any) when the specified timeout elapses between them.

        If no items were emitted from the upstream during this timeout phase, the next upstream item is emitted immediately and the timeout window starts from then.

        Scheduler:
        throttleLatest operates by default on the computation Scheduler.

        History: 2.1.14 - experimental

        Parameters:
        timeout - the time to wait after an item emission towards the downstream before trying to emit the latest item from upstream again
        unit - the time unit
        emitLast - If true, the very last item from the upstream will be emitted immediately when the upstream completes, regardless if there is a timeout window active or not. If false, the very last upstream item is ignored and the flow terminates.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit is null
        Since:
        2.2
        See Also:
        throttleLatest(long, TimeUnit, Scheduler, boolean)
      • throttleLatest

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<T> throttleLatest​(long timeout,
                                                           @NonNull
                                                           @NonNull java.util.concurrent.TimeUnit unit,
                                                           @NonNull
                                                           @NonNull Scheduler scheduler)
        Throttles items from the current Observable by first emitting the next item from upstream, then periodically emitting the latest item (if any) when the specified timeout elapses between them.

        Unlike the option with throttleLatest(long, TimeUnit, Scheduler, boolean), the very last item being held back (if any) is not emitted when the upstream completes.

        If no items were emitted from the upstream during this timeout phase, the next upstream item is emitted immediately and the timeout window starts from then.

        Scheduler:
        You specify which Scheduler this operator will use.

        History: 2.1.14 - experimental

        Parameters:
        timeout - the time to wait after an item emission towards the downstream before trying to emit the latest item from upstream again
        unit - the time unit
        scheduler - the Scheduler where the timed wait and latest item emission will be performed
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null
        Since:
        2.2
        See Also:
        throttleLatest(long, TimeUnit, Scheduler, boolean)
      • throttleLatest

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<T> throttleLatest​(long timeout,
                                                           @NonNull
                                                           @NonNull java.util.concurrent.TimeUnit unit,
                                                           @NonNull
                                                           @NonNull Scheduler scheduler,
                                                           boolean emitLast)
        Throttles items from the current Observable by first emitting the next item from upstream, then periodically emitting the latest item (if any) when the specified timeout elapses between them.

        If no items were emitted from the upstream during this timeout phase, the next upstream item is emitted immediately and the timeout window starts from then.

        Scheduler:
        You specify which Scheduler this operator will use.

        History: 2.1.14 - experimental

        Parameters:
        timeout - the time to wait after an item emission towards the downstream before trying to emit the latest item from upstream again
        unit - the time unit
        scheduler - the Scheduler where the timed wait and latest item emission will be performed
        emitLast - If true, the very last item from the upstream will be emitted immediately when the upstream completes, regardless if there is a timeout window active or not. If false, the very last upstream item is ignored and the flow terminates.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null
        Since:
        2.2
      • throttleLatest

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<T> throttleLatest​(long timeout,
                                                           @NonNull
                                                           @NonNull java.util.concurrent.TimeUnit unit,
                                                           @NonNull
                                                           @NonNull Scheduler scheduler,
                                                           boolean emitLast,
                                                           @NonNull
                                                           @NonNull Consumer<? super @NonNull T> onDropped)
        Throttles items from the current Observable by first emitting the next item from upstream, then periodically emitting the latest item (if any) when the specified timeout elapses between them, invoking the consumer for any dropped item.

        If no items were emitted from the upstream during this timeout phase, the next upstream item is emitted immediately and the timeout window starts from then.

        Scheduler:
        You specify which Scheduler this operator will use.
        Error handling:
        If the upstream signals an onError or onDropped callback crashes, the error is delivered immediately to the downstream. If both happen, a CompositeException is created, containing both the upstream and the callback error. If the onDropped callback crashes when the sequence gets disposed, the exception is forwarded to the global error handler via RxJavaPlugins.onError(Throwable).
        Parameters:
        timeout - the time to wait after an item emission towards the downstream before trying to emit the latest item from upstream again
        unit - the time unit
        scheduler - the Scheduler where the timed wait and latest item emission will be performed
        emitLast - If true, the very last item from the upstream will be emitted immediately when the upstream completes, regardless if there is a timeout window active or not. If false, the very last upstream item is ignored and the flow terminates.
        onDropped - called when an item is replaced by a newer item that doesn't get delivered to the downstream, including the very last item if emitLast is false and the current undelivered item when the sequence gets disposed.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit, scheduler or onDropped is null
        Since:
        3.1.6 - Experimental
      • throttleWithTimeout

        @CheckReturnValue
        @SchedulerSupport("io.reactivex:computation")
        @NonNull
        public final @NonNull Observable<T> throttleWithTimeout​(long timeout,
                                                                @NonNull
                                                                @NonNull java.util.concurrent.TimeUnit unit)
        Returns an Observable that mirrors the current Observable, except that it drops items emitted by the current Observable that are followed by newer items before a timeout value expires. The timer resets on each emission (alias to debounce(long, TimeUnit, Scheduler)).

        Note: If items keep being emitted by the current Observable faster than the timeout then no items will be emitted by the resulting Observable.

        Scheduler:
        throttleWithTimeout operates by default on the computation Scheduler.
        Parameters:
        timeout - the length of the window of time that must pass after the emission of an item from the current Observable, in which the current Observable emits no items, in order for the item to be emitted by the resulting Observable
        unit - the unit of time for the specified timeout
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit is null
        See Also:
        ReactiveX operators documentation: Debounce, debounce(long, TimeUnit)
      • throttleWithTimeout

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<T> throttleWithTimeout​(long timeout,
                                                                @NonNull
                                                                @NonNull java.util.concurrent.TimeUnit unit,
                                                                @NonNull
                                                                @NonNull Scheduler scheduler)
        Returns an Observable that mirrors the current Observable, except that it drops items emitted by the current Observable that are followed by newer items before a timeout value expires on a specified Scheduler. The timer resets on each emission (Alias to debounce(long, TimeUnit, Scheduler)).

        Note: If items keep being emitted by the current Observable faster than the timeout then no items will be emitted by the resulting Observable.

        Scheduler:
        You specify which Scheduler this operator will use.
        Parameters:
        timeout - the length of the window of time that must pass after the emission of an item from the current Observable, in which the current Observable emits no items, in order for the item to be emitted by the resulting Observable
        unit - the unit of time for the specified timeout
        scheduler - the Scheduler to use internally to manage the timers that handle the timeout for each item
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null
        See Also:
        ReactiveX operators documentation: Debounce, debounce(long, TimeUnit, Scheduler)
      • throttleWithTimeout

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<T> throttleWithTimeout​(long timeout,
                                                                @NonNull
                                                                @NonNull java.util.concurrent.TimeUnit unit,
                                                                @NonNull
                                                                @NonNull Scheduler scheduler,
                                                                @NonNull
                                                                @NonNull Consumer<? super @NonNull T> onDropped)
        Returns an Observable that mirrors the current Observable, except that it drops items emitted by the current Observable that are followed by newer items before a timeout value expires on a specified Scheduler. The timer resets on each emission (Alias to debounce(long, TimeUnit, Scheduler)).

        Note: If items keep being emitted by the current Observable faster than the timeout then no items will be emitted by the resulting Observable.

        Scheduler:
        You specify which Scheduler this operator will use.
        Parameters:
        timeout - the length of the window of time that must pass after the emission of an item from the current Observable, in which the current Observable emits no items, in order for the item to be emitted by the resulting Observable
        unit - the unit of time for the specified timeout
        scheduler - the Scheduler to use internally to manage the timers that handle the timeout for each item
        onDropped - called with the current entry when it has been replaced by a new one
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null or onDropped is null
        Since:
        3.1.6 - Experimental
        See Also:
        ReactiveX operators documentation: Debounce, debounce(long, TimeUnit, Scheduler, Consumer)
      • timeout

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull V> @NonNull Observable<T> timeout​(@NonNull
                                                                 @NonNull Function<? super @NonNull T,​? extends ObservableSource<@NonNull V>> itemTimeoutIndicator)
        Returns an Observable that mirrors the current Observable, but notifies observers of a TimeoutException if an item emitted by the current Observable doesn't arrive within a window of time after the emission of the previous item, where that period of time is measured by an ObservableSource that is a function of the previous item.

        Note: The arrival of the first source item is never timed out.

        Scheduler:
        This version of timeout operates by default on the immediate Scheduler.
        Type Parameters:
        V - the timeout value type (ignored)
        Parameters:
        itemTimeoutIndicator - a function that returns an ObservableSource for each item emitted by the current Observable and that determines the timeout window for the subsequent item
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if itemTimeoutIndicator is null
        See Also:
        ReactiveX operators documentation: Timeout
      • timeout

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull V> @NonNull Observable<T> timeout​(@NonNull
                                                                 @NonNull Function<? super @NonNull T,​? extends ObservableSource<@NonNull V>> itemTimeoutIndicator,
                                                                 @NonNull
                                                                 @NonNull ObservableSource<? extends @NonNull T> fallback)
        Returns an Observable that mirrors the current Observable, but that switches to a fallback ObservableSource if an item emitted by the current Observable doesn't arrive within a window of time after the emission of the previous item, where that period of time is measured by an ObservableSource that is a function of the previous item.

        Note: The arrival of the first source item is never timed out.

        Scheduler:
        This version of timeout operates by default on the immediate Scheduler.
        Type Parameters:
        V - the timeout value type (ignored)
        Parameters:
        itemTimeoutIndicator - a function that returns an ObservableSource, for each item emitted by the current Observable, that determines the timeout window for the subsequent item
        fallback - the fallback ObservableSource to switch to if the current Observable times out
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if itemTimeoutIndicator or fallback is null
        See Also:
        ReactiveX operators documentation: Timeout
      • timeout

        @CheckReturnValue
        @SchedulerSupport("io.reactivex:computation")
        @NonNull
        public final @NonNull Observable<T> timeout​(long timeout,
                                                    @NonNull
                                                    @NonNull java.util.concurrent.TimeUnit unit)
        Returns an Observable that mirrors the current Observable but applies a timeout policy for each emitted item. If the next item isn't emitted within the specified timeout duration starting from its predecessor, the resulting Observable terminates and notifies observers of a TimeoutException.

        Scheduler:
        This version of timeout operates by default on the computation Scheduler.
        Parameters:
        timeout - maximum duration between emitted items before a timeout occurs
        unit - the unit of time that applies to the timeout argument.
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit is null
        See Also:
        ReactiveX operators documentation: Timeout
      • timeout

        @CheckReturnValue
        @SchedulerSupport("io.reactivex:computation")
        @NonNull
        public final @NonNull Observable<T> timeout​(long timeout,
                                                    @NonNull
                                                    @NonNull java.util.concurrent.TimeUnit unit,
                                                    @NonNull
                                                    @NonNull ObservableSource<? extends @NonNull T> fallback)
        Returns an Observable that mirrors the current Observable but applies a timeout policy for each emitted item. If the next item isn't emitted within the specified timeout duration starting from its predecessor, the current Observable is disposed and the resulting Observable begins instead to mirror a fallback ObservableSource.

        Scheduler:
        This version of timeout operates by default on the computation Scheduler.
        Parameters:
        timeout - maximum duration between items before a timeout occurs
        unit - the unit of time that applies to the timeout argument
        fallback - the fallback ObservableSource to use in case of a timeout
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or fallback is null
        See Also:
        ReactiveX operators documentation: Timeout
      • timeout

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<T> timeout​(long timeout,
                                                    @NonNull
                                                    @NonNull java.util.concurrent.TimeUnit unit,
                                                    @NonNull
                                                    @NonNull Scheduler scheduler,
                                                    @NonNull
                                                    @NonNull ObservableSource<? extends @NonNull T> fallback)
        Returns an Observable that mirrors the current Observable but applies a timeout policy for each emitted item using a specified Scheduler. If the next item isn't emitted within the specified timeout duration starting from its predecessor, the current Observable is disposed and returned Observable begins instead to mirror a fallback ObservableSource.

        Scheduler:
        You specify which Scheduler this operator will use.
        Parameters:
        timeout - maximum duration between items before a timeout occurs
        unit - the unit of time that applies to the timeout argument
        scheduler - the Scheduler to run the timeout timers on
        fallback - the ObservableSource to use as the fallback in case of a timeout
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit, scheduler or fallback is null
        See Also:
        ReactiveX operators documentation: Timeout
      • timeout

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<T> timeout​(long timeout,
                                                    @NonNull
                                                    @NonNull java.util.concurrent.TimeUnit unit,
                                                    @NonNull
                                                    @NonNull Scheduler scheduler)
        Returns an Observable that mirrors the current Observable but applies a timeout policy for each emitted item, where this policy is governed on a specified Scheduler. If the next item isn't emitted within the specified timeout duration starting from its predecessor, the resulting Observable terminates and notifies observers of a TimeoutException.

        Scheduler:
        You specify which Scheduler this operator will use.
        Parameters:
        timeout - maximum duration between items before a timeout occurs
        unit - the unit of time that applies to the timeout argument
        scheduler - the Scheduler to run the timeout timers on
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null
        See Also:
        ReactiveX operators documentation: Timeout
      • timeout

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull U,​@NonNull V> @NonNull Observable<T> timeout​(@NonNull
                                                                                  @NonNull ObservableSource<@NonNull U> firstTimeoutIndicator,
                                                                                  @NonNull
                                                                                  @NonNull Function<? super @NonNull T,​? extends ObservableSource<@NonNull V>> itemTimeoutIndicator)
        Returns an Observable that mirrors the current Observable, but notifies observers of a TimeoutException if either the first item emitted by the current Observable or any subsequent item doesn't arrive within time windows defined by indicator ObservableSources.

        Scheduler:
        This version of timeout operates by default on the immediate Scheduler.
        Type Parameters:
        U - the first timeout value type (ignored)
        V - the subsequent timeout value type (ignored)
        Parameters:
        firstTimeoutIndicator - a function that returns an ObservableSource that determines the timeout window for the first source item
        itemTimeoutIndicator - a function that returns an ObservableSource for each item emitted by the current Observable and that determines the timeout window in which the subsequent source item must arrive in order to continue the sequence
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if firstTimeoutIndicator or itemTimeoutIndicator is null
        See Also:
        ReactiveX operators documentation: Timeout
      • timeout

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull U,​@NonNull V> @NonNull Observable<T> timeout​(@NonNull
                                                                                  @NonNull ObservableSource<@NonNull U> firstTimeoutIndicator,
                                                                                  @NonNull
                                                                                  @NonNull Function<? super @NonNull T,​? extends ObservableSource<@NonNull V>> itemTimeoutIndicator,
                                                                                  @NonNull
                                                                                  @NonNull ObservableSource<? extends @NonNull T> fallback)
        Returns an Observable that mirrors the current Observable, but switches to a fallback ObservableSource if either the first item emitted by the current Observable or any subsequent item doesn't arrive within time windows defined by indicator ObservableSources.

        Scheduler:
        This version of timeout operates by default on the immediate Scheduler.
        Type Parameters:
        U - the first timeout value type (ignored)
        V - the subsequent timeout value type (ignored)
        Parameters:
        firstTimeoutIndicator - a function that returns an ObservableSource which determines the timeout window for the first source item
        itemTimeoutIndicator - a function that returns an ObservableSource for each item emitted by the current Observable and that determines the timeout window in which the subsequent source item must arrive in order to continue the sequence
        fallback - the fallback ObservableSource to switch to if the current Observable times out
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if firstTimeoutIndicator, itemTimeoutIndicator or fallback is null
        See Also:
        ReactiveX operators documentation: Timeout
      • to

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> R to​(@NonNull
                                       @NonNull ObservableConverter<@NonNull T,​? extends @NonNull R> converter)
        Calls the specified converter function during assembly time and returns its resulting value.

        This allows fluent conversion to any other type.

        Scheduler:
        to does not operate by default on a particular Scheduler.

        History: 2.1.7 - experimental

        Type Parameters:
        R - the resulting object type
        Parameters:
        converter - the function that receives the current Observable instance and returns a value
        Returns:
        the converted value
        Throws:
        java.lang.NullPointerException - if converter is null
        Since:
        2.2
      • toList

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Single<@NonNull java.util.List<T>> toList()
        Returns a Single that emits a single item, a List composed of all the items emitted by the current and finite Observable.

        Normally, an ObservableSource that returns multiple items will do so by invoking its Observer's onNext method for each such item. You can change this behavior by having the operator to compose a list of all of these items and then to invoke the SingleObserver's onSuccess method once, passing it the entire list, by calling the Observable's toList method prior to calling its subscribe() method.

        Note that this operator requires the upstream to signal onComplete for the accumulated list to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatal OutOfMemoryError.

        Scheduler:
        toList does not operate by default on a particular Scheduler.
        Returns:
        the new Single instance
        See Also:
        ReactiveX operators documentation: To
      • toList

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Single<@NonNull java.util.List<T>> toList​(int capacityHint)
        Returns a Single that emits a single item, a List composed of all the items emitted by the current and finite Observable.

        Normally, an ObservableSource that returns multiple items will do so by invoking its Observer's onNext method for each such item. You can change this behavior by having the operator to compose a list of all of these items and then to invoke the SingleObserver's onSuccess method once, passing it the entire list, by calling the Observable's toList method prior to calling its subscribe() method.

        Note that this operator requires the upstream to signal onComplete for the accumulated list to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatal OutOfMemoryError.

        Scheduler:
        toList does not operate by default on a particular Scheduler.
        Parameters:
        capacityHint - the number of elements expected from the current Observable
        Returns:
        the new Single instance
        Throws:
        java.lang.IllegalArgumentException - if capacityHint is non-positive
        See Also:
        ReactiveX operators documentation: To
      • toList

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull U extends java.util.Collection<? super @NonNull T>> @NonNull Single<U> toList​(@NonNull
                                                                                                             @NonNull Supplier<@NonNull U> collectionSupplier)
        Returns a Single that emits a single item, a Collection (subclass) composed of all the items emitted by the finite upstream Observable.

        Normally, an ObservableSource that returns multiple items will do so by invoking its Observer's onNext method for each such item. You can change this behavior by having the operator to compose a collection of all of these items and then to invoke the SingleObserver's onSuccess method once, passing it the entire collection, by calling the Observable's toList method prior to calling its subscribe() method.

        Note that this operator requires the upstream to signal onComplete for the accumulated collection to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatal OutOfMemoryError.

        Scheduler:
        toList does not operate by default on a particular Scheduler.
        Type Parameters:
        U - the subclass of a collection of Ts
        Parameters:
        collectionSupplier - the Supplier returning the collection (for each individual Observer) to be filled in
        Returns:
        the new Single instance
        Throws:
        java.lang.NullPointerException - if collectionSupplier is null
        See Also:
        ReactiveX operators documentation: To
      • toMap

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull K> @NonNull Single<@NonNull java.util.Map<K,​T>> toMap​(@NonNull
                                                                                           @NonNull Function<? super @NonNull T,​? extends @NonNull K> keySelector)
        Returns a Single that emits a single HashMap containing all items emitted by the current and finite Observable, mapped by the keys returned by a specified keySelector function.

        If more than one source item maps to the same key, the HashMap will contain the latest of those items.

        Note that this operator requires the upstream to signal onComplete for the accumulated HashMap to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatal OutOfMemoryError.

        Scheduler:
        toMap does not operate by default on a particular Scheduler.
        Type Parameters:
        K - the key type of the Map
        Parameters:
        keySelector - the function that extracts the key from a source item to be used in the HashMap
        Returns:
        the new Single instance
        Throws:
        java.lang.NullPointerException - if keySelector is null
        See Also:
        ReactiveX operators documentation: To
      • toMap

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull K,​@NonNull V> @NonNull Single<java.util.Map<K,​V>> toMap​(@NonNull
                                                                                                   @NonNull Function<? super @NonNull T,​? extends @NonNull K> keySelector,
                                                                                                   @NonNull
                                                                                                   @NonNull Function<? super @NonNull T,​? extends @NonNull V> valueSelector)
        Returns a Single that emits a single HashMap containing values corresponding to items emitted by the current and finite Observable, mapped by the keys and values returned by the given selector functions.

        If more than one source item maps to the same key, the HashMap will contain a single entry that corresponds to the latest of those items.

        Note that this operator requires the upstream to signal onComplete for the accumulated HashMap to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatal OutOfMemoryError.

        Scheduler:
        toMap does not operate by default on a particular Scheduler.
        Type Parameters:
        K - the key type of the HashMap
        V - the value type of the HashMap
        Parameters:
        keySelector - the function that extracts the key from a source item to be used in the HashMap
        valueSelector - the function that extracts the value from a source item to be used in the HashMap
        Returns:
        the new Single instance
        Throws:
        java.lang.NullPointerException - if keySelector or valueSelector is null
        See Also:
        ReactiveX operators documentation: To
      • toMap

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull K,​@NonNull V> @NonNull Single<java.util.Map<K,​V>> toMap​(@NonNull
                                                                                                   @NonNull Function<? super @NonNull T,​? extends @NonNull K> keySelector,
                                                                                                   @NonNull
                                                                                                   @NonNull Function<? super @NonNull T,​? extends @NonNull V> valueSelector,
                                                                                                   @NonNull
                                                                                                   @NonNull Supplier<? extends java.util.Map<@NonNull K,​@NonNull V>> mapSupplier)
        Returns a Single that emits a single Map (subclass), returned by a specified mapFactory function, that contains keys and values extracted from the items, via selector functions, emitted by the current and finite Observable.

        Note that this operator requires the upstream to signal onComplete for the accumulated Map to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatal OutOfMemoryError.

        Scheduler:
        toMap does not operate by default on a particular Scheduler.
        Type Parameters:
        K - the key type of the Map
        V - the value type of the Map
        Parameters:
        keySelector - the function that extracts the key from a source item to be used in the Map
        valueSelector - the function that extracts the value from the source items to be used as value in the Map
        mapSupplier - the function that returns a Map instance to be used
        Returns:
        the new Single instance
        Throws:
        java.lang.NullPointerException - if keySelector, valueSelector or mapSupplier is null
        See Also:
        ReactiveX operators documentation: To
      • toMultimap

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull K> @NonNull Single<@NonNull java.util.Map<K,​java.util.Collection<T>>> toMultimap​(@NonNull
                                                                                                                      @NonNull Function<? super @NonNull T,​? extends @NonNull K> keySelector)
        Returns a Single that emits a single HashMap that contains an ArrayList of items emitted by the current and finite Observable keyed by a specified keySelector function.

        Note that this operator requires the upstream to signal onComplete for the accumulated HashMap to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatal OutOfMemoryError.

        Scheduler:
        toMultimap does not operate by default on a particular Scheduler.
        Type Parameters:
        K - the key type of the HashMap
        Parameters:
        keySelector - the function that extracts the key from the source items to be used as key in the HashMap
        Returns:
        the new Single instance
        Throws:
        java.lang.NullPointerException - if keySelector is null
        See Also:
        ReactiveX operators documentation: To
      • toMultimap

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull K,​@NonNull V> @NonNull Single<@NonNull java.util.Map<K,​java.util.Collection<V>>> toMultimap​(@NonNull
                                                                                                                                       @NonNull Function<? super @NonNull T,​? extends @NonNull K> keySelector,
                                                                                                                                       Function<? super @NonNull T,​? extends @NonNull V> valueSelector)
        Returns a Single that emits a single HashMap that contains an ArrayList of values extracted by a specified valueSelector function from items emitted by the current and finite Observable, keyed by a specified keySelector function.

        Note that this operator requires the upstream to signal onComplete for the accumulated HashMap to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatal OutOfMemoryError.

        Scheduler:
        toMultimap does not operate by default on a particular Scheduler.
        Type Parameters:
        K - the key type of the HashMap
        V - the value type of the HashMap
        Parameters:
        keySelector - the function that extracts a key from the source items to be used as key in the HashMap
        valueSelector - the function that extracts a value from the source items to be used as value in the HashMap
        Returns:
        the new Single instance
        Throws:
        java.lang.NullPointerException - if keySelector or valueSelector is null
        See Also:
        ReactiveX operators documentation: To
      • toMultimap

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull K,​@NonNull V> @NonNull Single<@NonNull java.util.Map<K,​java.util.Collection<V>>> toMultimap​(@NonNull
                                                                                                                                       @NonNull Function<? super @NonNull T,​? extends @NonNull K> keySelector,
                                                                                                                                       @NonNull
                                                                                                                                       @NonNull Function<? super @NonNull T,​? extends @NonNull V> valueSelector,
                                                                                                                                       @NonNull
                                                                                                                                       @NonNull Supplier<? extends java.util.Map<@NonNull K,​java.util.Collection<@NonNull V>>> mapSupplier,
                                                                                                                                       @NonNull
                                                                                                                                       @NonNull Function<? super @NonNull K,​? extends java.util.Collection<? super @NonNull V>> collectionFactory)
        Returns a Single that emits a single Map (subclass), returned by a specified mapFactory function, that contains a custom Collection of values, extracted by a specified valueSelector function from items emitted by the current and finite Observable, and keyed by the keySelector function.

        Note that this operator requires the upstream to signal onComplete for the accumulated Map to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatal OutOfMemoryError.

        Scheduler:
        toMultimap does not operate by default on a particular Scheduler.
        Type Parameters:
        K - the key type of the Map
        V - the value type of the Map
        Parameters:
        keySelector - the function that extracts a key from the source items to be used as the key in the Map
        valueSelector - the function that extracts a value from the source items to be used as the value in the Map
        mapSupplier - the function that returns a Map instance to be used
        collectionFactory - the function that returns a Collection instance for a particular key to be used in the Map
        Returns:
        the new Single instance
        Throws:
        java.lang.NullPointerException - if keySelector, valueSelector, mapSupplier or collectionFactory is null
        See Also:
        ReactiveX operators documentation: To
      • toMultimap

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull K,​@NonNull V> @NonNull Single<@NonNull java.util.Map<K,​java.util.Collection<V>>> toMultimap​(@NonNull
                                                                                                                                       @NonNull Function<? super @NonNull T,​? extends @NonNull K> keySelector,
                                                                                                                                       @NonNull
                                                                                                                                       @NonNull Function<? super @NonNull T,​? extends @NonNull V> valueSelector,
                                                                                                                                       @NonNull
                                                                                                                                       @NonNull Supplier<java.util.Map<@NonNull K,​java.util.Collection<@NonNull V>>> mapSupplier)
        Returns a Single that emits a single Map (subclass), returned by a specified mapFactory function, that contains an ArrayList of values, extracted by a specified valueSelector function from items emitted by the current and finite Observable and keyed by the keySelector function.

        Note that this operator requires the upstream to signal onComplete for the accumulated Map to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatal OutOfMemoryError.

        Scheduler:
        toMultimap does not operate by default on a particular Scheduler.
        Type Parameters:
        K - the key type of the Map
        V - the value type of the Map
        Parameters:
        keySelector - the function that extracts a key from the source items to be used as the key in the Map
        valueSelector - the function that extracts a value from the source items to be used as the value in the Map
        mapSupplier - the function that returns a Map instance to be used
        Returns:
        the new Single instance
        Throws:
        java.lang.NullPointerException - if keySelector, valueSelector or mapSupplier is null
        See Also:
        ReactiveX operators documentation: To
      • toSortedList

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Single<@NonNull java.util.List<T>> toSortedList()
        Returns a Single that emits a List that contains the items emitted by the current and finite Observable, in a sorted order. Each item emitted by the current Observable must implement Comparable with respect to all other items in the sequence.

        If any item emitted by the current Observable does not implement Comparable with respect to all other items emitted by the current Observable, no items will be emitted and the sequence is terminated with a ClassCastException.

        Note that this operator requires the upstream to signal onComplete for the accumulated List to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatal OutOfMemoryError.

        Scheduler:
        toSortedList does not operate by default on a particular Scheduler.
        Returns:
        the new Single instance
        See Also:
        ReactiveX operators documentation: To, toSortedList(int), toSortedList(Comparator)
      • toSortedList

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Single<@NonNull java.util.List<T>> toSortedList​(@NonNull
                                                                              @NonNull java.util.Comparator<? super @NonNull T> comparator)
        Returns a Single that emits a List that contains the items emitted by the current and finite Observable, in a sorted order based on a specified comparison function.

        Note that this operator requires the upstream to signal onComplete for the accumulated List to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatal OutOfMemoryError.

        Scheduler:
        toSortedList does not operate by default on a particular Scheduler.
        Parameters:
        comparator - a function that compares two items emitted by the current Observable and returns an int that indicates their sort order
        Returns:
        the new Single instance
        Throws:
        java.lang.NullPointerException - if comparator is null
        See Also:
        ReactiveX operators documentation: To
      • toSortedList

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Single<@NonNull java.util.List<T>> toSortedList​(@NonNull
                                                                              @NonNull java.util.Comparator<? super @NonNull T> comparator,
                                                                              int capacityHint)
        Returns a Single that emits a List that contains the items emitted by the current and finite Observable, in a sorted order based on a specified comparison function.

        Note that this operator requires the upstream to signal onComplete for the accumulated List to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatal OutOfMemoryError.

        Scheduler:
        toSortedList does not operate by default on a particular Scheduler.
        Parameters:
        comparator - a function that compares two items emitted by the current Observable and returns an int that indicates their sort order
        capacityHint - the initial capacity of the List used to accumulate items before sorting
        Returns:
        the new Single instance
        Throws:
        java.lang.NullPointerException - if comparator is null
        java.lang.IllegalArgumentException - if capacityHint is non-positive
        Since:
        2.0
        See Also:
        ReactiveX operators documentation: To
      • toSortedList

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Single<@NonNull java.util.List<T>> toSortedList​(int capacityHint)
        Returns a Single that emits a List that contains the items emitted by the current and finite Observable, in a sorted order. Each item emitted by the current Observable must implement Comparable with respect to all other items in the sequence.

        If any item emitted by the current Observable does not implement Comparable with respect to all other items emitted by the current Observable, no items will be emitted and the sequence is terminated with a ClassCastException.

        Note that this operator requires the upstream to signal onComplete for the accumulated List to be emitted. Sources that are infinite and never complete will never emit anything through this operator and an infinite source may lead to a fatal OutOfMemoryError.

        Scheduler:
        toSortedList does not operate by default on a particular Scheduler.
        Parameters:
        capacityHint - the initial capacity of the List used to accumulate items before sorting
        Returns:
        the new Single instance
        Throws:
        java.lang.IllegalArgumentException - if capacityHint is non-positive
        Since:
        2.0
        See Also:
        ReactiveX operators documentation: To, toSortedList(Comparator, int)
      • window

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<Observable<T>> window​(long count)
        Returns an Observable that emits windows of items it collects from the current Observable. The resulting Observable emits connected, non-overlapping windows, each containing count items. When the current Observable completes or encounters an error, the resulting Observable emits the current window and propagates the notification from the current Observable.

        Scheduler:
        This version of window does not operate by default on a particular Scheduler.
        Parameters:
        count - the maximum size of each window before it should be emitted
        Returns:
        the new Observable instance
        Throws:
        java.lang.IllegalArgumentException - if count is non-positive
        See Also:
        ReactiveX operators documentation: Window
      • window

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<Observable<T>> window​(long count,
                                                               long skip)
        Returns an Observable that emits windows of items it collects from the current Observable. The resulting Observable emits windows every skip items, each containing no more than count items. When the current Observable completes or encounters an error, the resulting Observable emits the current window and propagates the notification from the current Observable.

        Scheduler:
        This version of window does not operate by default on a particular Scheduler.
        Parameters:
        count - the maximum size of each window before it should be emitted
        skip - how many items need to be skipped before starting a new window. Note that if skip and count are equal this is the same operation as window(long).
        Returns:
        the new Observable instance
        Throws:
        java.lang.IllegalArgumentException - if count or skip is non-positive
        See Also:
        ReactiveX operators documentation: Window
      • window

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull Observable<Observable<T>> window​(long count,
                                                               long skip,
                                                               int bufferSize)
        Returns an Observable that emits windows of items it collects from the current Observable. The resulting Observable emits windows every skip items, each containing no more than count items. When the current Observable completes or encounters an error, the resulting Observable emits the current window and propagates the notification from the current Observable.

        Scheduler:
        This version of window does not operate by default on a particular Scheduler.
        Parameters:
        count - the maximum size of each window before it should be emitted
        skip - how many items need to be skipped before starting a new window. Note that if skip and count are equal this is the same operation as window(long).
        bufferSize - the capacity hint for the buffer in the inner windows
        Returns:
        the new Observable instance
        Throws:
        java.lang.IllegalArgumentException - if count, skip or bufferSize is non-positive
        See Also:
        ReactiveX operators documentation: Window
      • window

        @CheckReturnValue
        @SchedulerSupport("io.reactivex:computation")
        @NonNull
        public final @NonNull Observable<Observable<T>> window​(long timespan,
                                                               long timeskip,
                                                               @NonNull
                                                               @NonNull java.util.concurrent.TimeUnit unit)
        Returns an Observable that emits windows of items it collects from the current Observable. The resulting Observable starts a new window periodically, as determined by the timeskip argument. It emits each window after a fixed timespan, specified by the timespan argument. When the current Observable completes or encounters an error, the resulting Observable emits the current window and propagates the notification from the current Observable.

        Note that ignoring windows or subscribing later (i.e., on another thread) will result in so-called window abandonment where a window may not contain any elements. In this case, subsequent elements will be dropped until the condition for the next window boundary is satisfied. The behavior is a trade-off for ensuring upstream cancellation can happen under some race conditions.

        Scheduler:
        This version of window operates by default on the computation Scheduler.
        Parameters:
        timespan - the period of time each window collects items before it should be emitted
        timeskip - the period of time after which a new window will be created
        unit - the unit of time that applies to the timespan and timeskip arguments
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit is null
        java.lang.IllegalArgumentException - if timespan or timeskip is non-positive
        See Also:
        ReactiveX operators documentation: Window
      • window

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<Observable<T>> window​(long timespan,
                                                               long timeskip,
                                                               @NonNull
                                                               @NonNull java.util.concurrent.TimeUnit unit,
                                                               @NonNull
                                                               @NonNull Scheduler scheduler)
        Returns an Observable that emits windows of items it collects from the current Observable. The resulting Observable starts a new window periodically, as determined by the timeskip argument. It emits each window after a fixed timespan, specified by the timespan argument. When the current Observable completes or encounters an error, the resulting Observable emits the current window and propagates the notification from the current Observable.

        Note that ignoring windows or subscribing later (i.e., on another thread) will result in so-called window abandonment where a window may not contain any elements. In this case, subsequent elements will be dropped until the condition for the next window boundary is satisfied. The behavior is a trade-off for ensuring upstream cancellation can happen under some race conditions.

        Scheduler:
        You specify which Scheduler this operator will use.
        Parameters:
        timespan - the period of time each window collects items before it should be emitted
        timeskip - the period of time after which a new window will be created
        unit - the unit of time that applies to the timespan and timeskip arguments
        scheduler - the Scheduler to use when determining the end and start of a window
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null
        java.lang.IllegalArgumentException - if timespan or timeskip is non-positive
        See Also:
        ReactiveX operators documentation: Window
      • window

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<Observable<T>> window​(long timespan,
                                                               long timeskip,
                                                               @NonNull
                                                               @NonNull java.util.concurrent.TimeUnit unit,
                                                               @NonNull
                                                               @NonNull Scheduler scheduler,
                                                               int bufferSize)
        Returns an Observable that emits windows of items it collects from the current Observable. The resulting Observable starts a new window periodically, as determined by the timeskip argument. It emits each window after a fixed timespan, specified by the timespan argument. When the current Observable completes or encounters an error, the resulting Observable emits the current window and propagates the notification from the current Observable.

        Note that ignoring windows or subscribing later (i.e., on another thread) will result in so-called window abandonment where a window may not contain any elements. In this case, subsequent elements will be dropped until the condition for the next window boundary is satisfied. The behavior is a trade-off for ensuring upstream cancellation can happen under some race conditions.

        Scheduler:
        You specify which Scheduler this operator will use.
        Parameters:
        timespan - the period of time each window collects items before it should be emitted
        timeskip - the period of time after which a new window will be created
        unit - the unit of time that applies to the timespan and timeskip arguments
        scheduler - the Scheduler to use when determining the end and start of a window
        bufferSize - the capacity hint for the buffer in the inner windows
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null
        java.lang.IllegalArgumentException - if timespan, timeskip or bufferSize is non-positive
        See Also:
        ReactiveX operators documentation: Window
      • window

        @CheckReturnValue
        @SchedulerSupport("io.reactivex:computation")
        @NonNull
        public final @NonNull Observable<Observable<T>> window​(long timespan,
                                                               @NonNull
                                                               @NonNull java.util.concurrent.TimeUnit unit)
        Returns an Observable that emits windows of items it collects from the current Observable. The resulting Observable emits connected, non-overlapping windows, each of a fixed duration specified by the timespan argument. When the current Observable completes or encounters an error, the resulting Observable emits the current window and propagates the notification from the current Observable.

        Note that ignoring windows or subscribing later (i.e., on another thread) will result in so-called window abandonment where a window may not contain any elements. In this case, subsequent elements will be dropped until the condition for the next window boundary is satisfied. The behavior is a trade-off for ensuring upstream cancellation can happen under some race conditions.

        Scheduler:
        This version of window operates by default on the computation Scheduler.
        Parameters:
        timespan - the period of time each window collects items before it should be emitted and replaced with a new window
        unit - the unit of time that applies to the timespan argument
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit is null
        See Also:
        ReactiveX operators documentation: Window
      • window

        @CheckReturnValue
        @SchedulerSupport("io.reactivex:computation")
        @NonNull
        public final @NonNull Observable<Observable<T>> window​(long timespan,
                                                               @NonNull
                                                               @NonNull java.util.concurrent.TimeUnit unit,
                                                               long count)
        Returns an Observable that emits windows of items it collects from the current Observable. The resulting Observable emits connected, non-overlapping windows, each of a fixed duration as specified by the timespan argument or a maximum size as specified by the count argument (whichever is reached first). When the current Observable completes or encounters an error, the resulting Observable emits the current window and propagates the notification from the current Observable.

        Note that ignoring windows or subscribing later (i.e., on another thread) will result in so-called window abandonment where a window may not contain any elements. In this case, subsequent elements will be dropped until the condition for the next window boundary is satisfied. The behavior is a trade-off for ensuring upstream cancellation can happen under some race conditions.

        Scheduler:
        This version of window operates by default on the computation Scheduler.
        Parameters:
        timespan - the period of time each window collects items before it should be emitted and replaced with a new window
        unit - the unit of time that applies to the timespan argument
        count - the maximum size of each window before it should be emitted
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit is null
        java.lang.IllegalArgumentException - if count is non-positive
        See Also:
        ReactiveX operators documentation: Window
      • window

        @CheckReturnValue
        @SchedulerSupport("io.reactivex:computation")
        @NonNull
        public final @NonNull Observable<Observable<T>> window​(long timespan,
                                                               @NonNull
                                                               @NonNull java.util.concurrent.TimeUnit unit,
                                                               long count,
                                                               boolean restart)
        Returns an Observable that emits windows of items it collects from the current Observable. The resulting Observable emits connected, non-overlapping windows, each of a fixed duration as specified by the timespan argument or a maximum size as specified by the count argument (whichever is reached first). When the current Observable completes or encounters an error, the resulting Observable emits the current window and propagates the notification from the current Observable.

        Note that ignoring windows or subscribing later (i.e., on another thread) will result in so-called window abandonment where a window may not contain any elements. In this case, subsequent elements will be dropped until the condition for the next window boundary is satisfied. The behavior is a trade-off for ensuring upstream cancellation can happen under some race conditions.

        Scheduler:
        This version of window operates by default on the computation Scheduler.
        Parameters:
        timespan - the period of time each window collects items before it should be emitted and replaced with a new window
        unit - the unit of time that applies to the timespan argument
        count - the maximum size of each window before it should be emitted
        restart - if true, when a window reaches the capacity limit, the timer is restarted as well
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit is null
        java.lang.IllegalArgumentException - if count is non-positive
        See Also:
        ReactiveX operators documentation: Window
      • window

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<Observable<T>> window​(long timespan,
                                                               @NonNull
                                                               @NonNull java.util.concurrent.TimeUnit unit,
                                                               @NonNull
                                                               @NonNull Scheduler scheduler)
        Returns an Observable that emits windows of items it collects from the current Observable. The resulting Observable emits connected, non-overlapping windows, each of a fixed duration as specified by the timespan argument. When the current Observable completes or encounters an error, the resulting Observable emits the current window and propagates the notification from the current Observable.

        Note that ignoring windows or subscribing later (i.e., on another thread) will result in so-called window abandonment where a window may not contain any elements. In this case, subsequent elements will be dropped until the condition for the next window boundary is satisfied. The behavior is a trade-off for ensuring upstream cancellation can happen under some race conditions.

        Scheduler:
        You specify which Scheduler this operator will use.
        Parameters:
        timespan - the period of time each window collects items before it should be emitted and replaced with a new window
        unit - the unit of time which applies to the timespan argument
        scheduler - the Scheduler to use when determining the end and start of a window
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null
        See Also:
        ReactiveX operators documentation: Window
      • window

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<Observable<T>> window​(long timespan,
                                                               @NonNull
                                                               @NonNull java.util.concurrent.TimeUnit unit,
                                                               @NonNull
                                                               @NonNull Scheduler scheduler,
                                                               long count)
        Returns an Observable that emits windows of items it collects from the current Observable. The resulting Observable emits connected, non-overlapping windows, each of a fixed duration specified by the timespan argument or a maximum size specified by the count argument (whichever is reached first). When the current Observable completes or encounters an error, the resulting Observable emits the current window and propagates the notification from the current Observable.

        Note that ignoring windows or subscribing later (i.e., on another thread) will result in so-called window abandonment where a window may not contain any elements. In this case, subsequent elements will be dropped until the condition for the next window boundary is satisfied. The behavior is a trade-off for ensuring upstream cancellation can happen under some race conditions.

        Scheduler:
        You specify which Scheduler this operator will use.
        Parameters:
        timespan - the period of time each window collects items before it should be emitted and replaced with a new window
        unit - the unit of time which applies to the timespan argument
        count - the maximum size of each window before it should be emitted
        scheduler - the Scheduler to use when determining the end and start of a window
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null
        java.lang.IllegalArgumentException - if count is non-positive
        See Also:
        ReactiveX operators documentation: Window
      • window

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<Observable<T>> window​(long timespan,
                                                               @NonNull
                                                               @NonNull java.util.concurrent.TimeUnit unit,
                                                               @NonNull
                                                               @NonNull Scheduler scheduler,
                                                               long count,
                                                               boolean restart)
        Returns an Observable that emits windows of items it collects from the current Observable. The resulting Observable emits connected, non-overlapping windows, each of a fixed duration specified by the timespan argument or a maximum size specified by the count argument (whichever is reached first). When the current Observable completes or encounters an error, the resulting Observable emits the current window and propagates the notification from the current Observable.

        Note that ignoring windows or subscribing later (i.e., on another thread) will result in so-called window abandonment where a window may not contain any elements. In this case, subsequent elements will be dropped until the condition for the next window boundary is satisfied. The behavior is a trade-off for ensuring upstream cancellation can happen under some race conditions.

        Scheduler:
        You specify which Scheduler this operator will use.
        Parameters:
        timespan - the period of time each window collects items before it should be emitted and replaced with a new window
        unit - the unit of time which applies to the timespan argument
        count - the maximum size of each window before it should be emitted
        scheduler - the Scheduler to use when determining the end and start of a window
        restart - if true, when a window reaches the capacity limit, the timer is restarted as well
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null
        java.lang.IllegalArgumentException - if count is non-positive
        See Also:
        ReactiveX operators documentation: Window
      • window

        @CheckReturnValue
        @SchedulerSupport("custom")
        @NonNull
        public final @NonNull Observable<Observable<T>> window​(long timespan,
                                                               @NonNull
                                                               @NonNull java.util.concurrent.TimeUnit unit,
                                                               @NonNull
                                                               @NonNull Scheduler scheduler,
                                                               long count,
                                                               boolean restart,
                                                               int bufferSize)
        Returns an Observable that emits windows of items it collects from the current Observable. The resulting Observable emits connected, non-overlapping windows, each of a fixed duration specified by the timespan argument or a maximum size specified by the count argument (whichever is reached first). When the current Observable completes or encounters an error, the resulting Observable emits the current window and propagates the notification from the current Observable.

        Note that ignoring windows or subscribing later (i.e., on another thread) will result in so-called window abandonment where a window may not contain any elements. In this case, subsequent elements will be dropped until the condition for the next window boundary is satisfied. The behavior is a trade-off for ensuring upstream cancellation can happen under some race conditions.

        Scheduler:
        You specify which Scheduler this operator will use.
        Parameters:
        timespan - the period of time each window collects items before it should be emitted and replaced with a new window
        unit - the unit of time which applies to the timespan argument
        count - the maximum size of each window before it should be emitted
        scheduler - the Scheduler to use when determining the end and start of a window
        restart - if true, when a window reaches the capacity limit, the timer is restarted as well
        bufferSize - the capacity hint for the buffer in the inner windows
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if unit or scheduler is null
        java.lang.IllegalArgumentException - if count or bufferSize is non-positive
        See Also:
        ReactiveX operators documentation: Window
      • window

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull B> @NonNull Observable<Observable<T>> window​(@NonNull
                                                                            @NonNull ObservableSource<@NonNull B> boundaryIndicator)
        Returns an Observable that emits non-overlapping windows of items it collects from the current Observable where the boundary of each window is determined by the items emitted from a specified boundary-governing ObservableSource.

        Note that ignoring windows or subscribing later (i.e., on another thread) will result in so-called window abandonment where a window may not contain any elements. In this case, subsequent elements will be dropped until the condition for the next window boundary is satisfied. The behavior is a trade-off for ensuring upstream cancellation can happen under some race conditions.

        Scheduler:
        This version of window does not operate by default on a particular Scheduler.
        Type Parameters:
        B - the window element type (ignored)
        Parameters:
        boundaryIndicator - an ObservableSource whose emitted items close and open windows
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if boundaryIndicator is null
        See Also:
        ReactiveX operators documentation: Window
      • window

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull B> @NonNull Observable<Observable<T>> window​(@NonNull
                                                                            @NonNull ObservableSource<@NonNull B> boundaryIndicator,
                                                                            int bufferSize)
        Returns an Observable that emits non-overlapping windows of items it collects from the current Observable where the boundary of each window is determined by the items emitted from a specified boundary-governing ObservableSource.

        Note that ignoring windows or subscribing later (i.e., on another thread) will result in so-called window abandonment where a window may not contain any elements. In this case, subsequent elements will be dropped until the condition for the next window boundary is satisfied. The behavior is a trade-off for ensuring upstream cancellation can happen under some race conditions.

        Scheduler:
        This version of window does not operate by default on a particular Scheduler.
        Type Parameters:
        B - the window element type (ignored)
        Parameters:
        boundaryIndicator - an ObservableSource whose emitted items close and open windows
        bufferSize - the capacity hint for the buffer in the inner windows
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if boundaryIndicator is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        See Also:
        ReactiveX operators documentation: Window
      • window

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull U,​@NonNull V> @NonNull Observable<Observable<T>> window​(@NonNull
                                                                                             @NonNull ObservableSource<@NonNull U> openingIndicator,
                                                                                             @NonNull
                                                                                             @NonNull Function<? super @NonNull U,​? extends ObservableSource<@NonNull V>> closingIndicator)
        Returns an Observable that emits windows of items it collects from the current Observable. The resulting Observable emits windows that contain those items emitted by the current Observable between the time when the openingIndicator ObservableSource emits an item and when the ObservableSource returned by closingIndicator emits an item.

        Note that ignoring windows or subscribing later (i.e., on another thread) will result in so-called window abandonment where a window may not contain any elements. In this case, subsequent elements will be dropped until the condition for the next window boundary is satisfied. The behavior is a trade-off for ensuring upstream cancellation can happen under some race conditions.

        Scheduler:
        This version of window does not operate by default on a particular Scheduler.
        Type Parameters:
        U - the element type of the window-opening ObservableSource
        V - the element type of the window-closing ObservableSources
        Parameters:
        openingIndicator - an ObservableSource that, when it emits an item, causes another window to be created
        closingIndicator - a Function that produces an ObservableSource for every window created. When this indicator ObservableSource emits an item, the associated window is completed
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if openingIndicator or closingIndicator is null
        See Also:
        ReactiveX operators documentation: Window
      • window

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull U,​@NonNull V> @NonNull Observable<Observable<T>> window​(@NonNull
                                                                                             @NonNull ObservableSource<@NonNull U> openingIndicator,
                                                                                             @NonNull
                                                                                             @NonNull Function<? super @NonNull U,​? extends ObservableSource<@NonNull V>> closingIndicator,
                                                                                             int bufferSize)
        Returns an Observable that emits windows of items it collects from the current Observable. The resulting Observable emits windows that contain those items emitted by the current Observable between the time when the openingIndicator ObservableSource emits an item and when the ObservableSource returned by closingIndicator emits an item.

        Note that ignoring windows or subscribing later (i.e., on another thread) will result in so-called window abandonment where a window may not contain any elements. In this case, subsequent elements will be dropped until the condition for the next window boundary is satisfied. The behavior is a trade-off for ensuring upstream cancellation can happen under some race conditions.

        Scheduler:
        This version of window does not operate by default on a particular Scheduler.
        Type Parameters:
        U - the element type of the window-opening ObservableSource
        V - the element type of the window-closing ObservableSources
        Parameters:
        openingIndicator - an ObservableSource that, when it emits an item, causes another window to be created
        closingIndicator - a Function that produces an ObservableSource for every window created. When this indicator ObservableSource emits an item, the associated window is completed
        bufferSize - the capacity hint for the buffer in the inner windows
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if openingIndicator or closingIndicator is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        See Also:
        ReactiveX operators documentation: Window
      • withLatestFrom

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull U,​@NonNull R> @NonNull Observable<R> withLatestFrom​(@NonNull
                                                                                         @NonNull ObservableSource<? extends @NonNull U> other,
                                                                                         @NonNull
                                                                                         @NonNull BiFunction<? super @NonNull T,​? super @NonNull U,​? extends @NonNull R> combiner)
        Merges the specified ObservableSource into the current Observable sequence by using the resultSelector function only when the current Observable emits an item.

        Note that this operator doesn't emit anything until the other source has produced at least one value. The resulting emission only happens when the current Observable emits (and not when the other source emits, unlike combineLatest). If the other source doesn't produce any value and just completes, the sequence is completed immediately. If the upstream completes before the other source has produced at least one value, the sequence completes without emission.

        Scheduler:
        This operator, by default, doesn't run any particular Scheduler.
        Type Parameters:
        U - the element type of the other ObservableSource
        R - the result type of the combination
        Parameters:
        other - the other ObservableSource
        combiner - the function to call when the current Observable emits an item and the other ObservableSource has already emitted an item, to generate the item to be emitted by the resulting Observable
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if other or combiner is null
        Since:
        2.0
        See Also:
        ReactiveX operators documentation: CombineLatest
      • withLatestFrom

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull T1,​@NonNull T2,​@NonNull R> @NonNull Observable<R> withLatestFrom​(@NonNull
                                                                                                            @NonNull ObservableSource<@NonNull T1> source1,
                                                                                                            @NonNull
                                                                                                            @NonNull ObservableSource<@NonNull T2> source2,
                                                                                                            @NonNull
                                                                                                            @NonNull Function3<? super @NonNull T,​? super @NonNull T1,​? super @NonNull T2,​@NonNull R> combiner)
        Combines the value emission from the current Observable with the latest emissions from the other ObservableSources via a function to produce the output item.

        Note that this operator doesn't emit anything until all other sources have produced at least one value. The resulting emission only happens when the current Observable emits (and not when any of the other sources emit, unlike combineLatest). If a source doesn't produce any value and just completes, the sequence is completed immediately. If the upstream completes before all other sources have produced at least one value, the sequence completes without emission.

        Scheduler:
        This operator does not operate by default on a particular Scheduler.
        Type Parameters:
        T1 - the first other source's value type
        T2 - the second other source's value type
        R - the result value type
        Parameters:
        source1 - the first other ObservableSource
        source2 - the second other ObservableSource
        combiner - the function called with an array of values from each participating ObservableSource
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if source1, source2 or combiner is null
        Since:
        2.0
      • withLatestFrom

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull T1,​@NonNull T2,​@NonNull T3,​@NonNull R> @NonNull Observable<R> withLatestFrom​(@NonNull
                                                                                                                              @NonNull ObservableSource<@NonNull T1> source1,
                                                                                                                              @NonNull
                                                                                                                              @NonNull ObservableSource<@NonNull T2> source2,
                                                                                                                              @NonNull
                                                                                                                              @NonNull ObservableSource<@NonNull T3> source3,
                                                                                                                              @NonNull
                                                                                                                              @NonNull Function4<? super @NonNull T,​? super @NonNull T1,​? super @NonNull T2,​? super @NonNull T3,​@NonNull R> combiner)
        Combines the value emission from the current Observable with the latest emissions from the other ObservableSources via a function to produce the output item.

        Note that this operator doesn't emit anything until all other sources have produced at least one value. The resulting emission only happens when the current Observable emits (and not when any of the other sources emit, unlike combineLatest). If a source doesn't produce any value and just completes, the sequence is completed immediately. If the upstream completes before all other sources have produced at least one value, the sequence completes without emission.

        Scheduler:
        This operator does not operate by default on a particular Scheduler.
        Type Parameters:
        T1 - the first other source's value type
        T2 - the second other source's value type
        T3 - the third other source's value type
        R - the result value type
        Parameters:
        source1 - the first other ObservableSource
        source2 - the second other ObservableSource
        source3 - the third other ObservableSource
        combiner - the function called with an array of values from each participating ObservableSource
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if source1, source2, source3 or combiner is null
        Since:
        2.0
      • withLatestFrom

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull T1,​@NonNull T2,​@NonNull T3,​@NonNull T4,​@NonNull R> @NonNull Observable<R> withLatestFrom​(@NonNull
                                                                                                                                                @NonNull ObservableSource<@NonNull T1> source1,
                                                                                                                                                @NonNull
                                                                                                                                                @NonNull ObservableSource<@NonNull T2> source2,
                                                                                                                                                @NonNull
                                                                                                                                                @NonNull ObservableSource<@NonNull T3> source3,
                                                                                                                                                @NonNull
                                                                                                                                                @NonNull ObservableSource<@NonNull T4> source4,
                                                                                                                                                @NonNull
                                                                                                                                                @NonNull Function5<? super @NonNull T,​? super @NonNull T1,​? super @NonNull T2,​? super @NonNull T3,​? super @NonNull T4,​@NonNull R> combiner)
        Combines the value emission from the current Observable with the latest emissions from the other ObservableSources via a function to produce the output item.

        Note that this operator doesn't emit anything until all other sources have produced at least one value. The resulting emission only happens when the current Observable emits (and not when any of the other sources emit, unlike combineLatest). If a source doesn't produce any value and just completes, the sequence is completed immediately. If the upstream completes before all other sources have produced at least one value, the sequence completes without emission.

        Scheduler:
        This operator does not operate by default on a particular Scheduler.
        Type Parameters:
        T1 - the first other source's value type
        T2 - the second other source's value type
        T3 - the third other source's value type
        T4 - the fourth other source's value type
        R - the result value type
        Parameters:
        source1 - the first other ObservableSource
        source2 - the second other ObservableSource
        source3 - the third other ObservableSource
        source4 - the fourth other ObservableSource
        combiner - the function called with an array of values from each participating ObservableSource
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if source1, source2, source3, source4 or combiner is null
        Since:
        2.0
      • withLatestFrom

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> withLatestFrom​(@NonNull
                                                                        @NonNull ObservableSource<?>[] others,
                                                                        @NonNull
                                                                        @NonNull Function<? super java.lang.Object[],​@NonNull R> combiner)
        Combines the value emission from the current Observable with the latest emissions from the other ObservableSources via a function to produce the output item.

        Note that this operator doesn't emit anything until all other sources have produced at least one value. The resulting emission only happens when the current Observable emits (and not when any of the other sources emit, unlike combineLatest). If a source doesn't produce any value and just completes, the sequence is completed immediately. If the upstream completes before all other sources have produced at least one value, the sequence completes without emission.

        Scheduler:
        This operator does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the result value type
        Parameters:
        others - the array of other sources
        combiner - the function called with an array of values from each participating ObservableSource
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if others or combiner is null
        Since:
        2.0
      • withLatestFrom

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> withLatestFrom​(@NonNull
                                                                        @NonNull java.lang.Iterable<? extends ObservableSource<?>> others,
                                                                        @NonNull
                                                                        @NonNull Function<? super java.lang.Object[],​@NonNull R> combiner)
        Combines the value emission from the current Observable with the latest emissions from the other ObservableSources via a function to produce the output item.

        Note that this operator doesn't emit anything until all other sources have produced at least one value. The resulting emission only happens when the current Observable emits (and not when any of the other sources emit, unlike combineLatest). If a source doesn't produce any value and just completes, the sequence is completed immediately. If the upstream completes before all other sources have produced at least one value, the sequence completes without emission.

        Scheduler:
        This operator does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the result value type
        Parameters:
        others - the iterable of other sources
        combiner - the function called with an array of values from each participating ObservableSource
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if others or combiner is null
        Since:
        2.0
      • zipWith

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull U,​@NonNull R> @NonNull Observable<R> zipWith​(@NonNull
                                                                                  @NonNull java.lang.Iterable<@NonNull U> other,
                                                                                  @NonNull
                                                                                  @NonNull BiFunction<? super @NonNull T,​? super @NonNull U,​? extends @NonNull R> zipper)
        Returns an Observable that emits items that are the result of applying a specified function to pairs of values, one each from the current Observable and a specified Iterable sequence.

        Note that the other Iterable is evaluated as items are observed from the current Observable; it is not pre-consumed. This allows you to zip infinite streams on either side.

        Scheduler:
        zipWith does not operate by default on a particular Scheduler.
        Type Parameters:
        U - the type of items in the other Iterable
        R - the type of items emitted by the resulting Observable
        Parameters:
        other - the Iterable sequence
        zipper - a function that combines the pairs of items from the current Observable and the Iterable to generate the items to be emitted by the resulting Observable
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if other or zipper is null
        See Also:
        ReactiveX operators documentation: Zip
      • zipWith

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull U,​@NonNull R> @NonNull Observable<R> zipWith​(@NonNull
                                                                                  @NonNull ObservableSource<? extends @NonNull U> other,
                                                                                  @NonNull
                                                                                  @NonNull BiFunction<? super @NonNull T,​? super @NonNull U,​? extends @NonNull R> zipper)
        Returns an Observable that emits items that are the result of applying a specified function to pairs of values, one each from the current Observable and another specified ObservableSource.

        The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling doOnComplete()). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will dispose B immediately. For example:

        range(1, 5).doOnComplete(action1).zipWith(range(6, 5).doOnComplete(action2), (a, b) -> a + b)
        action1 will be called but action2 won't.
        To work around this termination property, use doOnDispose(Action) as well or use using() to do cleanup in case of completion or a dispose() call.
        Scheduler:
        zipWith does not operate by default on a particular Scheduler.
        Type Parameters:
        U - the type of items emitted by the other ObservableSource
        R - the type of items emitted by the resulting Observable
        Parameters:
        other - the other ObservableSource
        zipper - a function that combines the pairs of items from the current Observable and the other ObservableSource to generate the items to be emitted by the resulting Observable
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if other or zipper is null
        See Also:
        ReactiveX operators documentation: Zip
      • zipWith

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull U,​@NonNull R> @NonNull Observable<R> zipWith​(@NonNull
                                                                                  @NonNull ObservableSource<? extends @NonNull U> other,
                                                                                  @NonNull
                                                                                  @NonNull BiFunction<? super @NonNull T,​? super @NonNull U,​? extends @NonNull R> zipper,
                                                                                  boolean delayError)
        Returns an Observable that emits items that are the result of applying a specified function to pairs of values, one each from the current Observable and another specified ObservableSource.

        The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling doOnComplete()). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will dispose B immediately. For example:

        range(1, 5).doOnComplete(action1).zipWith(range(6, 5).doOnComplete(action2), (a, b) -> a + b)
        action1 will be called but action2 won't.
        To work around this termination property, use doOnDispose(Action) as well or use using() to do cleanup in case of completion or a dispose() call.
        Scheduler:
        zipWith does not operate by default on a particular Scheduler.
        Type Parameters:
        U - the type of items emitted by the other ObservableSource
        R - the type of items emitted by the resulting Observable
        Parameters:
        other - the other ObservableSource
        zipper - a function that combines the pairs of items from the current Observable and the other ObservableSource to generate the items to be emitted by the resulting Observable
        delayError - if true, errors from the current Observable or the other ObservableSource is delayed until both terminate
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if other or zipper is null
        Since:
        2.0
        See Also:
        ReactiveX operators documentation: Zip
      • zipWith

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull U,​@NonNull R> @NonNull Observable<R> zipWith​(@NonNull
                                                                                  @NonNull ObservableSource<? extends @NonNull U> other,
                                                                                  @NonNull
                                                                                  @NonNull BiFunction<? super @NonNull T,​? super @NonNull U,​? extends @NonNull R> zipper,
                                                                                  boolean delayError,
                                                                                  int bufferSize)
        Returns an Observable that emits items that are the result of applying a specified function to pairs of values, one each from the current Observable and another specified ObservableSource.

        The operator subscribes to its sources in order they are specified and completes eagerly if one of the sources is shorter than the rest while disposing the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling doOnComplete()). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will dispose B immediately. For example:

        range(1, 5).doOnComplete(action1).zipWith(range(6, 5).doOnComplete(action2), (a, b) -> a + b)
        action1 will be called but action2 won't.
        To work around this termination property, use doOnDispose(Action) as well or use using() to do cleanup in case of completion or a dispose() call.
        Scheduler:
        zipWith does not operate by default on a particular Scheduler.
        Type Parameters:
        U - the type of items emitted by the other ObservableSource
        R - the type of items emitted by the resulting Observable
        Parameters:
        other - the other ObservableSource
        zipper - a function that combines the pairs of items from the current Observable and the other ObservableSource to generate the items to be emitted by the resulting Observable
        bufferSize - the capacity hint for the buffer in the inner windows
        delayError - if true, errors from the current Observable or the other ObservableSource is delayed until both terminate
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if other or zipper is null
        java.lang.IllegalArgumentException - if bufferSize is non-positive
        Since:
        2.0
        See Also:
        ReactiveX operators documentation: Zip
      • test

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull TestObserver<T> test​(boolean dispose)
        Creates a TestObserver, optionally disposes it and then subscribes it to the current Observable.
        Scheduler:
        test does not operate by default on a particular Scheduler.
        Parameters:
        dispose - indicates if the TestObserver should be disposed before it is subscribed to the current Observable
        Returns:
        the new TestObserver instance
        Since:
        2.0
      • fromOptional

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T> @NonNull Observable<@NonNull T> fromOptional​(@NonNull
                                                                                @NonNull java.util.Optional<@NonNull T> optional)
        Converts the existing value of the provided optional into a just(Object) or an empty optional into an empty() Observable instance.

        Note that the operator takes an already instantiated optional reference and does not by any means create this original optional. If the optional is to be created per consumer upon subscription, use defer(Supplier) around fromOptional:

        
         Observable.defer(() -> Observable.fromOptional(createOptional()));
         
        Scheduler:
        fromOptional does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the element type of the optional value
        Parameters:
        optional - the optional value to convert into an Observable
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if optional is null
        Since:
        3.0.0
        See Also:
        just(Object), empty()
      • fromCompletionStage

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T> @NonNull Observable<@NonNull T> fromCompletionStage​(@NonNull
                                                                                       @NonNull java.util.concurrent.CompletionStage<@NonNull T> stage)
        Signals the completion value or error of the given (hot) CompletionStage-based asynchronous calculation.

        Note that the operator takes an already instantiated, running or terminated CompletionStage. If the CompletionStage is to be created per consumer upon subscription, use defer(Supplier) around fromCompletionStage:

        
         Observable.defer(() -> Observable.fromCompletionStage(createCompletionStage()));
         

        If the CompletionStage completes with null, a NullPointerException is signaled.

        Canceling the flow can't cancel the execution of the CompletionStage because CompletionStage itself doesn't support cancellation. Instead, the operator detaches from the CompletionStage.

        Scheduler:
        fromCompletionStage does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the element type of the CompletionStage
        Parameters:
        stage - the CompletionStage to convert to Observable and signal its terminal value or error
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if stage is null
        Since:
        3.0.0
      • fromStream

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public static <@NonNull T> @NonNull Observable<@NonNull T> fromStream​(@NonNull
                                                                              @NonNull java.util.stream.Stream<@NonNull T> stream)
        Converts a Stream into a finite Observable and emits its items in the sequence.

        The operator closes the Stream upon cancellation and when it terminates. The exceptions raised when closing a Stream are routed to the global error handler (RxJavaPlugins.onError(Throwable). If a Stream should not be closed, turn it into an Iterable and use fromIterable(Iterable):

        
         Stream<T> stream = ...
         Observable.fromIterable(stream::iterator);
         

        Note that Streams can be consumed only once; any subsequent attempt to consume a Stream will result in an IllegalStateException.

        Primitive streams are not supported and items have to be boxed manually (e.g., via IntStream.boxed()):

        
         IntStream intStream = IntStream.rangeClosed(1, 10);
         Observable.fromStream(intStream.boxed());
         

        Stream does not support concurrent usage so creating and/or consuming the same instance multiple times from multiple threads can lead to undefined behavior.

        Scheduler:
        fromStream does not operate by default on a particular Scheduler.
        Type Parameters:
        T - the element type of the source Stream
        Parameters:
        stream - the Stream of values to emit
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if stream is null
        Since:
        3.0.0
        See Also:
        fromIterable(Iterable)
      • mapOptional

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> mapOptional​(@NonNull
                                                                     @NonNull Function<? super @NonNull T,​@NonNull java.util.Optional<? extends @NonNull R>> mapper)
        Maps each upstream value into an Optional and emits the contained item if not empty.

        Scheduler:
        mapOptional does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the non-null output type
        Parameters:
        mapper - the function that receives the upstream item and should return a non-empty Optional to emit as the output or an empty Optional to skip to the next upstream value
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
        Since:
        3.0.0
        See Also:
        map(Function), filter(Predicate)
      • collect

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R,​@Nullable A> @NonNull Single<R> collect​(@NonNull
                                                                               @NonNull java.util.stream.Collector<? super @NonNull T,​@Nullable A,​@NonNull R> collector)
        Collects the finite upstream's values into a container via a Stream Collector callback set and emits it as the success result as a Single.

        Scheduler:
        collect does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the non-null result type
        A - the intermediate container type used for the accumulation
        Parameters:
        collector - the interface defining the container supplier, accumulator and finisher functions; see Collectors for some standard implementations
        Returns:
        the new Single instance
        Throws:
        java.lang.NullPointerException - if collector is null
        Since:
        3.0.0
        See Also:
        Collectors, collect(Supplier, BiConsumer)
      • firstStage

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull java.util.concurrent.CompletionStage<T> firstStage​(@Nullable
                                                                                 @NonNull T defaultItem)
        Signals the first upstream item (or the default item if the upstream is empty) via a CompletionStage.

        The upstream can be canceled by converting the resulting CompletionStage into CompletableFuture via CompletionStage.toCompletableFuture() and calling CompletableFuture.cancel(boolean) on it. The upstream will be also cancelled if the resulting CompletionStage is converted to and completed manually by CompletableFuture.complete(Object) or CompletableFuture.completeExceptionally(Throwable).

        CompletionStages don't have a notion of emptiness and allow nulls, therefore, one can either use a defaultItem of null or turn the flow into a sequence of Optionals and default to Optional.empty():

        
         CompletionStage<Optional<T>> stage = source.map(Optional::of).firstStage(Optional.empty());
         
        Scheduler:
        firstStage does not operate by default on a particular Scheduler.
        Parameters:
        defaultItem - the item to signal if the upstream is empty
        Returns:
        the new CompletionStage instance
        Throws:
        java.lang.NullPointerException - if defaultItem is null
        Since:
        3.0.0
        See Also:
        firstOrErrorStage()
      • singleStage

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull java.util.concurrent.CompletionStage<T> singleStage​(@Nullable
                                                                                  @NonNull T defaultItem)
        Signals the only expected upstream item (or the default item if the upstream is empty) or signals IllegalArgumentException if the upstream has more than one item via a CompletionStage.

        The upstream can be canceled by converting the resulting CompletionStage into CompletableFuture via CompletionStage.toCompletableFuture() and calling CompletableFuture.cancel(boolean) on it. The upstream will be also cancelled if the resulting CompletionStage is converted to and completed manually by CompletableFuture.complete(Object) or CompletableFuture.completeExceptionally(Throwable).

        CompletionStages don't have a notion of emptiness and allow nulls, therefore, one can either use a defaultItem of null or turn the flow into a sequence of Optionals and default to Optional.empty():

        
         CompletionStage<Optional<T>> stage = source.map(Optional::of).singleStage(Optional.empty());
         
        Scheduler:
        singleStage does not operate by default on a particular Scheduler.
        Parameters:
        defaultItem - the item to signal if the upstream is empty
        Returns:
        the new CompletionStage instance
        Throws:
        java.lang.NullPointerException - if defaultItem is null
        Since:
        3.0.0
        See Also:
        singleOrErrorStage()
      • lastStage

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull java.util.concurrent.CompletionStage<T> lastStage​(@Nullable
                                                                                @NonNull T defaultItem)
        Signals the last upstream item (or the default item if the upstream is empty) via a CompletionStage.

        The upstream can be canceled by converting the resulting CompletionStage into CompletableFuture via CompletionStage.toCompletableFuture() and calling CompletableFuture.cancel(boolean) on it. The upstream will be also cancelled if the resulting CompletionStage is converted to and completed manually by CompletableFuture.complete(Object) or CompletableFuture.completeExceptionally(Throwable).

        CompletionStages don't have a notion of emptiness and allow nulls, therefore, one can either use a defaultItem of null or turn the flow into a sequence of Optionals and default to Optional.empty():

        
         CompletionStage<Optional<T>> stage = source.map(Optional::of).lastStage(Optional.empty());
         
        Scheduler:
        lastStage does not operate by default on a particular Scheduler.
        Parameters:
        defaultItem - the item to signal if the upstream is empty
        Returns:
        the new CompletionStage instance
        Throws:
        java.lang.NullPointerException - if defaultItem is null
        Since:
        3.0.0
        See Also:
        lastOrErrorStage()
      • firstOrErrorStage

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull java.util.concurrent.CompletionStage<T> firstOrErrorStage()
        Signals the first upstream item or a NoSuchElementException if the upstream is empty via a CompletionStage.

        The upstream can be canceled by converting the resulting CompletionStage into CompletableFuture via CompletionStage.toCompletableFuture() and calling CompletableFuture.cancel(boolean) on it. The upstream will be also cancelled if the resulting CompletionStage is converted to and completed manually by CompletableFuture.complete(Object) or CompletableFuture.completeExceptionally(Throwable).

        Scheduler:
        firstOrErrorStage does not operate by default on a particular Scheduler.
        Returns:
        the new CompletionStage instance
        Since:
        3.0.0
        See Also:
        firstStage(Object)
      • singleOrErrorStage

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull java.util.concurrent.CompletionStage<T> singleOrErrorStage()
        Signals the only expected upstream item, a NoSuchElementException if the upstream is empty or signals IllegalArgumentException if the upstream has more than one item via a CompletionStage.

        The upstream can be canceled by converting the resulting CompletionStage into CompletableFuture via CompletionStage.toCompletableFuture() and calling CompletableFuture.cancel(boolean) on it. The upstream will be also cancelled if the resulting CompletionStage is converted to and completed manually by CompletableFuture.complete(Object) or CompletableFuture.completeExceptionally(Throwable).

        Scheduler:
        singleOrErrorStage does not operate by default on a particular Scheduler.
        Returns:
        the new CompletionStage instance
        Since:
        3.0.0
        See Also:
        singleStage(Object)
      • lastOrErrorStage

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull java.util.concurrent.CompletionStage<T> lastOrErrorStage()
        Signals the last upstream item or a NoSuchElementException if the upstream is empty via a CompletionStage.

        The upstream can be canceled by converting the resulting CompletionStage into CompletableFuture via CompletionStage.toCompletableFuture() and calling CompletableFuture.cancel(boolean) on it. The upstream will be also cancelled if the resulting CompletionStage is converted to and completed manually by CompletableFuture.complete(Object) or CompletableFuture.completeExceptionally(Throwable).

        Scheduler:
        lastOrErrorStage does not operate by default on a particular Scheduler.
        Returns:
        the new CompletionStage instance
        Since:
        3.0.0
        See Also:
        lastStage(Object)
      • blockingStream

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull java.util.stream.Stream<T> blockingStream()
        Creates a sequential Stream to consume or process the current Observable in a blocking manner via the Java Stream API.

        Cancellation of the upstream is done via BaseStream.close(), therefore, it is strongly recommended the consumption is performed within a try-with-resources construct:

        
         Observable<Integer> source = Observable.range(1, 10)
                .subscribeOn(Schedulers.computation());
        
         try (Stream<Integer> stream = source.blockingStream()) {
             stream.limit(3).forEach(System.out::println);
         }
         
        Scheduler:
        blockingStream does not operate by default on a particular Scheduler.
        Returns:
        the new Stream instance
        Since:
        3.0.0
        See Also:
        blockingStream(int)
      • blockingStream

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final @NonNull java.util.stream.Stream<T> blockingStream​(int capacityHint)
        Creates a sequential Stream to consume or process the current Observable in a blocking manner via the Java Stream API.

        Cancellation of the upstream is done via BaseStream.close(), therefore, it is strongly recommended the consumption is performed within a try-with-resources construct:

        
         Observable<Integer> source = Observable.range(1, 10)
                .subscribeOn(Schedulers.computation());
        
         try (Stream<Integer> stream = source.blockingStream(4)) {
             stream.limit(3).forEach(System.out::println);
         }
         
        Scheduler:
        blockingStream does not operate by default on a particular Scheduler.
        Parameters:
        capacityHint - the expected number of items to be buffered
        Returns:
        the new Stream instance
        Throws:
        java.lang.IllegalArgumentException - if capacityHint is non-positive
        Since:
        3.0.0
      • concatMapStream

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> concatMapStream​(@NonNull
                                                                         @NonNull Function<? super @NonNull T,​? extends java.util.stream.Stream<? extends @NonNull R>> mapper)
        Maps each upstream item into a Stream and emits the Stream's items to the downstream in a sequential fashion.

        Due to the blocking and sequential nature of Java Streams, the streams are mapped and consumed in a sequential fashion without interleaving (unlike a more general flatMap(Function)). Therefore, flatMapStream and concatMapStream are identical operators and are provided as aliases.

        The operator closes the Stream upon cancellation and when it terminates. The exceptions raised when closing a Stream are routed to the global error handler (RxJavaPlugins.onError(Throwable). If a Stream should not be closed, turn it into an Iterable and use concatMapIterable(Function):

        
         source.concatMapIterable(v -> createStream(v)::iterator);
         

        Note that Streams can be consumed only once; any subsequent attempt to consume a Stream will result in an IllegalStateException.

        Primitive streams are not supported and items have to be boxed manually (e.g., via IntStream.boxed()):

        
         source.concatMapStream(v -> IntStream.rangeClosed(v + 1, v + 10).boxed());
         

        Stream does not support concurrent usage so creating and/or consuming the same instance multiple times from multiple threads can lead to undefined behavior.

        Scheduler:
        concatMapStream does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the element type of the Streams and the result
        Parameters:
        mapper - the function that receives an upstream item and should return a Stream whose elements will be emitted to the downstream
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
        Since:
        3.0.0
        See Also:
        concatMap(Function), concatMapIterable(Function), flatMapStream(Function)
      • flatMapStream

        @CheckReturnValue
        @SchedulerSupport("none")
        @NonNull
        public final <@NonNull R> @NonNull Observable<R> flatMapStream​(@NonNull
                                                                       @NonNull Function<? super @NonNull T,​? extends java.util.stream.Stream<? extends @NonNull R>> mapper)
        Maps each upstream item into a Stream and emits the Stream's items to the downstream in a sequential fashion.

        Due to the blocking and sequential nature of Java Streams, the streams are mapped and consumed in a sequential fashion without interleaving (unlike a more general flatMap(Function)). Therefore, flatMapStream and concatMapStream are identical operators and are provided as aliases.

        The operator closes the Stream upon cancellation and when it terminates. The exceptions raised when closing a Stream are routed to the global error handler (RxJavaPlugins.onError(Throwable). If a Stream should not be closed, turn it into an Iterable and use flatMapIterable(Function):

        
         source.flatMapIterable(v -> createStream(v)::iterator);
         

        Note that Streams can be consumed only once; any subsequent attempt to consume a Stream will result in an IllegalStateException.

        Primitive streams are not supported and items have to be boxed manually (e.g., via IntStream.boxed()):

        
         source.flatMapStream(v -> IntStream.rangeClosed(v + 1, v + 10).boxed());
         

        Stream does not support concurrent usage so creating and/or consuming the same instance multiple times from multiple threads can lead to undefined behavior.

        Scheduler:
        flatMapStream does not operate by default on a particular Scheduler.
        Type Parameters:
        R - the element type of the Streams and the result
        Parameters:
        mapper - the function that receives an upstream item and should return a Stream whose elements will be emitted to the downstream
        Returns:
        the new Observable instance
        Throws:
        java.lang.NullPointerException - if mapper is null
        Since:
        3.0.0
        See Also:
        flatMap(Function), flatMapIterable(Function)