Class Flowable<T>
- java.lang.Object
-
- io.reactivex.rxjava3.core.Flowable<T>
-
- Type Parameters:
T
- the type of the items emitted by theFlowable
- All Implemented Interfaces:
org.reactivestreams.Publisher<T>
- Direct Known Subclasses:
AbstractFlowableWithUpstream
,CompletableAndThenPublisher
,CompletableToFlowable
,ConnectableFlowable
,FlowableAmb
,FlowableAutoConnect
,FlowableCollectWithCollector
,FlowableCombineLatest
,FlowableConcatArray
,FlowableConcatMapEagerPublisher
,FlowableConcatMapMaybe
,FlowableConcatMapMaybePublisher
,FlowableConcatMapSingle
,FlowableConcatMapSinglePublisher
,FlowableCreate
,FlowableDefer
,FlowableDelaySubscriptionOther
,FlowableEmpty
,FlowableError
,FlowableFlatMapMaybePublisher
,FlowableFlatMapSinglePublisher
,FlowableFlatMapStream
,FlowableFromAction
,FlowableFromArray
,FlowableFromCallable
,FlowableFromCompletable
,FlowableFromCompletionStage
,FlowableFromFuture
,FlowableFromIterable
,FlowableFromObservable
,FlowableFromPublisher
,FlowableFromRunnable
,FlowableFromStream
,FlowableFromSupplier
,FlowableGenerate
,FlowableInterval
,FlowableIntervalRange
,FlowableJust
,FlowableMapOptional
,FlowableMapPublisher
,FlowableNever
,FlowableProcessor
,FlowablePublishMulticast.MulticastProcessor
,FlowableRange
,FlowableRangeLong
,FlowableRefCount
,FlowableReplay.MulticastFlowable
,FlowableSamplePublisher
,FlowableScalarXMap.ScalarXMapFlowable
,FlowableSequenceEqual
,FlowableSwitchMapMaybe
,FlowableSwitchMapMaybePublisher
,FlowableSwitchMapSingle
,FlowableSwitchMapSinglePublisher
,FlowableTakePublisher
,FlowableTimer
,FlowableUsing
,FlowableWindowBoundarySelector.WindowBoundaryMainSubscriber.WindowEndSubscriberIntercept
,FlowableWindowSubscribeIntercept
,FlowableZip
,GroupedFlowable
,MaybeConcatArray
,MaybeConcatArrayDelayError
,MaybeConcatIterable
,MaybeFlatMapIterableFlowable
,MaybeFlatMapPublisher
,MaybeFlattenStreamAsFlowable
,MaybeMergeArray
,MaybeToFlowable
,ParallelCollector
,ParallelJoin
,ParallelReduceFull
,ParallelSortedJoin
,SingleFlatMapIterableFlowable
,SingleFlatMapPublisher
,SingleFlattenStreamAsFlowable
,SingleToFlowable
public abstract class Flowable<@NonNull T> extends java.lang.Object implements org.reactivestreams.Publisher<T>
TheFlowable
class that implements the Reactive StreamsPublisher
Pattern and offers factory methods, intermediate operators and the ability to consume reactive dataflows.Reactive Streams operates with
Publisher
s whichFlowable
extends. Many operators therefore accept generalPublisher
s directly and allow direct interoperation with other Reactive Streams implementations.The
Flowable
hosts the default buffer size of 128 elements for operators, accessible viabufferSize()
, that can be overridden globally via the system parameterrx3.buffer-size
. Most operators, however, have overloads that allow setting their internal buffer size explicitly.The documentation for this class makes use of marble diagrams. The following legend explains these diagrams:
The
Flowable
follows the protocol
where the stream can be disposed through theonSubscribe onNext* (onError | onComplete)?
Subscription
instance provided to consumers throughSubscriber.onSubscribe(Subscription)
. Unlike theObservable.subscribe()
of version 1.x,subscribe(Subscriber)
does not allow external cancellation of a subscription and theSubscriber
instance is expected to expose such capability if needed.Flowable
s support backpressure and requireSubscriber
s to signal demand viaSubscription.request(long)
.Example:
Disposable d = Flowable.just("Hello world!") .delay(1, TimeUnit.SECONDS) .subscribeWith(new DisposableSubscriber<String>() { @Override public void onStart() { System.out.println("Start!"); request(1); } @Override public void onNext(String t) { System.out.println(t); request(1); } @Override public void onError(Throwable t) { t.printStackTrace(); } @Override public void onComplete() { System.out.println("Done!"); } }); Thread.sleep(500); // the sequence can now be cancelled via dispose() d.dispose();
The Reactive Streams specification is relatively strict when defining interactions between
Publisher
s andSubscriber
s, so much so that there is a significant performance penalty due certain timing requirements and the need to prepare for invalid request amounts viaSubscription.request(long)
. Therefore, RxJava has introduced theFlowableSubscriber
interface that indicates the consumer can be driven with relaxed rules. All RxJava operators are implemented with these relaxed rules in mind. If the subscribingSubscriber
does not implement this interface, for example, due to it being from another Reactive Streams compliant library, theFlowable
will automatically apply a compliance wrapper around it.Flowable
is an abstract class, but it is not advised to implement sources and custom operators by extending the class directly due to the large amounts of Reactive Streams rules to be followed to the letter. See the wiki for some guidance if such custom implementations are necessary.The recommended way of creating custom
Flowable
s is by using thecreate(FlowableOnSubscribe, BackpressureStrategy)
factory method:Flowable<String> source = Flowable.create(new FlowableOnSubscribe<String>() { @Override public void subscribe(FlowableEmitter<String> emitter) throws Exception { // signal an item emitter.onNext("Hello"); // could be some blocking operation Thread.sleep(1000); // the consumer might have cancelled the flow if (emitter.isCancelled()) { return; } emitter.onNext("World"); Thread.sleep(1000); // the end-of-sequence has to be signaled, otherwise the // consumers may never finish emitter.onComplete(); } }, BackpressureStrategy.BUFFER); System.out.println("Subscribe!"); source.subscribe(System.out::println); System.out.println("Done!");
RxJava reactive sources, such as
Flowable
, are generally synchronous and sequential in nature. In the ReactiveX design, the location (thread) where operators run is orthogonal to when the operators can work with data. This means that asynchrony and parallelism has to be explicitly expressed via operators such assubscribeOn(Scheduler)
,observeOn(Scheduler)
andparallel()
. In general, operators featuring aScheduler
parameter are introducing this type of asynchrony into the flow.For more information see the ReactiveX documentation.
- See Also:
Observable
,ParallelFlowable
,DisposableSubscriber
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static int
BUFFER_SIZE
The default buffer size.
-
Constructor Summary
Constructors Constructor Description Flowable()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description @NonNull Single<java.lang.Boolean>
all(@NonNull Predicate<? super @NonNull T> predicate)
Returns aSingle
that emits aBoolean
that indicates whether all of the items emitted by the currentFlowable
satisfy a condition.static <@NonNull T>
@NonNull Flowable<T>amb(@NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources)
Mirrors the onePublisher
in anIterable
of severalPublisher
s that first either emits an item or sends a termination notification.static <@NonNull T>
@NonNull Flowable<T>ambArray(@NonNull org.reactivestreams.Publisher<? extends @NonNull T>... sources)
Mirrors the onePublisher
in an array of severalPublisher
s that first either emits an item or sends a termination notification.@NonNull Flowable<T>
ambWith(@NonNull org.reactivestreams.Publisher<? extends @NonNull T> other)
Mirrors thePublisher
(current or provided) that first either emits an item or sends a termination notification.@NonNull Single<java.lang.Boolean>
any(@NonNull Predicate<? super @NonNull T> predicate)
Returns aSingle
that emitstrue
if any item emitted by the currentFlowable
satisfies a specified condition, otherwisefalse
.T
blockingFirst()
Returns the first item emitted by thisFlowable
, or throwsNoSuchElementException
if it emits no items.T
blockingFirst(@NonNull T defaultItem)
Returns the first item emitted by thisFlowable
, or a default value if it emits no items.void
blockingForEach(@NonNull Consumer<? super @NonNull T> onNext)
Consumes the currentFlowable
in a blocking fashion and invokes the givenConsumer
with each upstream item on the current thread until the upstream terminates.void
blockingForEach(@NonNull Consumer<? super @NonNull T> onNext, int bufferSize)
Consumes the currentFlowable
in a blocking fashion and invokes the givenConsumer
with each upstream item on the current thread until the upstream terminates.@NonNull java.lang.Iterable<T>
blockingIterable()
Converts thisFlowable
into anIterable
.@NonNull java.lang.Iterable<T>
blockingIterable(int bufferSize)
Converts thisFlowable
into anIterable
.T
blockingLast()
Returns the last item emitted by thisFlowable
, or throwsNoSuchElementException
if thisFlowable
emits no items.T
blockingLast(@NonNull T defaultItem)
Returns the last item emitted by thisFlowable
, or a default value if it emits no items.@NonNull java.lang.Iterable<T>
blockingLatest()
Returns anIterable
that returns the latest item emitted by thisFlowable
, waiting if necessary for one to become available.@NonNull java.lang.Iterable<T>
blockingMostRecent(@NonNull T initialItem)
Returns anIterable
that always returns the item most recently emitted by thisFlowable
.@NonNull java.lang.Iterable<T>
blockingNext()
Returns anIterable
that blocks until thisFlowable
emits another item, then returns that item.T
blockingSingle()
If thisFlowable
completes after emitting a single item, return that item, otherwise throw aNoSuchElementException
.T
blockingSingle(@NonNull T defaultItem)
If thisFlowable
completes after emitting a single item, return that item; if it emits more than one item, throw anIllegalArgumentException
; if it emits no items, return a default value.@NonNull java.util.stream.Stream<T>
blockingStream()
Creates a sequentialStream
to consume or process thisFlowable
in a blocking manner via the JavaStream
API.@NonNull java.util.stream.Stream<T>
blockingStream(int prefetch)
Creates a sequentialStream
to consume or process thisFlowable
in a blocking manner via the JavaStream
API.void
blockingSubscribe()
Runs the currentFlowable
to a terminal event, ignoring any values and rethrowing any exception.void
blockingSubscribe(@NonNull Consumer<? super @NonNull T> onNext)
Subscribes to the source and calls the given callbacks on the current thread.void
blockingSubscribe(@NonNull Consumer<? super @NonNull T> onNext, int bufferSize)
Subscribes to the source and calls the given callbacks on the current thread.void
blockingSubscribe(@NonNull Consumer<? super @NonNull T> onNext, @NonNull Consumer<? super java.lang.Throwable> onError)
Subscribes to the source and calls the given callbacks on the current thread.void
blockingSubscribe(@NonNull Consumer<? super @NonNull T> onNext, @NonNull Consumer<? super java.lang.Throwable> onError, int bufferSize)
Subscribes to the source and calls the given callbacks on the current thread.void
blockingSubscribe(@NonNull Consumer<? super @NonNull T> onNext, @NonNull Consumer<? super java.lang.Throwable> onError, @NonNull Action onComplete)
Subscribes to the source and calls the given callbacks on the current thread.void
blockingSubscribe(@NonNull Consumer<? super @NonNull T> onNext, @NonNull Consumer<? super java.lang.Throwable> onError, @NonNull Action onComplete, int bufferSize)
Subscribes to the source and calls the given callbacks on the current thread.void
blockingSubscribe(@NonNull org.reactivestreams.Subscriber<? super @NonNull T> subscriber)
Subscribes to the source and calls theSubscriber
methods on the current thread.@NonNull Flowable<java.util.List<T>>
buffer(int count)
Returns aFlowable
that emits buffers of items it collects from the currentFlowable
.@NonNull Flowable<java.util.List<T>>
buffer(int count, int skip)
Returns aFlowable
that emits buffers of items it collects from the currentFlowable
.<@NonNull U extends java.util.Collection<? super @NonNull T>>
@NonNull Flowable<U>buffer(int count, int skip, @NonNull Supplier<@NonNull U> bufferSupplier)
Returns aFlowable
that emits buffers of items it collects from the currentFlowable
.<@NonNull U extends java.util.Collection<? super @NonNull T>>
@NonNull Flowable<U>buffer(int count, @NonNull Supplier<@NonNull U> bufferSupplier)
Returns aFlowable
that emits buffers of items it collects from the currentFlowable
.@NonNull Flowable<java.util.List<T>>
buffer(long timespan, long timeskip, @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits buffers of items it collects from the currentFlowable
.@NonNull Flowable<java.util.List<T>>
buffer(long timespan, long timeskip, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns aFlowable
that emits buffers of items it collects from the currentFlowable
.<@NonNull U extends java.util.Collection<? super @NonNull T>>
@NonNull Flowable<U>buffer(long timespan, long timeskip, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, @NonNull Supplier<@NonNull U> bufferSupplier)
Returns aFlowable
that emits buffers of items it collects from the currentFlowable
.@NonNull Flowable<java.util.List<T>>
buffer(long timespan, @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits buffers of items it collects from the currentFlowable
.@NonNull Flowable<java.util.List<T>>
buffer(long timespan, @NonNull java.util.concurrent.TimeUnit unit, int count)
Returns aFlowable
that emits buffers of items it collects from the currentFlowable
.@NonNull Flowable<java.util.List<T>>
buffer(long timespan, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns aFlowable
that emits buffers of items it collects from the currentFlowable
.@NonNull Flowable<java.util.List<T>>
buffer(long timespan, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, int count)
Returns aFlowable
that emits buffers of items it collects from the currentFlowable
.<@NonNull U extends java.util.Collection<? super @NonNull T>>
@NonNull Flowable<U>buffer(long timespan, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, int count, @NonNull Supplier<@NonNull U> bufferSupplier, boolean restartTimerOnMaxSize)
Returns aFlowable
that emits buffers of items it collects from the currentFlowable
.<@NonNull TOpening,@NonNull TClosing>
@NonNull Flowable<java.util.List<T>>buffer(@NonNull org.reactivestreams.Publisher<? extends @NonNull TOpening> openingIndicator, @NonNull Function<? super @NonNull TOpening,? extends org.reactivestreams.Publisher<? extends @NonNull TClosing>> closingIndicator)
Returns aFlowable
that emits buffers of items it collects from the currentFlowable
.<@NonNull TOpening,@NonNull TClosing,@NonNull U extends java.util.Collection<? super @NonNull T>>
@NonNull Flowable<U>buffer(@NonNull org.reactivestreams.Publisher<? extends @NonNull TOpening> openingIndicator, @NonNull Function<? super @NonNull TOpening,? extends org.reactivestreams.Publisher<? extends @NonNull TClosing>> closingIndicator, @NonNull Supplier<@NonNull U> bufferSupplier)
Returns aFlowable
that emits buffers of items it collects from the currentFlowable
.<@NonNull B>
@NonNull Flowable<java.util.List<T>>buffer(@NonNull org.reactivestreams.Publisher<@NonNull B> boundaryIndicator)
Returns aFlowable
that emits non-overlapping buffered items from the currentFlowable
each time the specified boundaryPublisher
emits an item.<@NonNull B>
@NonNull Flowable<java.util.List<T>>buffer(@NonNull org.reactivestreams.Publisher<@NonNull B> boundaryIndicator, int initialCapacity)
Returns aFlowable
that emits non-overlapping buffered items from the currentFlowable
each time the specified boundaryPublisher
emits an item.<@NonNull B,@NonNull U extends java.util.Collection<? super @NonNull T>>
@NonNull Flowable<U>buffer(@NonNull org.reactivestreams.Publisher<@NonNull B> boundaryIndicator, @NonNull Supplier<@NonNull U> bufferSupplier)
Returns aFlowable
that emits non-overlapping buffered items from the currentFlowable
each time the specified boundaryPublisher
emits an item.static int
bufferSize()
Returns the default internal buffer size used by most async operators.@NonNull Flowable<T>
cache()
Returns aFlowable
that subscribes to thisPublisher
lazily, caches all of its events and replays them, in the same order as received, to all the downstream subscribers.@NonNull Flowable<T>
cacheWithInitialCapacity(int initialCapacity)
Returns aFlowable
that subscribes to thisPublisher
lazily, caches all of its events and replays them, in the same order as received, to all the downstream subscribers.<@NonNull U>
@NonNull Flowable<U>cast(@NonNull java.lang.Class<@NonNull U> clazz)
Returns aFlowable
that emits the upstream items while they can be cast viaClass.cast(Object)
until the upstream terminates, or until the upstream signals an item which can't be cast, resulting in aClassCastException
to be signaled to the downstream.<@NonNull U>
@NonNull Single<U>collect(@NonNull Supplier<? extends @NonNull U> initialItemSupplier, @NonNull BiConsumer<? super @NonNull U,? super @NonNull T> collector)
Collects items emitted by the finite sourcePublisher
into a single mutable data structure and returns aSingle
that emits this structure.<@NonNull R,@Nullable A>
@NonNull Single<R>collect(@NonNull java.util.stream.Collector<? super @NonNull T,@Nullable A,@NonNull R> collector)
Collects the finite upstream's values into a container via aStream
Collector
callback set and emits it as the success result.<@NonNull U>
@NonNull Single<U>collectInto(@NonNull U initialItem, @NonNull BiConsumer<? super @NonNull U,? super @NonNull T> collector)
Collects items emitted by the finite sourcePublisher
into a single mutable data structure and returns aSingle
that emits this structure.static <@NonNull T,@NonNull R>
@NonNull Flowable<R>combineLatest(@NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, @NonNull Function<? super java.lang.Object[],? extends @NonNull R> combiner)
Combines a collection of sourcePublisher
s by emitting an item that aggregates the latest values of each of the sourcePublisher
s each time an item is received from any of the sourcePublisher
s, where this aggregation is defined by a specified function.static <@NonNull T,@NonNull R>
@NonNull Flowable<R>combineLatest(@NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, @NonNull Function<? super java.lang.Object[],? extends @NonNull R> combiner, int bufferSize)
Combines a collection of sourcePublisher
s by emitting an item that aggregates the latest values of each of the sourcePublisher
s each time an item is received from any of the sourcePublisher
s, where this aggregation is defined by a specified function.static <@NonNull T1,@NonNull T2,@NonNull R>
@NonNull Flowable<R>combineLatest(@NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull BiFunction<? super @NonNull T1,? super @NonNull T2,? extends @NonNull R> combiner)
Combines two sourcePublisher
s by emitting an item that aggregates the latest values of each of the sourcePublisher
s each time an item is received from either of the sourcePublisher
s, where this aggregation is defined by a specified function.static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull R>
@NonNull Flowable<R>combineLatest(@NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull org.reactivestreams.Publisher<? extends @NonNull T3> source3, @NonNull Function3<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? extends @NonNull R> combiner)
Combines three sourcePublisher
s by emitting an item that aggregates the latest values of each of the sourcePublisher
s each time an item is received from any of the sourcePublisher
s, where this aggregation is defined by a specified function.static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull R>
@NonNull Flowable<R>combineLatest(@NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull org.reactivestreams.Publisher<? extends @NonNull T3> source3, @NonNull org.reactivestreams.Publisher<? extends @NonNull T4> source4, @NonNull Function4<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? extends @NonNull R> combiner)
Combines four sourcePublisher
s by emitting an item that aggregates the latest values of each of the sourcePublisher
s each time an item is received from any of the sourcePublisher
s, where this aggregation is defined by a specified function.static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull R>
@NonNull Flowable<R>combineLatest(@NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull org.reactivestreams.Publisher<? extends @NonNull T3> source3, @NonNull org.reactivestreams.Publisher<? extends @NonNull T4> source4, @NonNull org.reactivestreams.Publisher<? extends @NonNull T5> source5, @NonNull Function5<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? super @NonNull T5,? extends @NonNull R> combiner)
Combines five sourcePublisher
s by emitting an item that aggregates the latest values of each of the sourcePublisher
s each time an item is received from any of the sourcePublisher
s, where this aggregation is defined by a specified function.static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull R>
@NonNull Flowable<R>combineLatest(@NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull org.reactivestreams.Publisher<? extends @NonNull T3> source3, @NonNull org.reactivestreams.Publisher<? extends @NonNull T4> source4, @NonNull org.reactivestreams.Publisher<? extends @NonNull T5> source5, @NonNull org.reactivestreams.Publisher<? extends @NonNull T6> source6, @NonNull Function6<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? super @NonNull T5,? super @NonNull T6,? extends @NonNull R> combiner)
Combines six sourcePublisher
s by emitting an item that aggregates the latest values of each of the sourcePublisher
s each time an item is received from any of the sourcePublisher
s, where this aggregation is defined by a specified function.static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull T7,@NonNull R>
@NonNull Flowable<R>combineLatest(@NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull org.reactivestreams.Publisher<? extends @NonNull T3> source3, @NonNull org.reactivestreams.Publisher<? extends @NonNull T4> source4, @NonNull org.reactivestreams.Publisher<? extends @NonNull T5> source5, @NonNull org.reactivestreams.Publisher<? extends @NonNull T6> source6, @NonNull org.reactivestreams.Publisher<? extends @NonNull T7> source7, @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> combiner)
Combines seven sourcePublisher
s by emitting an item that aggregates the latest values of each of the sourcePublisher
s each time an item is received from any of the sourcePublisher
s, where this aggregation is defined by a specified function.static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull T7,@NonNull T8,@NonNull R>
@NonNull Flowable<R>combineLatest(@NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull org.reactivestreams.Publisher<? extends @NonNull T3> source3, @NonNull org.reactivestreams.Publisher<? extends @NonNull T4> source4, @NonNull org.reactivestreams.Publisher<? extends @NonNull T5> source5, @NonNull org.reactivestreams.Publisher<? extends @NonNull T6> source6, @NonNull org.reactivestreams.Publisher<? extends @NonNull T7> source7, @NonNull org.reactivestreams.Publisher<? extends @NonNull T8> source8, @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> combiner)
Combines eight sourcePublisher
s by emitting an item that aggregates the latest values of each of the sourcePublisher
s each time an item is received from any of the sourcePublisher
s, where this aggregation is defined by a specified function.static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull T7,@NonNull T8,@NonNull T9,@NonNull R>
@NonNull Flowable<R>combineLatest(@NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull org.reactivestreams.Publisher<? extends @NonNull T3> source3, @NonNull org.reactivestreams.Publisher<? extends @NonNull T4> source4, @NonNull org.reactivestreams.Publisher<? extends @NonNull T5> source5, @NonNull org.reactivestreams.Publisher<? extends @NonNull T6> source6, @NonNull org.reactivestreams.Publisher<? extends @NonNull T7> source7, @NonNull org.reactivestreams.Publisher<? extends @NonNull T8> source8, @NonNull org.reactivestreams.Publisher<? extends @NonNull T9> source9, @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> combiner)
Combines nine sourcePublisher
s by emitting an item that aggregates the latest values of each of the sourcePublisher
s each time an item is received from any of the sourcePublisher
s, where this aggregation is defined by a specified function.static <@NonNull T,@NonNull R>
@NonNull Flowable<R>combineLatestArray(@NonNull org.reactivestreams.Publisher<? extends @NonNull T>[] sources, @NonNull Function<? super java.lang.Object[],? extends @NonNull R> combiner)
Combines a collection of sourcePublisher
s by emitting an item that aggregates the latest values of each of the sourcePublisher
s each time an item is received from any of the sourcePublisher
s, where this aggregation is defined by a specified function.static <@NonNull T,@NonNull R>
@NonNull Flowable<R>combineLatestArray(@NonNull org.reactivestreams.Publisher<? extends @NonNull T>[] sources, @NonNull Function<? super java.lang.Object[],? extends @NonNull R> combiner, int bufferSize)
Combines a collection of sourcePublisher
s by emitting an item that aggregates the latest values of each of the sourcePublisher
s each time an item is received from any of the sourcePublisher
s, where this aggregation is defined by a specified function.static <@NonNull T,@NonNull R>
@NonNull Flowable<R>combineLatestArrayDelayError(@NonNull org.reactivestreams.Publisher<? extends @NonNull T>[] sources, @NonNull Function<? super java.lang.Object[],? extends @NonNull R> combiner)
Combines a collection of sourcePublisher
s by emitting an item that aggregates the latest values of each of the sourcePublisher
s each time an item is received from any of the sourcePublisher
s, where this aggregation is defined by a specified function.static <@NonNull T,@NonNull R>
@NonNull Flowable<R>combineLatestArrayDelayError(@NonNull org.reactivestreams.Publisher<? extends @NonNull T>[] sources, @NonNull Function<? super java.lang.Object[],? extends @NonNull R> combiner, int bufferSize)
Combines a collection of sourcePublisher
s by emitting an item that aggregates the latest values of each of the sourcePublisher
s each time an item is received from any of the sourcePublisher
s, where this aggregation is defined by a specified function and delays any error from the sources until all sourcePublisher
s terminate.static <@NonNull T,@NonNull R>
@NonNull Flowable<R>combineLatestDelayError(@NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, @NonNull Function<? super java.lang.Object[],? extends @NonNull R> combiner)
Combines a collection of sourcePublisher
s by emitting an item that aggregates the latest values of each of the sourcePublisher
s each time an item is received from any of the sourcePublisher
s, where this aggregation is defined by a specified function and delays any error from the sources until all sourcePublisher
s terminate.static <@NonNull T,@NonNull R>
@NonNull Flowable<R>combineLatestDelayError(@NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, @NonNull Function<? super java.lang.Object[],? extends @NonNull R> combiner, int bufferSize)
Combines a collection of sourcePublisher
s by emitting an item that aggregates the latest values of each of the sourcePublisher
s each time an item is received from any of the sourcePublisher
s, where this aggregation is defined by a specified function and delays any error from the sources until all sourcePublisher
s terminate.<@NonNull R>
@NonNull Flowable<R>compose(@NonNull FlowableTransformer<? super @NonNull T,? extends @NonNull R> composer)
Transform the currentFlowable
by applying a particularFlowableTransformer
function to it.static <@NonNull T>
@NonNull Flowable<T>concat(@NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources)
Concatenates elements of eachPublisher
provided via anIterable
sequence into a single sequence of elements without interleaving them.static <@NonNull T>
@NonNull Flowable<T>concat(@NonNull org.reactivestreams.Publisher<? extends @NonNull T> source1, @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source2)
Returns aFlowable
that emits the items emitted by twoPublisher
s, one after the other, without interleaving them.static <@NonNull T>
@NonNull Flowable<T>concat(@NonNull org.reactivestreams.Publisher<? extends @NonNull T> source1, @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source2, @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source3)
Returns aFlowable
that emits the items emitted by threePublisher
s, one after the other, without interleaving them.static <@NonNull T>
@NonNull Flowable<T>concat(@NonNull org.reactivestreams.Publisher<? extends @NonNull T> source1, @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source2, @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source3, @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source4)
Returns aFlowable
that emits the items emitted by fourPublisher
s, one after the other, without interleaving them.static <@NonNull T>
@NonNull Flowable<T>concat(@NonNull org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources)
Returns aFlowable
that emits the items emitted by each of thePublisher
s emitted by the sourcePublisher
, one after the other, without interleaving them.static <@NonNull T>
@NonNull Flowable<T>concat(@NonNull org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, int prefetch)
Returns aFlowable
that emits the items emitted by each of thePublisher
s emitted by the sourcePublisher
, one after the other, without interleaving them.static <@NonNull T>
@NonNull Flowable<T>concatArray(@NonNull org.reactivestreams.Publisher<? extends @NonNull T>... sources)
Concatenates a variable number ofPublisher
sources.static <@NonNull T>
@NonNull Flowable<T>concatArrayDelayError(@NonNull org.reactivestreams.Publisher<? extends @NonNull T>... sources)
Concatenates a variable number ofPublisher
sources and delays errors from any of them till all terminate.static <@NonNull T>
@NonNull Flowable<T>concatArrayEager(int maxConcurrency, int prefetch, @NonNull org.reactivestreams.Publisher<? extends @NonNull T>... sources)
Concatenates an array ofPublisher
s eagerly into a single stream of values.static <@NonNull T>
@NonNull Flowable<T>concatArrayEager(@NonNull org.reactivestreams.Publisher<? extends @NonNull T>... sources)
Concatenates an array ofPublisher
s eagerly into a single stream of values.static <@NonNull T>
@NonNull Flowable<T>concatArrayEagerDelayError(int maxConcurrency, int prefetch, @NonNull org.reactivestreams.Publisher<? extends @NonNull T>... sources)
Concatenates an array ofPublisher
s eagerly into a single stream of values and delaying any errors until all sources terminate.static <@NonNull T>
@NonNull Flowable<T>concatArrayEagerDelayError(@NonNull org.reactivestreams.Publisher<? extends @NonNull T>... sources)
Concatenates an array ofPublisher
s eagerly into a single stream of values and delaying any errors until all sources terminate.static <@NonNull T>
@NonNull Flowable<T>concatDelayError(@NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources)
Concatenates theIterable
sequence ofPublisher
s into a single sequence by subscribing to eachPublisher
, one after the other, one at a time and delays any errors till the all innerPublisher
s terminate.static <@NonNull T>
@NonNull Flowable<T>concatDelayError(@NonNull org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources)
Concatenates thePublisher
sequence ofPublisher
s into a single sequence by subscribing to each innerPublisher
, one after the other, one at a time and delays any errors till the all inner and the outerPublisher
s terminate.static <@NonNull T>
@NonNull Flowable<T>concatDelayError(@NonNull org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, int prefetch, boolean tillTheEnd)
Concatenates thePublisher
sequence ofPublisher
s into a single sequence by subscribing to each innerPublisher
, one after the other, one at a time and delays any errors till the all inner and the outerPublisher
s terminate.static <@NonNull T>
@NonNull Flowable<T>concatEager(@NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources)
Concatenates a sequence ofPublisher
s eagerly into a single stream of values.static <@NonNull T>
@NonNull Flowable<T>concatEager(@NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, int maxConcurrency, int prefetch)
Concatenates a sequence ofPublisher
s eagerly into a single stream of values and runs a limited number of inner sequences at once.static <@NonNull T>
@NonNull Flowable<T>concatEager(@NonNull org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources)
Concatenates aPublisher
sequence ofPublisher
s eagerly into a single stream of values.static <@NonNull T>
@NonNull Flowable<T>concatEager(@NonNull org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, int maxConcurrency, int prefetch)
Concatenates aPublisher
sequence ofPublisher
s eagerly into a single stream of values and runs a limited number of inner sequences at once.static <@NonNull T>
@NonNull Flowable<T>concatEagerDelayError(@NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources)
Concatenates a sequence ofPublisher
s eagerly into a single stream of values, delaying errors until all the inner sequences terminate.static <@NonNull T>
@NonNull Flowable<T>concatEagerDelayError(@NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, int maxConcurrency, int prefetch)
Concatenates a sequence ofPublisher
s 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.static <@NonNull T>
@NonNull Flowable<T>concatEagerDelayError(@NonNull org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources)
Concatenates aPublisher
sequence ofPublisher
s eagerly into a single stream of values, delaying errors until all the inner and the outer sequences terminate.static <@NonNull T>
@NonNull Flowable<T>concatEagerDelayError(@NonNull org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, int maxConcurrency, int prefetch)
Concatenates aPublisher
sequence ofPublisher
s eagerly into a single stream of values, delaying errors until all the inner and outer sequences terminate and runs a limited number of inner sequences at once.<@NonNull R>
@NonNull Flowable<R>concatMap(@NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper)
Returns a newFlowable
that emits items resulting from applying a function that you supply to each item emitted by the currentFlowable
, where that function returns aPublisher
, and then emitting the items that result from concatenating those returnedPublisher
s.<@NonNull R>
@NonNull Flowable<R>concatMap(@NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper, int prefetch)
Returns a newFlowable
that emits items resulting from applying a function that you supply to each item emitted by the currentFlowable
, where that function returns aPublisher
, and then emitting the items that result from concatenating those returnedPublisher
s.<@NonNull R>
@NonNull Flowable<R>concatMap(@NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper, int prefetch, @NonNull Scheduler scheduler)
Returns a newFlowable
that emits items resulting from applying a function (on a designated scheduler) that you supply to each item emitted by the currentFlowable
, where that function returns aPublisher
, and then emitting the items that result from concatenating those returnedPublisher
s.@NonNull Completable
concatMapCompletable(@NonNull Function<? super @NonNull T,? extends CompletableSource> mapper)
Maps the upstream items intoCompletableSource
s and subscribes to them one after the other completes.@NonNull Completable
concatMapCompletable(@NonNull Function<? super @NonNull T,? extends CompletableSource> mapper, int prefetch)
Maps the upstream items intoCompletableSource
s and subscribes to them one after the other completes.@NonNull Completable
concatMapCompletableDelayError(@NonNull Function<? super @NonNull T,? extends CompletableSource> mapper)
Maps the upstream items intoCompletableSource
s and subscribes to them one after the other terminates, delaying all errors till both thisFlowable
and all innerCompletableSource
s terminate.@NonNull Completable
concatMapCompletableDelayError(@NonNull Function<? super @NonNull T,? extends CompletableSource> mapper, boolean tillTheEnd)
Maps the upstream items intoCompletableSource
s and subscribes to them one after the other terminates, optionally delaying all errors till both thisFlowable
and all innerCompletableSource
s terminate.@NonNull Completable
concatMapCompletableDelayError(@NonNull Function<? super @NonNull T,? extends CompletableSource> mapper, boolean tillTheEnd, int prefetch)
Maps the upstream items intoCompletableSource
s and subscribes to them one after the other terminates, optionally delaying all errors till both thisFlowable
and all innerCompletableSource
s terminate.<@NonNull R>
@NonNull Flowable<R>concatMapDelayError(@NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper)
Maps each of the items into aPublisher
, 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 innerPublisher
s till all of them terminate.<@NonNull R>
@NonNull Flowable<R>concatMapDelayError(@NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper, boolean tillTheEnd, int prefetch)
Maps each of the items into aPublisher
, 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 innerPublisher
s till all of them terminate.<@NonNull R>
@NonNull Flowable<R>concatMapDelayError(@NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper, boolean tillTheEnd, int prefetch, @NonNull Scheduler scheduler)
Maps each of the upstream items into aPublisher
, subscribes to them one after the other, one at a time and emits their values in order while executing the mapper function on the designated scheduler, delaying any error from either this or any of the innerPublisher
s till all of them terminate.<@NonNull R>
@NonNull Flowable<R>concatMapEager(@NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper)
Maps a sequence of values intoPublisher
s and concatenates thesePublisher
s eagerly into a singlePublisher
.<@NonNull R>
@NonNull Flowable<R>concatMapEager(@NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper, int maxConcurrency, int prefetch)
Maps a sequence of values intoPublisher
s and concatenates thesePublisher
s eagerly into a singlePublisher
.<@NonNull R>
@NonNull Flowable<R>concatMapEagerDelayError(@NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper, boolean tillTheEnd)
Maps a sequence of values intoPublisher
s and concatenates thesePublisher
s eagerly into a singlePublisher
.<@NonNull R>
@NonNull Flowable<R>concatMapEagerDelayError(@NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper, boolean tillTheEnd, int maxConcurrency, int prefetch)
Maps a sequence of values intoPublisher
s and concatenates thesePublisher
s eagerly into a singleFlowable
sequence.<@NonNull U>
@NonNull Flowable<U>concatMapIterable(@NonNull Function<? super @NonNull T,? extends java.lang.Iterable<? extends @NonNull U>> mapper)
Returns aFlowable
that concatenate each item emitted by the currentFlowable
with the values in anIterable
corresponding to that item that is generated by a selector.<@NonNull U>
@NonNull Flowable<U>concatMapIterable(@NonNull Function<? super @NonNull T,? extends java.lang.Iterable<? extends @NonNull U>> mapper, int prefetch)
Returns aFlowable
that concatenate each item emitted by the currentFlowable
with the values in anIterable
corresponding to that item that is generated by a selector.<@NonNull R>
@NonNull Flowable<R>concatMapMaybe(@NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper)
Maps the upstream items intoMaybeSource
s and subscribes to them one after the other succeeds or completes, emits their success value if available or terminates immediately if either thisFlowable
or the current innerMaybeSource
fail.<@NonNull R>
@NonNull Flowable<R>concatMapMaybe(@NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper, int prefetch)
Maps the upstream items intoMaybeSource
s and subscribes to them one after the other succeeds or completes, emits their success value if available or terminates immediately if either thisFlowable
or the current innerMaybeSource
fail.<@NonNull R>
@NonNull Flowable<R>concatMapMaybeDelayError(@NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper)
Maps the upstream items intoMaybeSource
s and subscribes to them one after the other terminates, emits their success value if available and delaying all errors till both thisFlowable
and all innerMaybeSource
s terminate.<@NonNull R>
@NonNull Flowable<R>concatMapMaybeDelayError(@NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper, boolean tillTheEnd)
Maps the upstream items intoMaybeSource
s and subscribes to them one after the other terminates, emits their success value if available and optionally delaying all errors till both thisFlowable
and all innerMaybeSource
s terminate.<@NonNull R>
@NonNull Flowable<R>concatMapMaybeDelayError(@NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper, boolean tillTheEnd, int prefetch)
Maps the upstream items intoMaybeSource
s and subscribes to them one after the other terminates, emits their success value if available and optionally delaying all errors till both thisFlowable
and all innerMaybeSource
s terminate.<@NonNull R>
@NonNull Flowable<R>concatMapSingle(@NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper)
Maps the upstream items intoSingleSource
s and subscribes to them one after the other succeeds, emits their success values or terminates immediately if either thisFlowable
or the current innerSingleSource
fail.<@NonNull R>
@NonNull Flowable<R>concatMapSingle(@NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper, int prefetch)
Maps the upstream items intoSingleSource
s and subscribes to them one after the other succeeds, emits their success values or terminates immediately if either thisFlowable
or the current innerSingleSource
fail.<@NonNull R>
@NonNull Flowable<R>concatMapSingleDelayError(@NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper)
Maps the upstream items intoSingleSource
s and subscribes to them one after the other succeeds or fails, emits their success values and delays all errors till both thisFlowable
and all innerSingleSource
s terminate.<@NonNull R>
@NonNull Flowable<R>concatMapSingleDelayError(@NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper, boolean tillTheEnd)
Maps the upstream items intoSingleSource
s and subscribes to them one after the other succeeds or fails, emits their success values and optionally delays all errors till both thisFlowable
and all innerSingleSource
s terminate.<@NonNull R>
@NonNull Flowable<R>concatMapSingleDelayError(@NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper, boolean tillTheEnd, int prefetch)
Maps the upstream items intoSingleSource
s and subscribes to them one after the other succeeds or fails, emits their success values and optionally delays errors till both thisFlowable
and all innerSingleSource
s terminate.<@NonNull R>
@NonNull Flowable<R>concatMapStream(@NonNull Function<? super @NonNull T,? extends java.util.stream.Stream<? extends @NonNull R>> mapper)
Maps each upstream item into aStream
and emits theStream
's items to the downstream in a sequential fashion.<@NonNull R>
@NonNull Flowable<R>concatMapStream(@NonNull Function<? super @NonNull T,? extends java.util.stream.Stream<? extends @NonNull R>> mapper, int prefetch)
Maps each upstream item into aStream
and emits theStream
's items to the downstream in a sequential fashion.@NonNull Flowable<T>
concatWith(@NonNull CompletableSource other)
Returns aFlowable
that emits items from thisFlowable
and when it completes normally, the otherCompletableSource
is subscribed to and the returnedFlowable
emits its terminal events.@NonNull Flowable<T>
concatWith(@NonNull MaybeSource<? extends @NonNull T> other)
Returns aFlowable
that emits the items from thisFlowable
followed by the success item or terminal events of the otherMaybeSource
.@NonNull Flowable<T>
concatWith(@NonNull SingleSource<? extends @NonNull T> other)
Returns aFlowable
that emits the items from thisFlowable
followed by the success item or error event of the otherSingleSource
.@NonNull Flowable<T>
concatWith(@NonNull org.reactivestreams.Publisher<? extends @NonNull T> other)
Returns aFlowable
that emits the items emitted from the currentFlowable
, then the next, one after the other, without interleaving them.@NonNull Single<java.lang.Boolean>
contains(@NonNull java.lang.Object item)
Returns aSingle
that emits aBoolean
that indicates whether the currentFlowable
emitted a specified item.@NonNull Single<java.lang.Long>
count()
Returns aSingle
that counts the total number of items emitted by the currentFlowable
and emits this count as a 64-bitLong
.static <@NonNull T>
@NonNull Flowable<T>create(@NonNull FlowableOnSubscribe<@NonNull T> source, @NonNull BackpressureStrategy mode)
Provides an API (via a coldFlowable
) that bridges the reactive world with the callback-style, generally non-backpressured world.@NonNull Flowable<T>
debounce(long timeout, @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that mirrors the currentFlowable
, except that it drops items emitted by the currentFlowable
that are followed by newer items before a timeout value expires.@NonNull Flowable<T>
debounce(long timeout, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns aFlowable
that mirrors the currentFlowable
, except that it drops items emitted by the currentFlowable
that are followed by newer items before a timeout value expires on a specifiedScheduler
.@NonNull Flowable<T>
debounce(long timeout, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, @NonNull Consumer<? super @NonNull T> onDropped)
Returns aFlowable
that mirrors the currentFlowable
, except that it drops items emitted by the currentFlowable
that are followed by newer items before a timeout value expires on a specifiedScheduler
.<@NonNull U>
@NonNull Flowable<T>debounce(@NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<@NonNull U>> debounceIndicator)
Returns aFlowable
that mirrors the currentFlowable
, except that it drops items emitted by the currentFlowable
that are followed by another item within a computed debounce duration.@NonNull Flowable<T>
defaultIfEmpty(@NonNull T defaultItem)
Returns aFlowable
that emits the items emitted by the currentFlowable
or a specified default item if the currentFlowable
is empty.static <@NonNull T>
@NonNull Flowable<T>defer(@NonNull Supplier<? extends @NonNull org.reactivestreams.Publisher<? extends @NonNull T>> supplier)
Returns aFlowable
that calls aPublisher
factory to create aPublisher
for each newSubscriber
that subscribes.@NonNull Flowable<T>
delay(long time, @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits the items emitted by the currentFlowable
shifted forward in time by a specified delay.@NonNull Flowable<T>
delay(long time, @NonNull java.util.concurrent.TimeUnit unit, boolean delayError)
Returns aFlowable
that emits the items emitted by the currentFlowable
shifted forward in time by a specified delay.@NonNull Flowable<T>
delay(long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns aFlowable
that emits the items emitted by the currentFlowable
shifted forward in time by a specified delay.@NonNull Flowable<T>
delay(long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, boolean delayError)
Returns aFlowable
that emits the items emitted by the currentFlowable
shifted forward in time by a specified delay.<@NonNull U>
@NonNull Flowable<T>delay(@NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<@NonNull U>> itemDelayIndicator)
Returns aFlowable
that delays the emissions of the currentFlowable
via anotherPublisher
on a per-item basis.<@NonNull U,@NonNull V>
@NonNull Flowable<T>delay(@NonNull org.reactivestreams.Publisher<@NonNull U> subscriptionIndicator, @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<@NonNull V>> itemDelayIndicator)
Returns aFlowable
that delays the subscription to and emissions from the currentFlowable
via anotherPublisher
on a per-item basis.@NonNull Flowable<T>
delaySubscription(long time, @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that delays the subscription to the currentFlowable
by a given amount of time.@NonNull Flowable<T>
delaySubscription(long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns aFlowable
that delays the subscription to the currentFlowable
by a given amount of time, both waiting and subscribing on a givenScheduler
.<@NonNull U>
@NonNull Flowable<T>delaySubscription(@NonNull org.reactivestreams.Publisher<@NonNull U> subscriptionIndicator)
Returns aFlowable
that delays the subscription to thisPublisher
until the otherPublisher
emits an element or completes normally.<@NonNull R>
@NonNull Flowable<R>dematerialize(@NonNull Function<? super @NonNull T,@NonNull Notification<@NonNull R>> selector)
Returns aFlowable
that reverses the effect ofmaterialize
by transforming theNotification
objects extracted from the source items via a selector function into their respectiveSubscriber
signal types.@NonNull Flowable<T>
distinct()
Returns aFlowable
that emits all items emitted by the currentFlowable
that are distinct based onObject.equals(Object)
comparison.<@NonNull K>
@NonNull Flowable<T>distinct(@NonNull Function<? super @NonNull T,@NonNull K> keySelector)
Returns aFlowable
that emits all items emitted by the currentFlowable
that are distinct according to a key selector function and based onObject.equals(Object)
comparison of the objects returned by the key selector function.<@NonNull K>
@NonNull Flowable<T>distinct(@NonNull Function<? super @NonNull T,@NonNull K> keySelector, @NonNull Supplier<? extends java.util.Collection<? super @NonNull K>> collectionSupplier)
Returns aFlowable
that emits all items emitted by the currentFlowable
that are distinct according to a key selector function and based onObject.equals(Object)
comparison of the objects returned by the key selector function.@NonNull Flowable<T>
distinctUntilChanged()
Returns aFlowable
that emits all items emitted by the currentFlowable
that are distinct from their immediate predecessors based onObject.equals(Object)
comparison.@NonNull Flowable<T>
distinctUntilChanged(@NonNull BiPredicate<? super @NonNull T,? super @NonNull T> comparer)
Returns aFlowable
that emits all items emitted by the currentFlowable
that are distinct from their immediate predecessors when compared with each other via the provided comparator function.<@NonNull K>
@NonNull Flowable<T>distinctUntilChanged(@NonNull Function<? super @NonNull T,@NonNull K> keySelector)
Returns aFlowable
that emits all items emitted by the currentFlowable
that are distinct from their immediate predecessors, according to a key selector function and based onObject.equals(Object)
comparison of those objects returned by the key selector function.@NonNull Flowable<T>
doAfterNext(@NonNull Consumer<? super @NonNull T> onAfterNext)
Calls the specified consumer with the current item after this item has been emitted to the downstream.@NonNull Flowable<T>
doAfterTerminate(@NonNull Action onAfterTerminate)
@NonNull Flowable<T>
doFinally(@NonNull Action onFinally)
Calls the specified action after thisFlowable
signalsonError
oronComplete
or gets canceled by the downstream.@NonNull Flowable<T>
doOnCancel(@NonNull Action onCancel)
Calls the cancelAction
if the downstream cancels the sequence.@NonNull Flowable<T>
doOnComplete(@NonNull Action onComplete)
private @NonNull Flowable<T>
doOnEach(@NonNull Consumer<? super @NonNull T> onNext, @NonNull Consumer<? super java.lang.Throwable> onError, Action onComplete, Action onAfterTerminate)
Calls the appropriate onXXX consumer (shared between all subscribers) whenever a signal with the same type passes through, before forwarding them to downstream.@NonNull Flowable<T>
doOnEach(@NonNull Consumer<? super Notification<@NonNull T>> onNotification)
Invokes aConsumer
with aNotification
instances matching the signals emitted by the currentFlowable
before they are forwarded to the downstream.@NonNull Flowable<T>
doOnEach(@NonNull org.reactivestreams.Subscriber<? super @NonNull T> subscriber)
Calls the appropriate methods of the givenSubscriber
when the currentFlowable
signals events before forwarding it to the downstream.@NonNull Flowable<T>
doOnError(@NonNull Consumer<? super java.lang.Throwable> onError)
Calls the givenConsumer
with the errorThrowable
if the currentFlowable
failed before forwarding it to the downstream.@NonNull Flowable<T>
doOnLifecycle(@NonNull Consumer<? super org.reactivestreams.Subscription> onSubscribe, @NonNull LongConsumer onRequest, @NonNull Action onCancel)
Calls the appropriateonXXX
method (shared between allSubscriber
s) for the lifecycle events of the sequence (subscription, cancellation, requesting).@NonNull Flowable<T>
doOnNext(@NonNull Consumer<? super @NonNull T> onNext)
Calls the givenConsumer
with the value emitted by the currentFlowable
before forwarding it to the downstream.@NonNull Flowable<T>
doOnRequest(@NonNull LongConsumer onRequest)
Calls the givenLongConsumer
with the request amount from the downstream before forwarding it to the currentFlowable
.@NonNull Flowable<T>
doOnSubscribe(@NonNull Consumer<? super org.reactivestreams.Subscription> onSubscribe)
Calls the givenConsumer
with theSubscription
provided by the currentFlowable
upon subscription from the downstream before forwarding it to the subscriber'sonSubscribe
method.@NonNull Flowable<T>
doOnTerminate(@NonNull Action onTerminate)
Calls the givenAction
when the currentFlowable
completes normally or with an error before those signals are forwarded to the downstream.@NonNull Maybe<T>
elementAt(long index)
Returns aMaybe
that emits the single item at a specified index in a sequence of emissions from thisFlowable
or completes if thisFlowable
sequence has fewer elements than index.@NonNull Single<T>
elementAt(long index, @NonNull T defaultItem)
Returns aSingle
that emits the item found at a specified index in a sequence of emissions from thisFlowable
, or a default item if that index is out of range.@NonNull Single<T>
elementAtOrError(long index)
Returns aSingle
that emits the item found at a specified index in a sequence of emissions from thisFlowable
or signals aNoSuchElementException
if thisFlowable
has fewer elements than index.static <@NonNull T>
@NonNull Flowable<T>empty()
Returns aFlowable
that emits no items to theSubscriber
and immediately invokes itsonComplete
method.static <@NonNull T>
@NonNull Flowable<T>error(@NonNull Supplier<? extends @NonNull java.lang.Throwable> supplier)
Returns aFlowable
that invokes aSubscriber
'sonError
method when theSubscriber
subscribes to it.static <@NonNull T>
@NonNull Flowable<T>error(@NonNull java.lang.Throwable throwable)
Returns aFlowable
that invokes aSubscriber
'sonError
method when theSubscriber
subscribes to it.@NonNull Flowable<T>
filter(@NonNull Predicate<? super @NonNull T> predicate)
Filters items emitted by the currentFlowable
by only emitting those that satisfy a specified predicate.@NonNull Single<T>
first(@NonNull T defaultItem)
Returns aSingle
that emits only the very first item emitted by thisFlowable
, or a default item if thisFlowable
completes without emitting anything.@NonNull Maybe<T>
firstElement()
Returns aMaybe
that emits only the very first item emitted by thisFlowable
or completes if thisFlowable
is empty.@NonNull Single<T>
firstOrError()
Returns aSingle
that emits only the very first item emitted by thisFlowable
or signals aNoSuchElementException
if thisFlowable
is empty.@NonNull java.util.concurrent.CompletionStage<T>
firstOrErrorStage()
Signals the first upstream item or aNoSuchElementException
if the upstream is empty via aCompletionStage
.@NonNull java.util.concurrent.CompletionStage<T>
firstStage(@NonNull T defaultItem)
Signals the first upstream item (or the default item if the upstream is empty) via aCompletionStage
.<@NonNull R>
@NonNull Flowable<R>flatMap(@NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper)
Returns aFlowable
that emits items based on applying a function that you supply to each item emitted by the currentFlowable
, where that function returns aPublisher
, and then merging those resultingPublisher
s and emitting the results of this merger.<@NonNull R>
@NonNull Flowable<R>flatMap(@NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper, boolean delayErrors)
Returns aFlowable
that emits items based on applying a function that you supply to each item emitted by the currentFlowable
, where that function returns aPublisher
, and then merging those resultingPublisher
s and emitting the results of this merger.<@NonNull R>
@NonNull Flowable<R>flatMap(@NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper, boolean delayErrors, int maxConcurrency)
Returns aFlowable
that emits items based on applying a function that you supply to each item emitted by the currentFlowable
, where that function returns aPublisher
, and then merging those resultingPublisher
s and emitting the results of this merger, while limiting the maximum number of concurrent subscriptions to thesePublisher
s.<@NonNull R>
@NonNull Flowable<R>flatMap(@NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper, boolean delayErrors, int maxConcurrency, int bufferSize)
Returns aFlowable
that emits items based on applying a function that you supply to each item emitted by the currentFlowable
, where that function returns aPublisher
, and then merging those resultingPublisher
s and emitting the results of this merger, while limiting the maximum number of concurrent subscriptions to thesePublisher
s.<@NonNull R>
@NonNull Flowable<R>flatMap(@NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper, int maxConcurrency)
Returns aFlowable
that emits items based on applying a function that you supply to each item emitted by the currentFlowable
, where that function returns aPublisher
, and then merging those resultingPublisher
s and emitting the results of this merger, while limiting the maximum number of concurrent subscriptions to thesePublisher
s.<@NonNull R>
@NonNull Flowable<R>flatMap(@NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> onNextMapper, @NonNull Function<? super java.lang.Throwable,? extends org.reactivestreams.Publisher<? extends @NonNull R>> onErrorMapper, @NonNull Supplier<? extends org.reactivestreams.Publisher<? extends @NonNull R>> onCompleteSupplier)
Returns aFlowable
that applies a function to each item emitted or notification raised by the currentFlowable
and then flattens thePublisher
s returned from these functions and emits the resulting items.<@NonNull R>
@NonNull Flowable<R>flatMap(@NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> onNextMapper, @NonNull Function<java.lang.Throwable,? extends org.reactivestreams.Publisher<? extends @NonNull R>> onErrorMapper, @NonNull Supplier<? extends org.reactivestreams.Publisher<? extends @NonNull R>> onCompleteSupplier, int maxConcurrency)
Returns aFlowable
that applies a function to each item emitted or notification raised by the currentFlowable
and then flattens thePublisher
s returned from these functions and emits the resulting items, while limiting the maximum number of concurrent subscriptions to thesePublisher
s.<@NonNull U,@NonNull R>
@NonNull Flowable<R>flatMap(@NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull U>> mapper, @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> combiner)
Returns aFlowable
that emits the results of a specified function to the pair of values emitted by the currentFlowable
and a specified collectionPublisher
.<@NonNull U,@NonNull R>
@NonNull Flowable<R>flatMap(@NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull U>> mapper, @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> combiner, boolean delayErrors)
Returns aFlowable
that emits the results of a specified function to the pair of values emitted by the currentFlowable
and a specified innerPublisher
.<@NonNull U,@NonNull R>
@NonNull Flowable<R>flatMap(@NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull U>> mapper, @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> combiner, boolean delayErrors, int maxConcurrency)
Returns aFlowable
that emits the results of a specified function to the pair of values emitted by the currentFlowable
and a specified collectionPublisher
, while limiting the maximum number of concurrent subscriptions to thesePublisher
s.<@NonNull U,@NonNull R>
@NonNull Flowable<R>flatMap(@NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull U>> mapper, @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> combiner, boolean delayErrors, int maxConcurrency, int bufferSize)
Returns aFlowable
that emits the results of a specified function to the pair of values emitted by the currentFlowable
and a specified collectionPublisher
, while limiting the maximum number of concurrent subscriptions to thesePublisher
s.<@NonNull U,@NonNull R>
@NonNull Flowable<R>flatMap(@NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull U>> mapper, @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> combiner, int maxConcurrency)
Returns aFlowable
that emits the results of a specified function to the pair of values emitted by the currentFlowable
and a specified collectionPublisher
, while limiting the maximum number of concurrent subscriptions to thesePublisher
s.@NonNull Completable
flatMapCompletable(@NonNull Function<? super @NonNull T,? extends CompletableSource> mapper)
Maps each element of the upstreamFlowable
intoCompletableSource
s, subscribes to them and waits until the upstream and allCompletableSource
s complete.@NonNull Completable
flatMapCompletable(@NonNull Function<? super @NonNull T,? extends CompletableSource> mapper, boolean delayErrors, int maxConcurrency)
Maps each element of the upstreamFlowable
intoCompletableSource
s, subscribes to them and waits until the upstream and allCompletableSource
s complete, optionally delaying all errors.<@NonNull U>
@NonNull Flowable<U>flatMapIterable(@NonNull Function<? super @NonNull T,? extends java.lang.Iterable<? extends @NonNull U>> mapper)
MergesIterable
s generated by a mapperFunction
for each individual item emitted by the currentFlowable
into a singleFlowable
sequence.<@NonNull U>
@NonNull Flowable<U>flatMapIterable(@NonNull Function<? super @NonNull T,? extends java.lang.Iterable<? extends @NonNull U>> mapper, int bufferSize)
MergesIterable
s generated by a mapperFunction
for each individual item emitted by the currentFlowable
into a singleFlowable
sequence.<@NonNull U,@NonNull V>
@NonNull Flowable<V>flatMapIterable(@NonNull Function<? super @NonNull T,? extends java.lang.Iterable<? extends @NonNull U>> mapper, @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull V> combiner)
MergesIterable
s generated by a mapperFunction
for each individual item emitted by the currentFlowable
into a singleFlowable
sequence where the resulting items will be the combination of the original item and each inner item of the respectiveIterable
as returned by theresultSelector
BiFunction
.<@NonNull U,@NonNull V>
@NonNull Flowable<V>flatMapIterable(@NonNull Function<? super @NonNull T,? extends java.lang.Iterable<? extends @NonNull U>> mapper, @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull V> combiner, int prefetch)
MergesIterable
s generated by a mapperFunction
for each individual item emitted by the currentFlowable
into a singleFlowable
sequence where the resulting items will be the combination of the original item and each inner item of the respectiveIterable
as returned by theresultSelector
BiFunction
.<@NonNull R>
@NonNull Flowable<R>flatMapMaybe(@NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper)
Maps each element of the upstreamFlowable
intoMaybeSource
s, subscribes to all of them and merges theironSuccess
values, in no particular order, into a singleFlowable
sequence.<@NonNull R>
@NonNull Flowable<R>flatMapMaybe(@NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper, boolean delayErrors, int maxConcurrency)
Maps each element of the upstreamFlowable
intoMaybeSource
s, subscribes to at mostmaxConcurrency
MaybeSource
s at a time and merges theironSuccess
values, in no particular order, into a singleFlowable
sequence, optionally delaying all errors.<@NonNull R>
@NonNull Flowable<R>flatMapSingle(@NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper)
Maps each element of the upstreamFlowable
intoSingleSource
s, subscribes to all of them and merges theironSuccess
values, in no particular order, into a singleFlowable
sequence.<@NonNull R>
@NonNull Flowable<R>flatMapSingle(@NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper, boolean delayErrors, int maxConcurrency)
Maps each element of the upstreamFlowable
intoSingleSource
s, subscribes to at mostmaxConcurrency
SingleSource
s at a time and merges theironSuccess
values, in no particular order, into a singleFlowable
sequence, optionally delaying all errors.<@NonNull R>
@NonNull Flowable<R>flatMapStream(@NonNull Function<? super @NonNull T,? extends java.util.stream.Stream<? extends @NonNull R>> mapper)
Maps each upstream item into aStream
and emits theStream
's items to the downstream in a sequential fashion.<@NonNull R>
@NonNull Flowable<R>flatMapStream(@NonNull Function<? super @NonNull T,? extends java.util.stream.Stream<? extends @NonNull R>> mapper, int prefetch)
Maps each upstream item into aStream
and emits theStream
's items to the downstream in a sequential fashion.@NonNull Disposable
forEach(@NonNull Consumer<? super @NonNull T> onNext)
Subscribes to the currentFlowable
and receives notifications for each element.@NonNull Disposable
forEachWhile(@NonNull Predicate<? super @NonNull T> onNext)
Subscribes to the currentFlowable
and receives notifications for each element until theonNext
Predicate returnsfalse
.@NonNull Disposable
forEachWhile(@NonNull Predicate<? super @NonNull T> onNext, @NonNull Consumer<? super java.lang.Throwable> onError)
Subscribes to the currentFlowable
and receives notifications for each element and error events until theonNext
Predicate returnsfalse
.@NonNull Disposable
forEachWhile(@NonNull Predicate<? super @NonNull T> onNext, @NonNull Consumer<? super java.lang.Throwable> onError, @NonNull Action onComplete)
Subscribes to the currentFlowable
and receives notifications for each element and the terminal events until theonNext
Predicate returnsfalse
.static <@NonNull T>
@NonNull Flowable<T>fromAction(@NonNull Action action)
Returns aFlowable
instance that runs the givenAction
for eachSubscriber
and emits either its exception or simply completes.static <@NonNull T>
@NonNull Flowable<T>fromArray(@NonNull T... items)
Converts an array into aPublisher
that emits the items in the array.static <@NonNull T>
@NonNull Flowable<T>fromCallable(@NonNull java.util.concurrent.Callable<? extends @NonNull T> callable)
Returns aFlowable
that, when aSubscriber
subscribes to it, invokes a function you specify and then emits the value returned from that function.static <@NonNull T>
@NonNull Flowable<T>fromCompletable(@NonNull CompletableSource completableSource)
Wraps aCompletableSource
into aFlowable
.static <@NonNull T>
@NonNull Flowable<@NonNull T>fromCompletionStage(@NonNull java.util.concurrent.CompletionStage<@NonNull T> stage)
Signals the completion value or error of the given (hot)CompletionStage
-based asynchronous calculation.static <@NonNull T>
@NonNull Flowable<T>fromFuture(@NonNull java.util.concurrent.Future<? extends @NonNull T> future)
Converts aFuture
into aPublisher
.static <@NonNull T>
@NonNull Flowable<T>fromFuture(@NonNull java.util.concurrent.Future<? extends @NonNull T> future, long timeout, @NonNull java.util.concurrent.TimeUnit unit)
Converts aFuture
into aPublisher
, with a timeout on theFuture
.static <@NonNull T>
@NonNull Flowable<T>fromIterable(@NonNull java.lang.Iterable<? extends @NonNull T> source)
Converts anIterable
sequence into aPublisher
that emits the items in the sequence.static <@NonNull T>
@NonNull Flowable<T>fromMaybe(@NonNull MaybeSource<@NonNull T> maybe)
Returns aFlowable
instance that when subscribed to, subscribes to theMaybeSource
instance and emitsonSuccess
as a single item or forwards anyonComplete
oronError
signal.static <@NonNull T>
@NonNull Flowable<T>fromObservable(@NonNull ObservableSource<@NonNull T> source, @NonNull BackpressureStrategy strategy)
Converts the givenObservableSource
into aFlowable
by applying the specified backpressure strategy.static <@NonNull T>
@NonNull Flowable<@NonNull T>fromOptional(@NonNull java.util.Optional<@NonNull T> optional)
Converts the existing value of the provided optional into ajust(Object)
or an empty optional into anempty()
Flowable
instance.static <@NonNull T>
@NonNull Flowable<T>fromPublisher(@NonNull org.reactivestreams.Publisher<? extends @NonNull T> publisher)
Converts an arbitrary Reactive StreamsPublisher
into aFlowable
if not already aFlowable
.static <@NonNull T>
@NonNull Flowable<T>fromRunnable(@NonNull java.lang.Runnable run)
Returns aFlowable
instance that runs the givenRunnable
for eachSubscriber
and emits either its unchecked exception or simply completes.static <@NonNull T>
@NonNull Flowable<T>fromSingle(@NonNull SingleSource<@NonNull T> source)
Returns aFlowable
instance that when subscribed to, subscribes to theSingleSource
instance and emitsonSuccess
as a single item or forwards theonError
signal.static <@NonNull T>
@NonNull Flowable<@NonNull T>fromStream(@NonNull java.util.stream.Stream<@NonNull T> stream)
Converts aStream
into a finiteFlowable
and emits its items in the sequence.static <@NonNull T>
@NonNull Flowable<T>fromSupplier(@NonNull Supplier<? extends @NonNull T> supplier)
Returns aFlowable
that, when aSubscriber
subscribes to it, invokes a supplier function you specify and then emits the value returned from that function.static <@NonNull T>
@NonNull Flowable<T>generate(@NonNull Consumer<@NonNull Emitter<@NonNull T>> generator)
Returns a cold, synchronous, stateless and backpressure-aware generator of values.static <@NonNull T,@NonNull S>
@NonNull Flowable<T>generate(@NonNull Supplier<@NonNull S> initialState, @NonNull BiConsumer<@NonNull S,Emitter<@NonNull T>> generator)
Returns a cold, synchronous, stateful and backpressure-aware generator of values.static <@NonNull T,@NonNull S>
@NonNull Flowable<T>generate(@NonNull Supplier<@NonNull S> initialState, @NonNull BiConsumer<@NonNull S,Emitter<@NonNull T>> generator, @NonNull Consumer<? super @NonNull S> disposeState)
Returns a cold, synchronous, stateful and backpressure-aware generator of values.static <@NonNull T,@NonNull S>
@NonNull Flowable<T>generate(@NonNull Supplier<@NonNull S> initialState, @NonNull BiFunction<@NonNull S,@NonNull Emitter<@NonNull T>,@NonNull S> generator)
Returns a cold, synchronous, stateful and backpressure-aware generator of values.static <@NonNull T,@NonNull S>
@NonNull Flowable<T>generate(@NonNull Supplier<@NonNull S> initialState, @NonNull BiFunction<@NonNull S,@NonNull Emitter<@NonNull T>,@NonNull S> generator, @NonNull Consumer<? super @NonNull S> disposeState)
Returns a cold, synchronous, stateful and backpressure-aware generator of values.<@NonNull K>
@NonNull Flowable<GroupedFlowable<K,T>>groupBy(@NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector)
Groups the items emitted by the currentFlowable
according to a specified criterion, and emits these grouped items asGroupedFlowable
s.<@NonNull K>
@NonNull Flowable<GroupedFlowable<K,T>>groupBy(@NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector, boolean delayError)
Groups the items emitted by the currentFlowable
according to a specified criterion, and emits these grouped items asGroupedFlowable
s.<@NonNull K,@NonNull V>
@NonNull Flowable<GroupedFlowable<K,V>>groupBy(@NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector, @NonNull Function<? super @NonNull T,? extends @NonNull V> valueSelector)
Groups the items emitted by the currentFlowable
according to a specified criterion, and emits these grouped items asGroupedFlowable
s.<@NonNull K,@NonNull V>
@NonNull Flowable<GroupedFlowable<K,V>>groupBy(@NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector, @NonNull Function<? super @NonNull T,? extends @NonNull V> valueSelector, boolean delayError)
Groups the items emitted by the currentFlowable
according to a specified criterion, and emits these grouped items asGroupedFlowable
s.<@NonNull K,@NonNull V>
@NonNull Flowable<GroupedFlowable<K,V>>groupBy(@NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector, @NonNull Function<? super @NonNull T,? extends @NonNull V> valueSelector, boolean delayError, int bufferSize)
Groups the items emitted by the currentFlowable
according to a specified criterion, and emits these grouped items asGroupedFlowable
s.<@NonNull K,@NonNull V>
@NonNull Flowable<GroupedFlowable<K,V>>groupBy(@NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector, @NonNull Function<? super @NonNull T,? extends @NonNull V> valueSelector, boolean delayError, int bufferSize, @NonNull Function<? super Consumer<java.lang.Object>,? extends java.util.Map<@NonNull K,java.lang.Object>> evictingMapFactory)
Groups the items emitted by the currentFlowable
according to a specified criterion, and emits these grouped items asGroupedFlowable
s.<@NonNull TRight,@NonNull TLeftEnd,@NonNull TRightEnd,@NonNull R>
@NonNull Flowable<R>groupJoin(@NonNull org.reactivestreams.Publisher<? extends @NonNull TRight> other, @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<@NonNull TLeftEnd>> leftEnd, @NonNull Function<? super @NonNull TRight,? extends org.reactivestreams.Publisher<@NonNull TRightEnd>> rightEnd, @NonNull BiFunction<? super @NonNull T,? super Flowable<@NonNull TRight>,? extends @NonNull R> resultSelector)
Returns aFlowable
that correlates twoPublisher
s when they overlap in time and groups the results.@NonNull Flowable<T>
hide()
Hides the identity of thisFlowable
and itsSubscription
.@NonNull Completable
ignoreElements()
Ignores all items emitted by the currentFlowable
and only callsonComplete
oronError
.static @NonNull Flowable<java.lang.Long>
interval(long initialDelay, long period, @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits a0L
after theinitialDelay
and ever-increasing numbers after eachperiod
of time thereafter.static @NonNull Flowable<java.lang.Long>
interval(long initialDelay, long period, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns aFlowable
that emits a0L
after theinitialDelay
and ever-increasing numbers after eachperiod
of time thereafter, on a specifiedScheduler
.static @NonNull Flowable<java.lang.Long>
interval(long period, @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits a sequential number every specified interval of time.static @NonNull Flowable<java.lang.Long>
interval(long period, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns aFlowable
that emits a sequential number every specified interval of time, on a specifiedScheduler
.static @NonNull Flowable<java.lang.Long>
intervalRange(long start, long count, long initialDelay, long period, @NonNull java.util.concurrent.TimeUnit unit)
Signals a range of long values, the first after some initial delay and the rest periodically after.static @NonNull Flowable<java.lang.Long>
intervalRange(long start, long count, long initialDelay, long period, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Signals a range of long values, the first after some initial delay and the rest periodically after.@NonNull Single<java.lang.Boolean>
isEmpty()
<@NonNull TRight,@NonNull TLeftEnd,@NonNull TRightEnd,@NonNull R>
@NonNull Flowable<R>join(@NonNull org.reactivestreams.Publisher<? extends @NonNull TRight> other, @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<@NonNull TLeftEnd>> leftEnd, @NonNull Function<? super @NonNull TRight,? extends org.reactivestreams.Publisher<@NonNull TRightEnd>> rightEnd, @NonNull BiFunction<? super @NonNull T,? super @NonNull TRight,? extends @NonNull R> resultSelector)
Correlates the items emitted by twoPublisher
s based on overlapping durations.static <@NonNull T>
@NonNull Flowable<T>just(@NonNull T item)
Returns aFlowable
that signals the given (constant reference) item and then completes.static <@NonNull T>
@NonNull Flowable<T>just(@NonNull T item1, @NonNull T item2)
Converts two items into aPublisher
that emits those items.static <@NonNull T>
@NonNull Flowable<T>just(@NonNull T item1, @NonNull T item2, @NonNull T item3)
Converts three items into aPublisher
that emits those items.static <@NonNull T>
@NonNull Flowable<T>just(@NonNull T item1, @NonNull T item2, @NonNull T item3, @NonNull T item4)
Converts four items into aPublisher
that emits those items.static <@NonNull T>
@NonNull Flowable<T>just(@NonNull T item1, @NonNull T item2, @NonNull T item3, @NonNull T item4, @NonNull T item5)
Converts five items into aPublisher
that emits those items.static <@NonNull T>
@NonNull Flowable<T>just(@NonNull T item1, @NonNull T item2, @NonNull T item3, @NonNull T item4, @NonNull T item5, @NonNull T item6)
Converts six items into aPublisher
that emits those items.static <@NonNull T>
@NonNull Flowable<T>just(@NonNull T item1, @NonNull T item2, @NonNull T item3, @NonNull T item4, @NonNull T item5, @NonNull T item6, @NonNull T item7)
Converts seven items into aPublisher
that emits those items.static <@NonNull T>
@NonNull Flowable<T>just(@NonNull T item1, @NonNull T item2, @NonNull T item3, @NonNull T item4, @NonNull T item5, @NonNull T item6, @NonNull T item7, @NonNull T item8)
Converts eight items into aPublisher
that emits those items.static <@NonNull T>
@NonNull Flowable<T>just(@NonNull T item1, @NonNull T item2, @NonNull T item3, @NonNull T item4, @NonNull T item5, @NonNull T item6, @NonNull T item7, @NonNull T item8, @NonNull T item9)
Converts nine items into aPublisher
that emits those items.static <@NonNull T>
@NonNull Flowable<T>just(@NonNull T item1, @NonNull T item2, @NonNull T item3, @NonNull T item4, @NonNull T item5, @NonNull T item6, @NonNull T item7, @NonNull T item8, @NonNull T item9, @NonNull T item10)
Converts ten items into aPublisher
that emits those items.@NonNull Single<T>
last(@NonNull T defaultItem)
Returns aSingle
that emits only the last item emitted by thisFlowable
, or a default item if thisFlowable
completes without emitting any items.@NonNull Maybe<T>
lastElement()
Returns aMaybe
that emits the last item emitted by thisFlowable
or completes if thisFlowable
is empty.@NonNull Single<T>
lastOrError()
Returns aSingle
that emits only the last item emitted by thisFlowable
or signals aNoSuchElementException
if thisFlowable
is empty.@NonNull java.util.concurrent.CompletionStage<T>
lastOrErrorStage()
Signals the last upstream item or aNoSuchElementException
if the upstream is empty via aCompletionStage
.@NonNull java.util.concurrent.CompletionStage<T>
lastStage(@NonNull T defaultItem)
Signals the last upstream item (or the default item if the upstream is empty) via aCompletionStage
.<@NonNull R>
@NonNull Flowable<R>lift(@NonNull FlowableOperator<? extends @NonNull R,? super @NonNull T> lifter)
This method requires advanced knowledge about building operators, please consider other standard composition methods first; Returns aFlowable
which, when subscribed to, invokes theapply(Subscriber)
method of the providedFlowableOperator
for each individual downstreamSubscriber
and allows the insertion of a custom operator by accessing the downstream'sSubscriber
during this subscription phase and providing a newSubscriber
, containing the custom operator's intended business logic, that will be used in the subscription process going further upstream.<@NonNull R>
@NonNull Flowable<R>map(@NonNull Function<? super @NonNull T,? extends @NonNull R> mapper)
Returns aFlowable
that applies a specified function to each item emitted by the currentFlowable
and emits the results of these function applications.<@NonNull R>
@NonNull Flowable<R>mapOptional(@NonNull Function<? super @NonNull T,@NonNull java.util.Optional<? extends @NonNull R>> mapper)
Maps each upstream value into anOptional
and emits the contained item if not empty.@NonNull Flowable<Notification<T>>
materialize()
Returns aFlowable
that represents all of the emissions and notifications from the currentFlowable
into emissions marked with their original types withinNotification
objects.static <@NonNull T>
@NonNull Flowable<T>merge(@NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources)
Flattens anIterable
ofPublisher
s into onePublisher
, without any transformation.static <@NonNull T>
@NonNull Flowable<T>merge(@NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, int maxConcurrency)
Flattens anIterable
ofPublisher
s into onePublisher
, without any transformation, while limiting the number of concurrent subscriptions to thesePublisher
s.static <@NonNull T>
@NonNull Flowable<T>merge(@NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, int maxConcurrency, int bufferSize)
Flattens anIterable
ofPublisher
s into onePublisher
, without any transformation, while limiting the number of concurrent subscriptions to thesePublisher
s.static <@NonNull T>
@NonNull Flowable<T>merge(@NonNull org.reactivestreams.Publisher<? extends @NonNull T> source1, @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source2)
Flattens twoPublisher
s into a singlePublisher
, without any transformation.static <@NonNull T>
@NonNull Flowable<T>merge(@NonNull org.reactivestreams.Publisher<? extends @NonNull T> source1, @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source2, @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source3)
Flattens threePublisher
s into a singlePublisher
, without any transformation.static <@NonNull T>
@NonNull Flowable<T>merge(@NonNull org.reactivestreams.Publisher<? extends @NonNull T> source1, @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source2, @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source3, @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source4)
Flattens fourPublisher
s into a singlePublisher
, without any transformation.static <@NonNull T>
@NonNull Flowable<T>merge(@NonNull org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources)
Flattens aPublisher
that emitsPublisher
s into a singlePublisher
that emits the items emitted by thosPublisher
s , without any transformation.static <@NonNull T>
@NonNull Flowable<T>merge(@NonNull org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, int maxConcurrency)
Flattens aPublisher
that emitsPublisher
s into a singlePublisher
that emits the items emitted by thosePublisher
s, without any transformation, while limiting the maximum number of concurrent subscriptions to thesePublisher
s.static <@NonNull T>
@NonNull Flowable<T>mergeArray(int maxConcurrency, int bufferSize, @NonNull org.reactivestreams.Publisher<? extends @NonNull T>... sources)
Flattens an array ofPublisher
s into onePublisher
, without any transformation, while limiting the number of concurrent subscriptions to thesePublisher
s.static <@NonNull T>
@NonNull Flowable<T>mergeArray(@NonNull org.reactivestreams.Publisher<? extends @NonNull T>... sources)
Flattens an array ofPublisher
s into onePublisher
, without any transformation.static <@NonNull T>
@NonNull Flowable<T>mergeArrayDelayError(int maxConcurrency, int bufferSize, @NonNull org.reactivestreams.Publisher<? extends @NonNull T>... sources)
Flattens an array ofPublisher
s into onePublisher
, in a way that allows aSubscriber
to receive all successfully emitted items from each of the sourcePublisher
s without being interrupted by an error notification from one of them, while limiting the number of concurrent subscriptions to thesePublisher
s.static <@NonNull T>
@NonNull Flowable<T>mergeArrayDelayError(@NonNull org.reactivestreams.Publisher<? extends @NonNull T>... sources)
Flattens an array ofPublisher
s into oneFlowable
, in a way that allows aSubscriber
to receive all successfully emitted items from each of the sourcePublisher
s without being interrupted by an error notification from one of them.static <@NonNull T>
@NonNull Flowable<T>mergeDelayError(@NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources)
Flattens anIterable
ofPublisher
s into onePublisher
, in a way that allows aSubscriber
to receive all successfully emitted items from each of the sourcePublisher
s without being interrupted by an error notification from one of them.static <@NonNull T>
@NonNull Flowable<T>mergeDelayError(@NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, int maxConcurrency)
Flattens anIterable
ofPublisher
s into onePublisher
, in a way that allows aSubscriber
to receive all successfully emitted items from each of the sourcePublisher
s without being interrupted by an error notification from one of them, while limiting the number of concurrent subscriptions to thesePublisher
s.static <@NonNull T>
@NonNull Flowable<T>mergeDelayError(@NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, int maxConcurrency, int bufferSize)
Flattens anIterable
ofPublisher
s into onePublisher
, in a way that allows aSubscriber
to receive all successfully emitted items from each of the sourcePublisher
s without being interrupted by an error notification from one of them, while limiting the number of concurrent subscriptions to thesePublisher
s.static <@NonNull T>
@NonNull Flowable<T>mergeDelayError(@NonNull org.reactivestreams.Publisher<? extends @NonNull T> source1, @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source2)
Flattens twoPublisher
s into onePublisher
, in a way that allows aSubscriber
to receive all successfully emitted items from each of the sourcePublisher
s without being interrupted by an error notification from one of them.static <@NonNull T>
@NonNull Flowable<T>mergeDelayError(@NonNull org.reactivestreams.Publisher<? extends @NonNull T> source1, @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source2, @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source3)
Flattens threePublisher
s into onePublisher
, in a way that allows aSubscriber
to receive all successfully emitted items from all of the sourcePublisher
s without being interrupted by an error notification from one of them.static <@NonNull T>
@NonNull Flowable<T>mergeDelayError(@NonNull org.reactivestreams.Publisher<? extends @NonNull T> source1, @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source2, @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source3, @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source4)
Flattens fourPublisher
s into onePublisher
, in a way that allows aSubscriber
to receive all successfully emitted items from all of the sourcePublisher
s without being interrupted by an error notification from one of them.static <@NonNull T>
@NonNull Flowable<T>mergeDelayError(@NonNull org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources)
Flattens aPublisher
that emitsPublisher
s into onePublisher
, in a way that allows aSubscriber
to receive all successfully emitted items from all of the sourcePublisher
s without being interrupted by an error notification from one of them.static <@NonNull T>
@NonNull Flowable<T>mergeDelayError(@NonNull org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, int maxConcurrency)
Flattens aPublisher
that emitsPublisher
s into onePublisher
, in a way that allows aSubscriber
to receive all successfully emitted items from all of the sourcePublisher
s without being interrupted by an error notification from one of them, while limiting the number of concurrent subscriptions to thesePublisher
s.@NonNull Flowable<T>
mergeWith(@NonNull CompletableSource other)
Relays the items of thisFlowable
and completes only when the otherCompletableSource
completes as well.@NonNull Flowable<T>
mergeWith(@NonNull MaybeSource<? extends @NonNull T> other)
Merges the sequence of items of thisFlowable
with the success value of the otherMaybeSource
or waits for both to complete normally if theMaybeSource
is empty.@NonNull Flowable<T>
mergeWith(@NonNull SingleSource<? extends @NonNull T> other)
Merges the sequence of items of thisFlowable
with the success value of the otherSingleSource
.@NonNull Flowable<T>
mergeWith(@NonNull org.reactivestreams.Publisher<? extends @NonNull T> other)
Flattens this and anotherPublisher
into a singlePublisher
, without any transformation.static <@NonNull T>
@NonNull Flowable<T>never()
Returns aFlowable
that never sends any items or notifications to aSubscriber
.@NonNull Flowable<T>
observeOn(@NonNull Scheduler scheduler)
Signals the items and terminal signals of the currentFlowable
on the specifiedScheduler
, asynchronously with a bounded buffer ofbufferSize()
slots.@NonNull Flowable<T>
observeOn(@NonNull Scheduler scheduler, boolean delayError)
Signals the items and terminal signals of the currentFlowable
on the specifiedScheduler
, asynchronously with a bounded buffer and optionally delaysonError
notifications.@NonNull Flowable<T>
observeOn(@NonNull Scheduler scheduler, boolean delayError, int bufferSize)
Signals the items and terminal signals of the currentFlowable
on the specifiedScheduler
, asynchronously with a bounded buffer of configurable size and optionally delaysonError
notifications.<@NonNull U>
@NonNull Flowable<U>ofType(@NonNull java.lang.Class<@NonNull U> clazz)
Filters the items emitted by the currentFlowable
, only emitting those of the specified type.@NonNull Flowable<T>
onBackpressureBuffer()
Buffers an unlimited number of items from the currentFlowable
and allows it to emit as fast it can while allowing the downstream to consume the items at its own place.@NonNull Flowable<T>
onBackpressureBuffer(boolean delayError)
Buffers an unlimited number of items from the currentFlowable
and allows it to emit as fast it can while allowing the downstream to consume the items at its own place, optionally delaying an error until all buffered items have been consumed.@NonNull Flowable<T>
onBackpressureBuffer(int capacity)
Buffers an limited number of items from the currentFlowable
and allows it to emit as fast it can while allowing the downstream to consume the items at its own place, however, the resultingFlowable
will signal aMissingBackpressureException
viaonError
as soon as the buffer's capacity is exceeded, dropping all undelivered items, and canceling the flow.@NonNull Flowable<T>
onBackpressureBuffer(int capacity, boolean delayError)
Buffers an limited number of items from the currentFlowable
and allows it to emit as fast it can while allowing the downstream to consume the items at its own place, however, the resultingFlowable
will signal aMissingBackpressureException
viaonError
as soon as the buffer's capacity is exceeded, dropping all undelivered items, and canceling the flow.@NonNull Flowable<T>
onBackpressureBuffer(int capacity, boolean delayError, boolean unbounded)
Buffers an optionally unlimited number of items from the currentFlowable
and allows it to emit as fast it can while allowing the downstream to consume the items at its own place.@NonNull Flowable<T>
onBackpressureBuffer(int capacity, boolean delayError, boolean unbounded, @NonNull Action onOverflow)
Buffers an optionally unlimited number of items from the currentFlowable
and allows it to emit as fast it can while allowing the downstream to consume the items at its own place.@NonNull Flowable<T>
onBackpressureBuffer(int capacity, boolean delayError, boolean unbounded, @NonNull Action onOverflow, @NonNull Consumer<? super @NonNull T> onDropped)
Buffers an optionally unlimited number of items from the currentFlowable
and allows it to emit as fast it can while allowing the downstream to consume the items at its own place.@NonNull Flowable<T>
onBackpressureBuffer(int capacity, @NonNull Action onOverflow)
Buffers an limited number of items from the currentFlowable
and allows it to emit as fast it can while allowing the downstream to consume the items at its own place, however, the resultingFlowable
will signal aMissingBackpressureException
viaonError
as soon as the buffer's capacity is exceeded, dropping all undelivered items, canceling the flow and calling theonOverflow
action.@NonNull Flowable<T>
onBackpressureBuffer(long capacity, @Nullable Action onOverflow, @NonNull BackpressureOverflowStrategy overflowStrategy)
Buffers an optionally unlimited number of items from the currentFlowable
and allows it to emit as fast it can while allowing the downstream to consume the items at its own place.@NonNull Flowable<T>
onBackpressureBuffer(long capacity, @Nullable Action onOverflow, @NonNull BackpressureOverflowStrategy overflowStrategy, @NonNull Consumer<? super @NonNull T> onDropped)
Buffers an optionally unlimited number of items from the currentFlowable
and allows it to emit as fast it can while allowing the downstream to consume the items at its own place.@NonNull Flowable<T>
onBackpressureDrop()
Drops items from the currentFlowable
if the downstream is not ready to receive new items (indicated by a lack ofSubscription.request(long)
calls from it).@NonNull Flowable<T>
onBackpressureDrop(@NonNull Consumer<? super @NonNull T> onDrop)
Drops items from the currentFlowable
if the downstream is not ready to receive new items (indicated by a lack ofSubscription.request(long)
calls from it) and calls the givenConsumer
with such dropped items.@NonNull Flowable<T>
onBackpressureLatest()
Drops all but the latest item emitted by the currentFlowable
if the downstream is not ready to receive new items (indicated by a lack ofSubscription.request(long)
calls from it) and emits this latest item when the downstream becomes ready.@NonNull Flowable<T>
onBackpressureLatest(@NonNull Consumer<? super @NonNull T> onDropped)
Drops all but the latest item emitted by the currentFlowable
if the downstream is not ready to receive new items (indicated by a lack ofSubscription.request(long)
calls from it) and emits this latest item when the downstream becomes ready.@NonNull Flowable<T>
onBackpressureReduce(@NonNull BiFunction<@NonNull T,@NonNull T,@NonNull T> reducer)
Reduces a sequence of two not emitted values via a function into a single value if the downstream is not ready to receive new items (indicated by a lack ofSubscription.request(long)
calls from it) and emits this latest item when the downstream becomes ready.<@NonNull R>
@NonNull Flowable<R>onBackpressureReduce(@NonNull Supplier<@NonNull R> supplier, @NonNull BiFunction<@NonNull R,? super @NonNull T,@NonNull R> reducer)
Reduces upstream values into an aggregate value, provided by a supplier and combined via a reducer function, while the downstream is not ready to receive items, then emits this aggregate value when the downstream becomes ready.@NonNull Flowable<T>
onErrorComplete()
Returns aFlowable
instance that if the currentFlowable
emits an error, it will emit anonComplete
and swallow the throwable.@NonNull Flowable<T>
onErrorComplete(@NonNull Predicate<? super java.lang.Throwable> predicate)
Returns aFlowable
instance that if the currentFlowable
emits an error and the predicate returnstrue
, it will emit anonComplete
and swallow the throwable.@NonNull Flowable<T>
onErrorResumeNext(@NonNull Function<? super java.lang.Throwable,? extends org.reactivestreams.Publisher<? extends @NonNull T>> fallbackSupplier)
Resumes the flow with aPublisher
returned for the failureThrowable
of the currentFlowable
by a function instead of signaling the error viaonError
.@NonNull Flowable<T>
onErrorResumeWith(@NonNull org.reactivestreams.Publisher<? extends @NonNull T> fallback)
Resumes the flow with the givenPublisher
when the currentFlowable
fails instead of signaling the error viaonError
.@NonNull Flowable<T>
onErrorReturn(@NonNull Function<? super java.lang.Throwable,? extends @NonNull T> itemSupplier)
Ends the flow with a last item returned by a function for theThrowable
error signaled by the currentFlowable
instead of signaling the error viaonError
.@NonNull Flowable<T>
onErrorReturnItem(@NonNull T item)
Ends the flow with the given last item when the currentFlowable
fails instead of signaling the error viaonError
.@NonNull Flowable<T>
onTerminateDetach()
Nulls out references to the upstream producer and downstreamSubscriber
if the sequence is terminated or downstream cancels.@NonNull ParallelFlowable<T>
parallel()
Parallelizes the flow by creating multiple 'rails' (equal to the number of CPUs) and dispatches the upstream items to them in a round-robin fashion.@NonNull ParallelFlowable<T>
parallel(int parallelism)
Parallelizes the flow by creating the specified number of 'rails' and dispatches the upstream items to them in a round-robin fashion.@NonNull ParallelFlowable<T>
parallel(int parallelism, int prefetch)
Parallelizes the flow by creating the specified number of 'rails' and dispatches the upstream items to them in a round-robin fashion and uses the defined per-'rail' prefetch amount.@NonNull ConnectableFlowable<T>
publish()
Returns aConnectableFlowable
, which is a variety ofPublisher
that waits until itsconnect
method is called before it begins emitting items to thoseSubscriber
s that have subscribed to it.@NonNull ConnectableFlowable<T>
publish(int bufferSize)
Returns aConnectableFlowable
, which is a variety ofPublisher
that waits until itsconnect
method is called before it begins emitting items to thoseSubscriber
s that have subscribed to it.<@NonNull R>
@NonNull Flowable<R>publish(@NonNull Function<? super Flowable<@NonNull T>,? extends org.reactivestreams.Publisher<? extends @NonNull R>> selector, int prefetch)
Returns aFlowable
that emits the results of invoking a specified selector on items emitted by aConnectableFlowable
that shares a single subscription to the underlying sequence.<@NonNull R>
@NonNull Flowable<R>publish(@NonNull Function<? super Flowable<@NonNull T>,? extends org.reactivestreams.Publisher<@NonNull R>> selector)
Returns aFlowable
that emits the results of invoking a specified selector on items emitted by aConnectableFlowable
that shares a single subscription to the underlying sequence.static @NonNull Flowable<java.lang.Integer>
range(int start, int count)
Returns aFlowable
that emits a sequence ofInteger
s within a specified range.static @NonNull Flowable<java.lang.Long>
rangeLong(long start, long count)
Returns aFlowable
that emits a sequence ofLong
s within a specified range.@NonNull Flowable<T>
rebatchRequests(int n)
Requestsn
initially from the upstream and then 75% ofn
subsequently after 75% ofn
values have been emitted to the downstream.@NonNull Maybe<T>
reduce(@NonNull BiFunction<@NonNull T,@NonNull T,@NonNull T> reducer)
Returns aMaybe
that applies a specified accumulator function to the first item emitted by the currentFlowable
, then feeds the result of that function along with the second item emitted by the currentFlowable
into the same function, and so on until all items have been emitted by the current and finiteFlowable
, and emits the final result from the final call to your function as its sole item.<@NonNull R>
@NonNull Single<R>reduce(@NonNull R seed, @NonNull BiFunction<@NonNull R,? super @NonNull T,@NonNull R> reducer)
Returns aSingle
that applies a specified accumulator function to the first item emitted by the currentFlowable
and a specified seed value, then feeds the result of that function along with the second item emitted by the currentFlowable
into the same function, and so on until all items have been emitted by the current and finiteFlowable
, emitting the final result from the final call to your function as its sole item.<@NonNull R>
@NonNull Single<R>reduceWith(@NonNull Supplier<@NonNull R> seedSupplier, @NonNull BiFunction<@NonNull R,? super @NonNull T,@NonNull R> reducer)
Returns aSingle
that applies a specified accumulator function to the first item emitted by the currentFlowable
and a seed value derived from calling a specifiedseedSupplier
, then feeds the result of that function along with the second item emitted by the currentFlowable
into the same function, and so on until all items have been emitted by the current and finiteFlowable
, emitting the final result from the final call to your function as its sole item.@NonNull Flowable<T>
repeat()
Returns aFlowable
that repeats the sequence of items emitted by the currentFlowable
indefinitely.@NonNull Flowable<T>
repeat(long times)
Returns aFlowable
that repeats the sequence of items emitted by the currentFlowable
at mostcount
times.@NonNull Flowable<T>
repeatUntil(@NonNull BooleanSupplier stop)
Returns aFlowable
that repeats the sequence of items emitted by the currentFlowable
until the provided stop function returnstrue
.@NonNull Flowable<T>
repeatWhen(@NonNull Function<? super Flowable<java.lang.Object>,? extends org.reactivestreams.Publisher<?>> handler)
Returns aFlowable
that emits the same values as the currentFlowable
with the exception of anonComplete
.@NonNull ConnectableFlowable<T>
replay()
Returns aConnectableFlowable
that shares a single subscription to the underlyingPublisher
that will replay all of its items and notifications to any futureSubscriber
.@NonNull ConnectableFlowable<T>
replay(int bufferSize)
Returns aConnectableFlowable
that shares a single subscription to the currentFlowable
and replays at mostbufferSize
items to lateSubscriber
s.@NonNull ConnectableFlowable<T>
replay(int bufferSize, boolean eagerTruncate)
Returns aConnectableFlowable
that shares a single subscription to the currentFlowable
and replays at mostbufferSize
items to lateSubscriber
s.@NonNull ConnectableFlowable<T>
replay(int bufferSize, long time, @NonNull java.util.concurrent.TimeUnit unit)
Returns aConnectableFlowable
that shares a single subscription to the currentFlowable
and replays at mostbufferSize
items that were emitted during a specified time window.@NonNull ConnectableFlowable<T>
replay(int bufferSize, long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns aConnectableFlowable
that shares a single subscription to the currentFlowable
and replays a maximum ofbufferSize
items that are emitted within a specified time window to lateSubscriber
s.@NonNull ConnectableFlowable<T>
replay(int bufferSize, long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, boolean eagerTruncate)
Returns aConnectableFlowable
that shares a single subscription to the currentFlowable
and replays a maximum ofbufferSize
items that are emitted within a specified time window to lateSubscriber
s.@NonNull ConnectableFlowable<T>
replay(long time, @NonNull java.util.concurrent.TimeUnit unit)
Returns aConnectableFlowable
that shares a single subscription to the currentFlowable
and replays all items emitted by it within a specified time window to lateSubscriber
s.@NonNull ConnectableFlowable<T>
replay(long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns aConnectableFlowable
that shares a single subscription to the currentFlowable
and replays all items emitted by it within a specified time window to lateSubscriber
s.@NonNull ConnectableFlowable<T>
replay(long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, boolean eagerTruncate)
Returns aConnectableFlowable
that shares a single subscription to the currentFlowable
and replays all items emitted by it within a specified time window to lateSubscriber
s.<@NonNull R>
@NonNull Flowable<R>replay(@NonNull Function<? super Flowable<@NonNull T>,? extends org.reactivestreams.Publisher<@NonNull R>> selector)
Returns aFlowable
that emits items that are the results of invoking a specified selector on the items emitted by aConnectableFlowable
that shares a single subscription to the currentFlowable
.<@NonNull R>
@NonNull Flowable<R>replay(@NonNull Function<? super Flowable<@NonNull T>,? extends org.reactivestreams.Publisher<@NonNull R>> selector, int bufferSize)
Returns aFlowable
that emits items that are the results of invoking a specified selector on items emitted by aConnectableFlowable
that shares a single subscription to the currentFlowable
, replayingbufferSize
notifications.<@NonNull R>
@NonNull Flowable<R>replay(@NonNull Function<? super Flowable<@NonNull T>,? extends org.reactivestreams.Publisher<@NonNull R>> selector, int bufferSize, boolean eagerTruncate)
Returns aFlowable
that emits items that are the results of invoking a specified selector on items emitted by aConnectableFlowable
that shares a single subscription to the currentFlowable
, replayingbufferSize
notifications.<@NonNull R>
@NonNull Flowable<R>replay(@NonNull Function<? super Flowable<@NonNull T>,? extends org.reactivestreams.Publisher<@NonNull R>> selector, int bufferSize, long time, @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits items that are the results of invoking a specified selector on items emitted by aConnectableFlowable
that shares a single subscription to the currentFlowable
, replaying no more thanbufferSize
items that were emitted within a specified time window.<@NonNull R>
@NonNull Flowable<R>replay(@NonNull Function<? super Flowable<@NonNull T>,? extends org.reactivestreams.Publisher<@NonNull R>> selector, int bufferSize, long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns aFlowable
that emits items that are the results of invoking a specified selector on items emitted by aConnectableFlowable
that shares a single subscription to the currentFlowable
, replaying no more thanbufferSize
items that were emitted within a specified time window.<@NonNull R>
@NonNull Flowable<R>replay(@NonNull Function<? super Flowable<@NonNull T>,? extends org.reactivestreams.Publisher<@NonNull R>> selector, int bufferSize, long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, boolean eagerTruncate)
Returns aFlowable
that emits items that are the results of invoking a specified selector on items emitted by aConnectableFlowable
that shares a single subscription to the currentFlowable
, replaying no more thanbufferSize
items that were emitted within a specified time window.<@NonNull R>
@NonNull Flowable<R>replay(@NonNull Function<? super Flowable<@NonNull T>,? extends org.reactivestreams.Publisher<@NonNull R>> selector, long time, @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits items that are the results of invoking a specified selector on items emitted by aConnectableFlowable
that shares a single subscription to the currentFlowable
, replaying all items that were emitted within a specified time window.<@NonNull R>
@NonNull Flowable<R>replay(@NonNull Function<? super Flowable<@NonNull T>,? extends org.reactivestreams.Publisher<@NonNull R>> selector, long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns aFlowable
that emits items that are the results of invoking a specified selector on items emitted by aConnectableFlowable
that shares a single subscription to the currentFlowable
, replaying all items that were emitted within a specified time window.<@NonNull R>
@NonNull Flowable<R>replay(@NonNull Function<? super Flowable<@NonNull T>,? extends org.reactivestreams.Publisher<@NonNull R>> selector, long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, boolean eagerTruncate)
Returns aFlowable
that emits items that are the results of invoking a specified selector on items emitted by aConnectableFlowable
that shares a single subscription to the currentFlowable
, replaying all items that were emitted within a specified time window.@NonNull Flowable<T>
retry()
Returns aFlowable
that mirrors the currentFlowable
, resubscribing to it if it callsonError
(infinite retry count).@NonNull Flowable<T>
retry(long times)
Returns aFlowable
that mirrors the currentFlowable
, resubscribing to it if it callsonError
up to a specified number of retries.@NonNull Flowable<T>
retry(long times, @NonNull Predicate<? super java.lang.Throwable> predicate)
Retries at most times or until the predicate returnsfalse
, whichever happens first.@NonNull Flowable<T>
retry(@NonNull BiPredicate<? super java.lang.Integer,? super java.lang.Throwable> predicate)
Returns aFlowable
that mirrors the currentFlowable
, resubscribing to it if it callsonError
and the predicate returnstrue
for that specific exception and retry count.@NonNull Flowable<T>
retry(@NonNull Predicate<? super java.lang.Throwable> predicate)
Retries the currentFlowable
if the predicate returnstrue
.@NonNull Flowable<T>
retryUntil(@NonNull BooleanSupplier stop)
Retries until the given stop function returnstrue
.@NonNull Flowable<T>
retryWhen(@NonNull Function<? super Flowable<java.lang.Throwable>,? extends org.reactivestreams.Publisher<?>> handler)
Returns aFlowable
that emits the same values as the currentFlowable
with the exception of anonError
.void
safeSubscribe(@NonNull org.reactivestreams.Subscriber<? super @NonNull T> subscriber)
Subscribes to the currentFlowable
and wraps the givenSubscriber
into aSafeSubscriber
(if not already aSafeSubscriber
) that deals with exceptions thrown by a misbehavingSubscriber
(that doesn't follow the Reactive Streams specification).@NonNull Flowable<T>
sample(long period, @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits the most recently emitted item (if any) emitted by the currentFlowable
within periodic time intervals.@NonNull Flowable<T>
sample(long period, @NonNull java.util.concurrent.TimeUnit unit, boolean emitLast)
Returns aFlowable
that emits the most recently emitted item (if any) emitted by the currentFlowable
within periodic time intervals and optionally emit the very last upstream item when the upstream completes.@NonNull Flowable<T>
sample(long period, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns aFlowable
that emits the most recently emitted item (if any) emitted by the currentFlowable
within periodic time intervals, where the intervals are defined on a particularScheduler
.@NonNull Flowable<T>
sample(long period, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, boolean emitLast)
Returns aFlowable
that emits the most recently emitted item (if any) emitted by the currentFlowable
within periodic time intervals, where the intervals are defined on a particularScheduler
and optionally emit the very last upstream item when the upstream completes.@NonNull Flowable<T>
sample(long period, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, boolean emitLast, @NonNull Consumer<? super @NonNull T> onDropped)
Returns aFlowable
that emits the most recently emitted item (if any) emitted by the currentFlowable
within periodic time intervals, where the intervals are defined on a particularScheduler
and optionally emit the very last upstream item when the upstream completes.<@NonNull U>
@NonNull Flowable<T>sample(@NonNull org.reactivestreams.Publisher<@NonNull U> sampler)
Returns aFlowable
that, when the specifiedsampler
Publisher
emits an item or completes, emits the most recently emitted item (if any) emitted by the currentFlowable
since the previous emission from thesampler
Publisher
.<@NonNull U>
@NonNull Flowable<T>sample(@NonNull org.reactivestreams.Publisher<@NonNull U> sampler, boolean emitLast)
Returns aFlowable
that, when the specifiedsampler
Publisher
emits an item or completes, emits the most recently emitted item (if any) emitted by the currentFlowable
since the previous emission from thesampler
Publisher
and optionally emit the very last upstream item when the upstream or otherPublisher
complete.@NonNull Flowable<T>
scan(@NonNull BiFunction<@NonNull T,@NonNull T,@NonNull T> accumulator)
Returns aFlowable
that emits the first value emitted by the currentFlowable
, then emits one value for each subsequent value emitted by the currentFlowable
.<@NonNull R>
@NonNull Flowable<R>scan(@NonNull R initialValue, @NonNull BiFunction<@NonNull R,? super @NonNull T,@NonNull R> accumulator)
Returns aFlowable
that emits the provided initial (seed) value, then emits one value for each value emitted by the currentFlowable
.<@NonNull R>
@NonNull Flowable<R>scanWith(@NonNull Supplier<@NonNull R> seedSupplier, @NonNull BiFunction<@NonNull R,? super @NonNull T,@NonNull R> accumulator)
Returns aFlowable
that emits the provided initial (seed) value, then emits one value for each value emitted by the currentFlowable
.static <@NonNull T>
@NonNull Single<java.lang.Boolean>sequenceEqual(@NonNull org.reactivestreams.Publisher<? extends @NonNull T> source1, @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source2)
Returns aSingle
that emits aBoolean
value that indicates whether twoPublisher
sequences are the same by comparing the items emitted by eachPublisher
pairwise.static <@NonNull T>
@NonNull Single<java.lang.Boolean>sequenceEqual(@NonNull org.reactivestreams.Publisher<? extends @NonNull T> source1, @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source2, int bufferSize)
Returns aSingle
that emits aBoolean
value that indicates whether twoPublisher
sequences are the same by comparing the items emitted by eachPublisher
pairwise.static <@NonNull T>
@NonNull Single<java.lang.Boolean>sequenceEqual(@NonNull org.reactivestreams.Publisher<? extends @NonNull T> source1, @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source2, @NonNull BiPredicate<? super @NonNull T,? super @NonNull T> isEqual)
Returns aSingle
that emits aBoolean
value that indicates whether twoPublisher
sequences are the same by comparing the items emitted by eachPublisher
pairwise based on the results of a specified equality function.static <@NonNull T>
@NonNull Single<java.lang.Boolean>sequenceEqual(@NonNull org.reactivestreams.Publisher<? extends @NonNull T> source1, @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source2, @NonNull BiPredicate<? super @NonNull T,? super @NonNull T> isEqual, int bufferSize)
Returns aSingle
that emits aBoolean
value that indicates whether twoPublisher
sequences are the same by comparing the items emitted by eachPublisher
pairwise based on the results of a specified equality function.@NonNull Flowable<T>
serialize()
Forces the currentFlowable
's emissions and notifications to be serialized and for it to obey thePublisher
contract in other ways.@NonNull Flowable<T>
share()
Returns a newFlowable
that multicasts (and shares a single subscription to) the currentFlowable
.@NonNull Single<T>
single(@NonNull T defaultItem)
Returns aSingle
that emits the single item emitted by the currentFlowable
if it emits only a single item, or a default item if the currentFlowable
emits no items.@NonNull Maybe<T>
singleElement()
Returns aMaybe
that completes if thisFlowable
is empty, signals one item if thisFlowable
signals exactly one item or signals anIllegalArgumentException
if thisFlowable
signals more than one item.@NonNull Single<T>
singleOrError()
Returns aSingle
that emits the single item emitted by thisFlowable
, if thisFlowable
emits only a single item, otherwise if thisFlowable
completes without emitting any items aNoSuchElementException
will be signaled and if thisFlowable
emits more than one item, anIllegalArgumentException
will be signaled.@NonNull java.util.concurrent.CompletionStage<T>
singleOrErrorStage()
Signals the only expected upstream item, aNoSuchElementException
if the upstream is empty or signalsIllegalArgumentException
if the upstream has more than one item via aCompletionStage
.@NonNull java.util.concurrent.CompletionStage<T>
singleStage(@NonNull T defaultItem)
Signals the only expected upstream item (or the default item if the upstream is empty) or signalsIllegalArgumentException
if the upstream has more than one item via aCompletionStage
.@NonNull Flowable<T>
skip(long count)
Returns aFlowable
that skips the firstcount
items emitted by the currentFlowable
and emits the remainder.@NonNull Flowable<T>
skip(long time, @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that skips values emitted by the currentFlowable
before a specified time window elapses.@NonNull Flowable<T>
skip(long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns aFlowable
that skips values emitted by the currentFlowable
before a specified time window on a specifiedScheduler
elapses.@NonNull Flowable<T>
skipLast(int count)
Returns aFlowable
that drops a specified number of items from the end of the sequence emitted by the currentFlowable
.@NonNull Flowable<T>
skipLast(long time, @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that drops items emitted by the currentFlowable
during a specified time window before the source completes.@NonNull Flowable<T>
skipLast(long time, @NonNull java.util.concurrent.TimeUnit unit, boolean delayError)
Returns aFlowable
that drops items emitted by the currentFlowable
during a specified time window before the source completes.@NonNull Flowable<T>
skipLast(long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns aFlowable
that drops items emitted by the currentFlowable
during a specified time window (defined on a specified scheduler) before the source completes.@NonNull Flowable<T>
skipLast(long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, boolean delayError)
Returns aFlowable
that drops items emitted by the currentFlowable
during a specified time window (defined on a specified scheduler) before the source completes.@NonNull Flowable<T>
skipLast(long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, boolean delayError, int bufferSize)
Returns aFlowable
that drops items emitted by the currentFlowable
during a specified time window (defined on a specified scheduler) before the source completes.<@NonNull U>
@NonNull Flowable<T>skipUntil(@NonNull org.reactivestreams.Publisher<@NonNull U> other)
Returns aFlowable
that skips items emitted by the currentFlowable
until a secondPublisher
emits an item.@NonNull Flowable<T>
skipWhile(@NonNull Predicate<? super @NonNull T> predicate)
Returns aFlowable
that skips all items emitted by the currentFlowable
as long as a specified condition holdstrue
, but emits all further source items as soon as the condition becomesfalse
.@NonNull Flowable<T>
sorted()
Returns aFlowable
that emits the events emitted by sourcePublisher
, in a sorted order.@NonNull Flowable<T>
sorted(@NonNull java.util.Comparator<? super @NonNull T> comparator)
Returns aFlowable
that emits the events emitted by sourcePublisher
, in a sorted order based on a specified comparison function.@NonNull Flowable<T>
startWith(@NonNull CompletableSource other)
Returns aFlowable
which first runs the otherCompletableSource
then the currentFlowable
if the other completed normally.@NonNull Flowable<T>
startWith(@NonNull MaybeSource<@NonNull T> other)
Returns aFlowable
which first runs the otherMaybeSource
then the currentFlowable
if the other succeeded or completed normally.@NonNull Flowable<T>
startWith(@NonNull SingleSource<@NonNull T> other)
Returns aFlowable
which first runs the otherSingleSource
then the currentFlowable
if the other succeeded normally.@NonNull Flowable<T>
startWith(@NonNull org.reactivestreams.Publisher<? extends @NonNull T> other)
Returns aFlowable
that emits the items in a specifiedPublisher
before it begins to emit items emitted by the currentFlowable
.@NonNull Flowable<T>
startWithArray(@NonNull T... items)
Returns aFlowable
that emits the specified items before it begins to emit items emitted by the currentFlowable
.@NonNull Flowable<T>
startWithItem(@NonNull T item)
Returns aFlowable
that emits a specified item before it begins to emit items emitted by the currentFlowable
.@NonNull Flowable<T>
startWithIterable(@NonNull java.lang.Iterable<? extends @NonNull T> items)
Returns aFlowable
that emits the items in a specifiedIterable
before it begins to emit items emitted by the currentFlowable
.@NonNull Disposable
subscribe()
Subscribes to the currentFlowable
and ignoresonNext
andonComplete
emissions.void
subscribe(@NonNull FlowableSubscriber<? super @NonNull T> subscriber)
Establish a connection between thisFlowable
and the givenFlowableSubscriber
and start streaming events based on the demand of theFlowableSubscriber
.@NonNull Disposable
subscribe(@NonNull Consumer<? super @NonNull T> onNext)
Subscribes to the currentFlowable
and provides a callback to handle the items it emits.@NonNull Disposable
subscribe(@NonNull Consumer<? super @NonNull T> onNext, @NonNull Consumer<? super java.lang.Throwable> onError)
Subscribes to the currentFlowable
and provides callbacks to handle the items it emits and any error notification it issues.@NonNull Disposable
subscribe(@NonNull Consumer<? super @NonNull T> onNext, @NonNull Consumer<? super java.lang.Throwable> onError, @NonNull Action onComplete)
Subscribes to the currentFlowable
and provides callbacks to handle the items it emits and any error or completion notification it issues.@NonNull Disposable
subscribe(@NonNull Consumer<? super @NonNull T> onNext, @NonNull Consumer<? super java.lang.Throwable> onError, @NonNull Action onComplete, @NonNull DisposableContainer container)
Wraps the given onXXX callbacks into aDisposable
Subscriber
, adds it to the givenDisposableContainer
and ensures, that if the upstream terminates or this particularDisposable
is disposed, theSubscriber
is removed from the given container.void
subscribe(@NonNull org.reactivestreams.Subscriber<? super @NonNull T> subscriber)
protected abstract void
subscribeActual(@NonNull org.reactivestreams.Subscriber<? super @NonNull T> subscriber)
Operator implementations (both source and intermediate) should implement this method that performs the necessary business logic and handles the incomingSubscriber
s.@NonNull Flowable<T>
subscribeOn(@NonNull Scheduler scheduler)
@NonNull Flowable<T>
subscribeOn(@NonNull Scheduler scheduler, boolean requestOn)
Asynchronously subscribesSubscriber
s to the currentFlowable
on the specifiedScheduler
optionally reroutes requests from other threads to the sameScheduler
thread.<@NonNull E extends org.reactivestreams.Subscriber<? super @NonNull T>>
EsubscribeWith(@NonNull E subscriber)
Subscribes a givenSubscriber
(subclass) to thisFlowable
and returns the givenSubscriber
as is.@NonNull Flowable<T>
switchIfEmpty(@NonNull org.reactivestreams.Publisher<? extends @NonNull T> other)
Returns aFlowable
that emits the items emitted by the currentFlowable
or the items of an alternatePublisher
if the currentFlowable
is empty.<@NonNull R>
@NonNull Flowable<R>switchMap(@NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper)
Returns a newFlowable
by applying a function that you supply to each item emitted by the currentFlowable
that returns aPublisher
, and then emitting the items emitted by the most recently emitted of thesePublisher
s.<@NonNull R>
@NonNull Flowable<R>switchMap(@NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper, int bufferSize)
Returns a newFlowable
by applying a function that you supply to each item emitted by the currentFlowable
that returns aPublisher
, and then emitting the items emitted by the most recently emitted of thesePublisher
s.(package private) <R> Flowable<R>
switchMap0(Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends R>> mapper, int bufferSize, boolean delayError)
@NonNull Completable
switchMapCompletable(@NonNull Function<? super @NonNull T,? extends CompletableSource> mapper)
Maps the upstream values intoCompletableSource
s, subscribes to the newer one while disposing the subscription to the previousCompletableSource
, thus keeping at most one activeCompletableSource
running.@NonNull Completable
switchMapCompletableDelayError(@NonNull Function<? super @NonNull T,? extends CompletableSource> mapper)
Maps the upstream values intoCompletableSource
s, subscribes to the newer one while disposing the subscription to the previousCompletableSource
, thus keeping at most one activeCompletableSource
running and delaying any main or inner errors until all of them terminate.<@NonNull R>
@NonNull Flowable<R>switchMapDelayError(@NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper)
Returns a newFlowable
by applying a function that you supply to each item emitted by the currentFlowable
that returns aPublisher
, and then emitting the items emitted by the most recently emitted of thesePublisher
s and delays any error until allPublisher
s terminate.<@NonNull R>
@NonNull Flowable<R>switchMapDelayError(@NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper, int bufferSize)
Returns a newFlowable
by applying a function that you supply to each item emitted by the currentFlowable
that returns aPublisher
, and then emitting the items emitted by the most recently emitted of thesePublisher
s and delays any error until allPublisher
s terminate.<@NonNull R>
@NonNull Flowable<R>switchMapMaybe(@NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper)
Maps the upstream items intoMaybeSource
s 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 thisFlowable
or any of the active innerMaybeSource
s fail.<@NonNull R>
@NonNull Flowable<R>switchMapMaybeDelayError(@NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper)
Maps the upstream items intoMaybeSource
s 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 thisFlowable
or the innerMaybeSource
s until all terminate.<@NonNull R>
@NonNull Flowable<R>switchMapSingle(@NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper)
Maps the upstream items intoSingleSource
s 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 while failing immediately if thisFlowable
or any of the active innerSingleSource
s fail.<@NonNull R>
@NonNull Flowable<R>switchMapSingleDelayError(@NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper)
Maps the upstream items intoSingleSource
s 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, delaying errors from thisFlowable
or the innerSingleSource
s until all terminate.static <@NonNull T>
@NonNull Flowable<T>switchOnNext(@NonNull org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, int bufferSize)
Converts aPublisher
that emitsPublisher
s into aPublisher
that emits the items emitted by the most recently emitted of thosePublisher
s.static <@NonNull T>
@NonNull Flowable<T>switchOnNext(@NonNull org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources)
Converts aPublisher
that emitsPublisher
s into aPublisher
that emits the items emitted by the most recently emitted of thosePublisher
s.static <@NonNull T>
@NonNull Flowable<T>switchOnNextDelayError(@NonNull org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources)
Converts aPublisher
that emitsPublisher
s into aPublisher
that emits the items emitted by the most recently emitted of thosePublisher
s and delays any exception until allPublisher
s terminate.static <@NonNull T>
@NonNull Flowable<T>switchOnNextDelayError(@NonNull org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, int prefetch)
Converts aPublisher
that emitsPublisher
s into aPublisher
that emits the items emitted by the most recently emitted of thosePublisher
s and delays any exception until allPublisher
s terminate.@NonNull Flowable<T>
take(long count)
Returns aFlowable
that emits only the firstcount
items emitted by the currentFlowable
.@NonNull Flowable<T>
take(long time, @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits those items emitted by sourcePublisher
before a specified time runs out.@NonNull Flowable<T>
take(long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns aFlowable
that emits those items emitted by sourcePublisher
before a specified time (on a specifiedScheduler
) runs out.@NonNull Flowable<T>
takeLast(int count)
Returns aFlowable
that emits at most the lastcount
items emitted by the currentFlowable
.@NonNull Flowable<T>
takeLast(long count, long time, @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits at most a specified number of items from the currentFlowable
that were emitted in a specified window of time before the currentFlowable
completed.@NonNull Flowable<T>
takeLast(long count, long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns aFlowable
that emits at most a specified number of items from the currentFlowable
that were emitted in a specified window of time before the currentFlowable
completed, where the timing information is provided by a givenScheduler
.@NonNull Flowable<T>
takeLast(long count, long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, boolean delayError, int bufferSize)
Returns aFlowable
that emits at most a specified number of items from the currentFlowable
that were emitted in a specified window of time before the currentFlowable
completed, where the timing information is provided by a givenScheduler
.@NonNull Flowable<T>
takeLast(long time, @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits the items from the currentFlowable
that were emitted in a specified window of time before the currentFlowable
completed.@NonNull Flowable<T>
takeLast(long time, @NonNull java.util.concurrent.TimeUnit unit, boolean delayError)
Returns aFlowable
that emits the items from the currentFlowable
that were emitted in a specified window of time before the currentFlowable
completed.@NonNull Flowable<T>
takeLast(long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns aFlowable
that emits the items from the currentFlowable
that were emitted in a specified window of time before the currentFlowable
completed, where the timing information is provided by a specifiedScheduler
.@NonNull Flowable<T>
takeLast(long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, boolean delayError)
Returns aFlowable
that emits the items from the currentFlowable
that were emitted in a specified window of time before the currentFlowable
completed, where the timing information is provided by a specifiedScheduler
.@NonNull Flowable<T>
takeLast(long time, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, boolean delayError, int bufferSize)
Returns aFlowable
that emits the items from the currentFlowable
that were emitted in a specified window of time before the currentFlowable
completed, where the timing information is provided by a specifiedScheduler
.@NonNull Flowable<T>
takeUntil(@NonNull Predicate<? super @NonNull T> stopPredicate)
Returns aFlowable
that emits items emitted by the currentFlowable
, checks the specified predicate for each item, and then completes when the condition is satisfied.<@NonNull U>
@NonNull Flowable<T>takeUntil(@NonNull org.reactivestreams.Publisher<@NonNull U> other)
Returns aFlowable
that emits the items emitted by the currentFlowable
until a secondPublisher
emits an item or completes.@NonNull Flowable<T>
takeWhile(@NonNull Predicate<? super @NonNull T> predicate)
Returns aFlowable
that emits items emitted by the currentFlowable
so long as each item satisfied a specified condition, and then completes as soon as this condition is not satisfied.@NonNull TestSubscriber<T>
test()
@NonNull TestSubscriber<T>
test(long initialRequest)
Creates aTestSubscriber
with the given initial request amount and subscribes it to thisFlowable
.@NonNull TestSubscriber<T>
test(long initialRequest, boolean cancel)
Creates aTestSubscriber
with the given initial request amount, optionally cancels it before the subscription and subscribes it to thisFlowable
.@NonNull Flowable<T>
throttleFirst(long windowDuration, @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits only the first item emitted by the currentFlowable
during sequential time windows of a specified duration.@NonNull Flowable<T>
throttleFirst(long skipDuration, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns aFlowable
that emits only the first item emitted by the currentFlowable
during sequential time windows of a specified duration, where the windows are managed by a specifiedScheduler
.@NonNull Flowable<T>
throttleFirst(long skipDuration, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, @NonNull Consumer<? super @NonNull T> onDropped)
Returns aFlowable
that emits only the first item emitted by the currentFlowable
during sequential time windows of a specified duration, where the windows are managed by a specifiedScheduler
.@NonNull Flowable<T>
throttleLast(long intervalDuration, @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits only the last item emitted by the currentFlowable
during sequential time windows of a specified duration.@NonNull Flowable<T>
throttleLast(long intervalDuration, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns aFlowable
that emits only the last item emitted by the currentFlowable
during sequential time windows of a specified duration, where the duration is governed by a specifiedScheduler
.@NonNull Flowable<T>
throttleLast(long intervalDuration, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, @NonNull Consumer<? super @NonNull T> onDropped)
Returns aFlowable
that emits only the last item emitted by the currentFlowable
during sequential time windows of a specified duration, where the duration is governed by a specifiedScheduler
.@NonNull Flowable<T>
throttleLatest(long timeout, @NonNull java.util.concurrent.TimeUnit unit)
Throttles items from the upstreamFlowable
by first emitting the next item from upstream, then periodically emitting the latest item (if any) when the specified timeout elapses between them.@NonNull Flowable<T>
throttleLatest(long timeout, @NonNull java.util.concurrent.TimeUnit unit, boolean emitLast)
Throttles items from the upstreamFlowable
by first emitting the next item from upstream, then periodically emitting the latest item (if any) when the specified timeout elapses between them.@NonNull Flowable<T>
throttleLatest(long timeout, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Throttles items from the upstreamFlowable
by first emitting the next item from upstream, then periodically emitting the latest item (if any) when the specified timeout elapses between them.@NonNull Flowable<T>
throttleLatest(long timeout, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, boolean emitLast)
Throttles items from the upstreamFlowable
by first emitting the next item from upstream, then periodically emitting the latest item (if any) when the specified timeout elapses between them.@NonNull Flowable<T>
throttleLatest(long timeout, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, boolean emitLast, @NonNull Consumer<? super @NonNull T> onDropped)
Throttles items from the upstreamFlowable
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.@NonNull Flowable<T>
throttleWithTimeout(long timeout, @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that mirrors the currentFlowable
, except that it drops items emitted by the currentFlowable
that are followed by newer items before a timeout value expires.@NonNull Flowable<T>
throttleWithTimeout(long timeout, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns aFlowable
that mirrors the currentFlowable
, except that it drops items emitted by the currentFlowable
that are followed by newer items before a timeout value expires on a specifiedScheduler
.@NonNull Flowable<T>
throttleWithTimeout(long timeout, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, @NonNull Consumer<? super @NonNull T> onDropped)
Returns aFlowable
that mirrors the currentFlowable
, except that it drops items emitted by the currentFlowable
that are followed by newer items before a timeout value expires on a specifiedScheduler
.@NonNull Flowable<Timed<T>>
timeInterval()
Returns aFlowable
that emits records of the time interval between consecutive items emitted by the currentFlowable
.@NonNull Flowable<Timed<T>>
timeInterval(@NonNull Scheduler scheduler)
Returns aFlowable
that emits records of the time interval between consecutive items emitted by the currentFlowable
, where this interval is computed on a specifiedScheduler
.@NonNull Flowable<Timed<T>>
timeInterval(@NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits records of the time interval between consecutive items emitted by the currentFlowable
.@NonNull Flowable<Timed<T>>
timeInterval(@NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns aFlowable
that emits records of the time interval between consecutive items emitted by the currentFlowable
, where this interval is computed on a specifiedScheduler
.@NonNull Flowable<T>
timeout(long timeout, @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that mirrors the currentFlowable
but applies a timeout policy for each emitted item.@NonNull Flowable<T>
timeout(long timeout, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns aFlowable
that mirrors the currentFlowable
but applies a timeout policy for each emitted item, where this policy is governed by a specifiedScheduler
.@NonNull Flowable<T>
timeout(long timeout, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, @NonNull org.reactivestreams.Publisher<? extends @NonNull T> fallback)
Returns aFlowable
that mirrors the currentFlowable
but applies a timeout policy for each emitted item using a specifiedScheduler
.@NonNull Flowable<T>
timeout(long timeout, @NonNull java.util.concurrent.TimeUnit unit, @NonNull org.reactivestreams.Publisher<? extends @NonNull T> fallback)
Returns aFlowable
that mirrors the currentFlowable
but applies a timeout policy for each emitted item.<@NonNull V>
@NonNull Flowable<T>timeout(@NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<@NonNull V>> itemTimeoutIndicator)
Returns aFlowable
that mirrors the currentFlowable
, but notifiesSubscriber
s of aTimeoutException
if an item emitted by the currentFlowable
doesn't arrive within a window of time after the emission of the previous item, where that period of time is measured by aPublisher
that is a function of the previous item.<@NonNull V>
@NonNull Flowable<T>timeout(@NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<@NonNull V>> itemTimeoutIndicator, @NonNull org.reactivestreams.Publisher<? extends @NonNull T> fallback)
Returns aFlowable
that mirrors the currentFlowable
, but that switches to a fallbackPublisher
if an item emitted by the currentFlowable
doesn't arrive within a window of time after the emission of the previous item, where that period of time is measured by aPublisher
that is a function of the previous item.<@NonNull U,@NonNull V>
@NonNull Flowable<T>timeout(@NonNull org.reactivestreams.Publisher<@NonNull U> firstTimeoutIndicator, @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<@NonNull V>> itemTimeoutIndicator)
Returns aFlowable
that mirrors the currentFlowable
, but notifiesSubscriber
s of aTimeoutException
if either the first item emitted by the currentFlowable
or any subsequent item doesn't arrive within time windows defined by otherPublisher
s.<@NonNull U,@NonNull V>
@NonNull Flowable<T>timeout(@NonNull org.reactivestreams.Publisher<@NonNull U> firstTimeoutIndicator, @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<@NonNull V>> itemTimeoutIndicator, @NonNull org.reactivestreams.Publisher<? extends @NonNull T> fallback)
Returns aFlowable
that mirrors the currentFlowable
, but switches to a fallbackPublisher
if either the first item emitted by the currentFlowable
or any subsequent item doesn't arrive within time windows defined by otherPublisher
s.private Flowable<T>
timeout0(long timeout, java.util.concurrent.TimeUnit unit, org.reactivestreams.Publisher<? extends @NonNull T> fallback, Scheduler scheduler)
private <@NonNull U,@NonNull V>
Flowable<T>timeout0(org.reactivestreams.Publisher<@NonNull U> firstTimeoutIndicator, Function<? super @NonNull T,? extends org.reactivestreams.Publisher<@NonNull V>> itemTimeoutIndicator, org.reactivestreams.Publisher<? extends @NonNull T> fallback)
static @NonNull Flowable<java.lang.Long>
timer(long delay, @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits0L
after a specified delay, and then completes.static @NonNull Flowable<java.lang.Long>
timer(long delay, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns aFlowable
that emits0L
after a specified delay, on a specifiedScheduler
, and then completes.@NonNull Flowable<Timed<T>>
timestamp()
@NonNull Flowable<Timed<T>>
timestamp(@NonNull Scheduler scheduler)
@NonNull Flowable<Timed<T>>
timestamp(@NonNull java.util.concurrent.TimeUnit unit)
@NonNull Flowable<Timed<T>>
timestamp(@NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
<@NonNull R>
Rto(@NonNull FlowableConverter<@NonNull T,? extends @NonNull R> converter)
Calls the specified converter function during assembly time and returns its resulting value.@NonNull java.util.concurrent.Future<T>
toFuture()
Returns aFuture
representing the only value emitted by thisFlowable
.@NonNull Single<java.util.List<T>>
toList()
Returns aSingle
that emits a single item, a list composed of all the items emitted by the finite upstream sourcePublisher
.@NonNull Single<java.util.List<T>>
toList(int capacityHint)
Returns aSingle
that emits a single item, a list composed of all the items emitted by the finite sourcePublisher
.<@NonNull U extends java.util.Collection<? super @NonNull T>>
@NonNull Single<U>toList(@NonNull Supplier<@NonNull U> collectionSupplier)
Returns aSingle
that emits a single item, a list composed of all the items emitted by the finite sourcePublisher
.<@NonNull K>
@NonNull Single<java.util.Map<K,T>>toMap(@NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector)
Returns aSingle
that emits a singleHashMap
containing all items emitted by the finite sourcePublisher
, mapped by the keys returned by a specifiedkeySelector
function.<@NonNull K,@NonNull V>
@NonNull Single<java.util.Map<K,V>>toMap(@NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector, @NonNull Function<? super @NonNull T,? extends @NonNull V> valueSelector)
Returns aSingle
that emits a singleHashMap
containing values corresponding to items emitted by the finite sourcePublisher
, mapped by the keys returned by a specifiedkeySelector
function.<@NonNull K,@NonNull V>
@NonNull Single<java.util.Map<K,V>>toMap(@NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector, @NonNull Function<? super @NonNull T,? extends @NonNull V> valueSelector, @NonNull Supplier<? extends java.util.Map<@NonNull K,@NonNull V>> mapSupplier)
Returns aSingle
that emits a singleMap
, returned by a specifiedmapFactory
function, that contains keys and values extracted from the items emitted by the finite sourcePublisher
.<@NonNull K>
@NonNull Single<java.util.Map<K,java.util.Collection<T>>>toMultimap(@NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector)
Returns aSingle
that emits a singleHashMap
that contains anArrayList
of items emitted by the finite sourcePublisher
keyed by a specifiedkeySelector
function.<@NonNull K,@NonNull V>
@NonNull Single<java.util.Map<K,java.util.Collection<V>>>toMultimap(@NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector, @NonNull Function<? super @NonNull T,? extends @NonNull V> valueSelector)
Returns aSingle
that emits a singleHashMap
that contains anArrayList
of values extracted by a specifiedvalueSelector
function from items emitted by the finite sourcePublisher
, keyed by a specifiedkeySelector
function.<@NonNull K,@NonNull V>
@NonNull Single<java.util.Map<K,java.util.Collection<V>>>toMultimap(@NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector, @NonNull Function<? super @NonNull T,? extends @NonNull V> valueSelector, @NonNull Supplier<? extends java.util.Map<@NonNull K,java.util.Collection<@NonNull V>>> mapSupplier, @NonNull Function<? super @NonNull K,? extends java.util.Collection<? super @NonNull V>> collectionFactory)
Returns aSingle
that emits a singleMap
, returned by a specifiedmapFactory
function, that contains a custom collection of values, extracted by a specifiedvalueSelector
function from items emitted by the finite sourcePublisher
, and keyed by thekeySelector
function.<@NonNull K,@NonNull V>
@NonNull Single<java.util.Map<K,java.util.Collection<V>>>toMultimap(@NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector, @NonNull Function<? super @NonNull T,? extends @NonNull V> valueSelector, @NonNull Supplier<java.util.Map<@NonNull K,java.util.Collection<@NonNull V>>> mapSupplier)
Returns aSingle
that emits a singleMap
, returned by a specifiedmapFactory
function, that contains anArrayList
of values, extracted by a specifiedvalueSelector
function from items emitted by the finite sourcePublisher
and keyed by thekeySelector
function.@NonNull Observable<T>
toObservable()
Converts the currentFlowable
into a non-backpressuredObservable
.@NonNull Single<java.util.List<T>>
toSortedList()
Returns aSingle
that emits aList
that contains the items emitted by the finite sourcePublisher
, in a sorted order.@NonNull Single<java.util.List<T>>
toSortedList(int capacityHint)
Returns aSingle
that emits aList
that contains the items emitted by the finite sourcePublisher
, in a sorted order.@NonNull Single<java.util.List<T>>
toSortedList(@NonNull java.util.Comparator<? super @NonNull T> comparator)
Returns aSingle
that emits aList
that contains the items emitted by the finite sourcePublisher
, in a sorted order based on a specified comparison function.@NonNull Single<java.util.List<T>>
toSortedList(@NonNull java.util.Comparator<? super @NonNull T> comparator, int capacityHint)
Returns aSingle
that emits aList
that contains the items emitted by the finite sourcePublisher
, in a sorted order based on a specified comparison function.static <@NonNull T>
@NonNull Flowable<T>unsafeCreate(@NonNull org.reactivestreams.Publisher<@NonNull T> onSubscribe)
Create aFlowable
by wrapping aPublisher
which has to be implemented according to the Reactive Streams specification by handling backpressure and cancellation correctly; no safeguards are provided by theFlowable
itself.@NonNull Flowable<T>
unsubscribeOn(@NonNull Scheduler scheduler)
Cancels the currentFlowable
asynchronously by invokingSubscription.cancel()
on the specifiedScheduler
.static <@NonNull T,@NonNull D>
@NonNull Flowable<T>using(@NonNull Supplier<? extends @NonNull D> resourceSupplier, @NonNull Function<? super @NonNull D,? extends org.reactivestreams.Publisher<? extends @NonNull T>> sourceSupplier, @NonNull Consumer<? super @NonNull D> resourceCleanup)
Constructs aFlowable
that creates a dependent resource object, aPublisher
with that resource and calls the providedresourceDisposer
function if this inner source terminates or the downstream cancels the flow.static <@NonNull T,@NonNull D>
@NonNull Flowable<T>using(@NonNull Supplier<? extends @NonNull D> resourceSupplier, @NonNull Function<? super @NonNull D,? extends org.reactivestreams.Publisher<? extends @NonNull T>> sourceSupplier, @NonNull Consumer<? super @NonNull D> resourceCleanup, boolean eager)
Constructs aFlowable
that creates a dependent resource object, aPublisher
with that resource and calls the providedresourceDisposer
function if this inner source terminates or the downstream disposes the flow; doing it before these end-states have been reached ifeager == true
, after otherwise.@NonNull Flowable<Flowable<T>>
window(long count)
Returns aFlowable
that emits windows of items it collects from the currentFlowable
.@NonNull Flowable<Flowable<T>>
window(long count, long skip)
Returns aFlowable
that emits windows of items it collects from the currentFlowable
.@NonNull Flowable<Flowable<T>>
window(long count, long skip, int bufferSize)
Returns aFlowable
that emits windows of items it collects from the currentFlowable
.@NonNull Flowable<Flowable<T>>
window(long timespan, long timeskip, @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits windows of items it collects from the currentFlowable
.@NonNull Flowable<Flowable<T>>
window(long timespan, long timeskip, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns aFlowable
that emits windows of items it collects from the currentFlowable
.@NonNull Flowable<Flowable<T>>
window(long timespan, long timeskip, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, int bufferSize)
Returns aFlowable
that emits windows of items it collects from the currentFlowable
.@NonNull Flowable<Flowable<T>>
window(long timespan, @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits windows of items it collects from the currentFlowable
.@NonNull Flowable<Flowable<T>>
window(long timespan, @NonNull java.util.concurrent.TimeUnit unit, long count)
Returns aFlowable
that emits windows of items it collects from the currentFlowable
.@NonNull Flowable<Flowable<T>>
window(long timespan, @NonNull java.util.concurrent.TimeUnit unit, long count, boolean restart)
Returns aFlowable
that emits windows of items it collects from the currentFlowable
.@NonNull Flowable<Flowable<T>>
window(long timespan, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler)
Returns aFlowable
that emits windows of items it collects from the currentFlowable
.@NonNull Flowable<Flowable<T>>
window(long timespan, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, long count)
Returns aFlowable
that emits windows of items it collects from the currentFlowable
.@NonNull Flowable<Flowable<T>>
window(long timespan, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, long count, boolean restart)
Returns aFlowable
that emits windows of items it collects from the currentFlowable
.@NonNull Flowable<Flowable<T>>
window(long timespan, @NonNull java.util.concurrent.TimeUnit unit, @NonNull Scheduler scheduler, long count, boolean restart, int bufferSize)
Returns aFlowable
that emits windows of items it collects from the currentFlowable
.<@NonNull B>
@NonNull Flowable<Flowable<T>>window(@NonNull org.reactivestreams.Publisher<@NonNull B> boundaryIndicator)
Returns aFlowable
that emits non-overlapping windows of items it collects from the currentFlowable
where the boundary of each window is determined by the items emitted from a specified boundary-governingPublisher
.<@NonNull B>
@NonNull Flowable<Flowable<T>>window(@NonNull org.reactivestreams.Publisher<@NonNull B> boundaryIndicator, int bufferSize)
Returns aFlowable
that emits non-overlapping windows of items it collects from the currentFlowable
where the boundary of each window is determined by the items emitted from a specified boundary-governingPublisher
.<@NonNull U,@NonNull V>
@NonNull Flowable<Flowable<T>>window(@NonNull org.reactivestreams.Publisher<@NonNull U> openingIndicator, @NonNull Function<? super @NonNull U,? extends org.reactivestreams.Publisher<@NonNull V>> closingIndicator)
Returns aFlowable
that emits windows of items it collects from the currentFlowable
.<@NonNull U,@NonNull V>
@NonNull Flowable<Flowable<T>>window(@NonNull org.reactivestreams.Publisher<@NonNull U> openingIndicator, @NonNull Function<? super @NonNull U,? extends org.reactivestreams.Publisher<@NonNull V>> closingIndicator, int bufferSize)
Returns aFlowable
that emits windows of items it collects from the currentFlowable
.<@NonNull R>
@NonNull Flowable<R>withLatestFrom(@NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<?>> others, @NonNull Function<? super java.lang.Object[],@NonNull R> combiner)
Combines the value emission from the currentFlowable
with the latest emissions from the otherPublisher
s via a function to produce the output item.<@NonNull U,@NonNull R>
@NonNull Flowable<R>withLatestFrom(@NonNull org.reactivestreams.Publisher<? extends @NonNull U> other, @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> combiner)
Merges the specifiedPublisher
into the currentFlowable
sequence by using theresultSelector
function only when the currentFlowable
(this instance) emits an item.<@NonNull R>
@NonNull Flowable<R>withLatestFrom(@NonNull org.reactivestreams.Publisher<?>[] others, @NonNull Function<? super java.lang.Object[],@NonNull R> combiner)
Combines the value emission from the currentFlowable
with the latest emissions from the otherPublisher
s via a function to produce the output item.<@NonNull T1,@NonNull T2,@NonNull R>
@NonNull Flowable<R>withLatestFrom(@NonNull org.reactivestreams.Publisher<@NonNull T1> source1, @NonNull org.reactivestreams.Publisher<@NonNull T2> source2, @NonNull Function3<? super @NonNull T,? super @NonNull T1,? super @NonNull T2,@NonNull R> combiner)
Combines the value emission from the currentFlowable
with the latest emissions from the otherPublisher
s via a function to produce the output item.<@NonNull T1,@NonNull T2,@NonNull T3,@NonNull R>
@NonNull Flowable<R>withLatestFrom(@NonNull org.reactivestreams.Publisher<@NonNull T1> source1, @NonNull org.reactivestreams.Publisher<@NonNull T2> source2, @NonNull org.reactivestreams.Publisher<@NonNull T3> source3, @NonNull Function4<? super @NonNull T,? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,@NonNull R> combiner)
Combines the value emission from the currentFlowable
with the latest emissions from the otherPublisher
s via a function to produce the output item.<@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull R>
@NonNull Flowable<R>withLatestFrom(@NonNull org.reactivestreams.Publisher<@NonNull T1> source1, @NonNull org.reactivestreams.Publisher<@NonNull T2> source2, @NonNull org.reactivestreams.Publisher<@NonNull T3> source3, @NonNull org.reactivestreams.Publisher<@NonNull T4> source4, @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 currentFlowable
with the latest emissions from the otherPublisher
s via a function to produce the output item.static <@NonNull T,@NonNull R>
@NonNull Flowable<R>zip(@NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, @NonNull Function<? super java.lang.Object[],? extends @NonNull R> zipper)
Returns aFlowable
that emits the results of a specified combiner function applied to combinations of items emitted, in sequence, by anIterable
of otherPublisher
s.static <@NonNull T,@NonNull R>
@NonNull Flowable<R>zip(@NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, @NonNull Function<? super java.lang.Object[],? extends @NonNull R> zipper, boolean delayError, int bufferSize)
Returns aFlowable
that emits the results of a specified combiner function applied to combinations of items emitted, in sequence, by anIterable
of otherPublisher
s.static <@NonNull T1,@NonNull T2,@NonNull R>
@NonNull Flowable<R>zip(@NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull BiFunction<? super @NonNull T1,? super @NonNull T2,? extends @NonNull R> zipper)
Returns aFlowable
that emits the results of a specified combiner function applied to combinations of two items emitted, in sequence, by two otherPublisher
s.static <@NonNull T1,@NonNull T2,@NonNull R>
@NonNull Flowable<R>zip(@NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull BiFunction<? super @NonNull T1,? super @NonNull T2,? extends @NonNull R> zipper, boolean delayError)
Returns aFlowable
that emits the results of a specified combiner function applied to combinations of two items emitted, in sequence, by two otherPublisher
s.static <@NonNull T1,@NonNull T2,@NonNull R>
@NonNull Flowable<R>zip(@NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull BiFunction<? super @NonNull T1,? super @NonNull T2,? extends @NonNull R> zipper, boolean delayError, int bufferSize)
Returns aFlowable
that emits the results of a specified combiner function applied to combinations of two items emitted, in sequence, by two otherPublisher
s.static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull R>
@NonNull Flowable<R>zip(@NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull org.reactivestreams.Publisher<? extends @NonNull T3> source3, @NonNull Function3<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? extends @NonNull R> zipper)
Returns aFlowable
that emits the results of a specified combiner function applied to combinations of three items emitted, in sequence, by three otherPublisher
s.static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull R>
@NonNull Flowable<R>zip(@NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull org.reactivestreams.Publisher<? extends @NonNull T3> source3, @NonNull org.reactivestreams.Publisher<? extends @NonNull T4> source4, @NonNull Function4<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? extends @NonNull R> zipper)
Returns aFlowable
that emits the results of a specified combiner function applied to combinations of four items emitted, in sequence, by four otherPublisher
s.static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull R>
@NonNull Flowable<R>zip(@NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull org.reactivestreams.Publisher<? extends @NonNull T3> source3, @NonNull org.reactivestreams.Publisher<? extends @NonNull T4> source4, @NonNull org.reactivestreams.Publisher<? extends @NonNull T5> source5, @NonNull Function5<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? super @NonNull T5,? extends @NonNull R> zipper)
Returns aFlowable
that emits the results of a specified combiner function applied to combinations of five items emitted, in sequence, by five otherPublisher
s.static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull R>
@NonNull Flowable<R>zip(@NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull org.reactivestreams.Publisher<? extends @NonNull T3> source3, @NonNull org.reactivestreams.Publisher<? extends @NonNull T4> source4, @NonNull org.reactivestreams.Publisher<? extends @NonNull T5> source5, @NonNull org.reactivestreams.Publisher<? extends @NonNull T6> source6, @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 aFlowable
that emits the results of a specified combiner function applied to combinations of six items emitted, in sequence, by six otherPublisher
s.static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull T7,@NonNull R>
@NonNull Flowable<R>zip(@NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull org.reactivestreams.Publisher<? extends @NonNull T3> source3, @NonNull org.reactivestreams.Publisher<? extends @NonNull T4> source4, @NonNull org.reactivestreams.Publisher<? extends @NonNull T5> source5, @NonNull org.reactivestreams.Publisher<? extends @NonNull T6> source6, @NonNull org.reactivestreams.Publisher<? extends @NonNull T7> source7, @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 aFlowable
that emits the results of a specified combiner function applied to combinations of seven items emitted, in sequence, by seven otherPublisher
s.static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull T7,@NonNull T8,@NonNull R>
@NonNull Flowable<R>zip(@NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull org.reactivestreams.Publisher<? extends @NonNull T3> source3, @NonNull org.reactivestreams.Publisher<? extends @NonNull T4> source4, @NonNull org.reactivestreams.Publisher<? extends @NonNull T5> source5, @NonNull org.reactivestreams.Publisher<? extends @NonNull T6> source6, @NonNull org.reactivestreams.Publisher<? extends @NonNull T7> source7, @NonNull org.reactivestreams.Publisher<? extends @NonNull T8> source8, @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 aFlowable
that emits the results of a specified combiner function applied to combinations of eight items emitted, in sequence, by eight otherPublisher
s.static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull T7,@NonNull T8,@NonNull T9,@NonNull R>
@NonNull Flowable<R>zip(@NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull org.reactivestreams.Publisher<? extends @NonNull T3> source3, @NonNull org.reactivestreams.Publisher<? extends @NonNull T4> source4, @NonNull org.reactivestreams.Publisher<? extends @NonNull T5> source5, @NonNull org.reactivestreams.Publisher<? extends @NonNull T6> source6, @NonNull org.reactivestreams.Publisher<? extends @NonNull T7> source7, @NonNull org.reactivestreams.Publisher<? extends @NonNull T8> source8, @NonNull org.reactivestreams.Publisher<? extends @NonNull T9> source9, @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 aFlowable
that emits the results of a specified combiner function applied to combinations of nine items emitted, in sequence, by nine otherPublisher
s.static <@NonNull T,@NonNull R>
@NonNull Flowable<R>zipArray(@NonNull Function<? super java.lang.Object[],? extends @NonNull R> zipper, boolean delayError, int bufferSize, @NonNull org.reactivestreams.Publisher<? extends @NonNull T>... sources)
Returns aFlowable
that emits the results of a specified combiner function applied to combinations of items emitted, in sequence, by an array of otherPublisher
s.<@NonNull U,@NonNull R>
@NonNull Flowable<R>zipWith(@NonNull java.lang.Iterable<@NonNull U> other, @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> zipper)
Returns aFlowable
that emits items that are the result of applying a specified function to pairs of values, one each from the currentFlowable
and a specifiedIterable
sequence.<@NonNull U,@NonNull R>
@NonNull Flowable<R>zipWith(@NonNull org.reactivestreams.Publisher<? extends @NonNull U> other, @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> zipper)
Returns aFlowable
that emits items that are the result of applying a specified function to pairs of values, one each from the currentFlowable
and another specifiedPublisher
.<@NonNull U,@NonNull R>
@NonNull Flowable<R>zipWith(@NonNull org.reactivestreams.Publisher<? extends @NonNull U> other, @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> zipper, boolean delayError)
Returns aFlowable
that emits items that are the result of applying a specified function to pairs of values, one each from the currentFlowable
and another specifiedPublisher
.<@NonNull U,@NonNull R>
@NonNull Flowable<R>zipWith(@NonNull org.reactivestreams.Publisher<? extends @NonNull U> other, @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> zipper, boolean delayError, int bufferSize)
Returns aFlowable
that emits items that are the result of applying a specified function to pairs of values, one each from the currentFlowable
and another specifiedPublisher
.
-
-
-
Method Detail
-
amb
@CheckReturnValue @NonNull @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> amb(@NonNull @NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources)
Mirrors the onePublisher
in anIterable
of severalPublisher
s that first either emits an item or sends a termination notification.When one of the
Publisher
s signal an item or terminates first, all subscriptions to the otherPublisher
s are canceled.- Backpressure:
- The operator itself doesn't interfere with backpressure which is determined by the winning
Publisher
's backpressure behavior. - Scheduler:
amb
does not operate by default on a particularScheduler
.- Error handling:
-
If any of the losing
Publisher
s signals an error, the error is routed to the global error handler viaRxJavaPlugins.onError(Throwable)
.
- Type Parameters:
T
- the common element type- Parameters:
sources
- anIterable
ofPublisher
s sources competing to react first. A subscription to eachPublisher
will occur in the same order as in thisIterable
.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
- See Also:
- ReactiveX operators documentation: Amb
-
ambArray
@CheckReturnValue @NonNull @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") @SafeVarargs public static <@NonNull T> @NonNull Flowable<T> ambArray(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T>... sources)
Mirrors the onePublisher
in an array of severalPublisher
s that first either emits an item or sends a termination notification.When one of the
Publisher
s signal an item or terminates first, all subscriptions to the otherPublisher
s are canceled.- Backpressure:
- The operator itself doesn't interfere with backpressure which is determined by the winning
Publisher
's backpressure behavior. - Scheduler:
ambArray
does not operate by default on a particularScheduler
.- Error handling:
-
If any of the losing
Publisher
s signals an error, the error is routed to the global error handler viaRxJavaPlugins.onError(Throwable)
.
- Type Parameters:
T
- the common element type- Parameters:
sources
- an array ofPublisher
sources competing to react first. A subscription to eachPublisher
will occur in the same order as in this array.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
- See Also:
- ReactiveX operators documentation: Amb
-
bufferSize
@CheckReturnValue public static int bufferSize()
Returns the default internal buffer size used by most async operators.The value can be overridden via system parameter
rx3.buffer-size
before theFlowable
class is loaded.- Returns:
- the default internal buffer size.
-
combineLatestArray
@SchedulerSupport("none") @CheckReturnValue @BackpressureSupport(FULL) @NonNull public static <@NonNull T,@NonNull R> @NonNull Flowable<R> combineLatestArray(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T>[] sources, @NonNull @NonNull Function<? super java.lang.Object[],? extends @NonNull R> combiner)
Combines a collection of sourcePublisher
s by emitting an item that aggregates the latest values of each of the sourcePublisher
s each time an item is received from any of the sourcePublisher
s, 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 anObject[]
instead. Unfortunately, aFunction<Integer[], R>
passed to the method would trigger aClassCastException
.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 until that point). If that input source is also synchronous, other sources after it will not be subscribed to.
If the provided array of source
Publisher
s is empty, the resulting sequence completes immediately without emitting any items and without any calls to the combiner function.- Backpressure:
- The returned
Publisher
honors backpressure from downstream. The sourcePublisher
s are requested in a bounded manner, however, their backpressure is not enforced (the operator won't signalMissingBackpressureException
) and may lead toOutOfMemoryError
due to internal buffer bloat. - Scheduler:
combineLatestArray
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common base type of source valuesR
- the result type- Parameters:
sources
- the collection of sourcePublisher
scombiner
- the aggregation function used to combine the items emitted by the sourcePublisher
s- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
orcombiner
isnull
- See Also:
- ReactiveX operators documentation: CombineLatest
-
combineLatestArray
@SchedulerSupport("none") @CheckReturnValue @NonNull @BackpressureSupport(FULL) public static <@NonNull T,@NonNull R> @NonNull Flowable<R> combineLatestArray(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T>[] sources, @NonNull @NonNull Function<? super java.lang.Object[],? extends @NonNull R> combiner, int bufferSize)
Combines a collection of sourcePublisher
s by emitting an item that aggregates the latest values of each of the sourcePublisher
s each time an item is received from any of the sourcePublisher
s, 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 anObject[]
instead. Unfortunately, aFunction<Integer[], R>
passed to the method would trigger aClassCastException
.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 until that point). If that input source is also synchronous, other sources after it will not be subscribed to.
If the provided array of source
Publisher
s is empty, the resulting sequence completes immediately without emitting any items and without any calls to the combiner function.- Backpressure:
- The returned
Publisher
honors backpressure from downstream. The sourcePublisher
s are requested in a bounded manner, however, their backpressure is not enforced (the operator won't signalMissingBackpressureException
) and may lead toOutOfMemoryError
due to internal buffer bloat. - Scheduler:
combineLatestArray
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common base type of source valuesR
- the result type- Parameters:
sources
- the collection of sourcePublisher
scombiner
- the aggregation function used to combine the items emitted by the sourcePublisher
sbufferSize
- the internal buffer size and prefetch amount applied to every sourceFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
orcombiner
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: CombineLatest
-
combineLatest
@SchedulerSupport("none") @CheckReturnValue @BackpressureSupport(FULL) @NonNull public static <@NonNull T,@NonNull R> @NonNull Flowable<R> combineLatest(@NonNull @NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, @NonNull @NonNull Function<? super java.lang.Object[],? extends @NonNull R> combiner)
Combines a collection of sourcePublisher
s by emitting an item that aggregates the latest values of each of the sourcePublisher
s each time an item is received from any of the sourcePublisher
s, 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 anObject[]
instead. Unfortunately, aFunction<Integer[], R>
passed to the method would trigger aClassCastException
.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 until that point). If that input source is also synchronous, other sources after it will not be subscribed to.
If the provided iterable of source
Publisher
s is empty, the resulting sequence completes immediately without emitting any items and without any calls to the combiner function.- Backpressure:
- The returned
Publisher
honors backpressure from downstream. The sourcePublisher
s are requested in a bounded manner, however, their backpressure is not enforced (the operator won't signalMissingBackpressureException
) and may lead toOutOfMemoryError
due to internal buffer bloat. - Scheduler:
combineLatest
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common base type of source valuesR
- the result type- Parameters:
sources
- the collection of sourcePublisher
scombiner
- the aggregation function used to combine the items emitted by the sourcePublisher
s- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
orcombiner
isnull
- See Also:
- ReactiveX operators documentation: CombineLatest
-
combineLatest
@SchedulerSupport("none") @CheckReturnValue @NonNull @BackpressureSupport(FULL) public static <@NonNull T,@NonNull R> @NonNull Flowable<R> combineLatest(@NonNull @NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, @NonNull @NonNull Function<? super java.lang.Object[],? extends @NonNull R> combiner, int bufferSize)
Combines a collection of sourcePublisher
s by emitting an item that aggregates the latest values of each of the sourcePublisher
s each time an item is received from any of the sourcePublisher
s, 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 anObject[]
instead. Unfortunately, aFunction<Integer[], R>
passed to the method would trigger aClassCastException
.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 until that point). If that input source is also synchronous, other sources after it will not be subscribed to.
If the provided iterable of source
Publisher
s is empty, the resulting sequence completes immediately without emitting any items and without any calls to the combiner function.- Backpressure:
- The returned
Publisher
honors backpressure from downstream. The sourcePublisher
s are requested in a bounded manner, however, their backpressure is not enforced (the operator won't signalMissingBackpressureException
) and may lead toOutOfMemoryError
due to internal buffer bloat. - Scheduler:
combineLatest
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common base type of source valuesR
- the result type- Parameters:
sources
- the collection of sourcePublisher
scombiner
- the aggregation function used to combine the items emitted by the sourcePublisher
sbufferSize
- the internal buffer size and prefetch amount applied to every sourceFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
orcombiner
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: CombineLatest
-
combineLatestArrayDelayError
@SchedulerSupport("none") @CheckReturnValue @BackpressureSupport(FULL) @NonNull public static <@NonNull T,@NonNull R> @NonNull Flowable<R> combineLatestArrayDelayError(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T>[] sources, @NonNull @NonNull Function<? super java.lang.Object[],? extends @NonNull R> combiner)
Combines a collection of sourcePublisher
s by emitting an item that aggregates the latest values of each of the sourcePublisher
s each time an item is received from any of the sourcePublisher
s, 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 anObject[]
instead. Unfortunately, aFunction<Integer[], R>
passed to the method would trigger aClassCastException
.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 until that point). If that input source is also synchronous, other sources after it will not be subscribed to.
If the provided array of source
Publisher
s is empty, the resulting sequence completes immediately without emitting any items and without any calls to the combiner function.- Backpressure:
- The returned
Publisher
honors backpressure from downstream. The sourcePublisher
s are requested in a bounded manner, however, their backpressure is not enforced (the operator won't signalMissingBackpressureException
) and may lead toOutOfMemoryError
due to internal buffer bloat. - Scheduler:
combineLatestArrayDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common base type of source valuesR
- the result type- Parameters:
sources
- the collection of sourcePublisher
scombiner
- the aggregation function used to combine the items emitted by the sourcePublisher
s- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
orcombiner
isnull
- See Also:
- ReactiveX operators documentation: CombineLatest
-
combineLatestArrayDelayError
@SchedulerSupport("none") @CheckReturnValue @NonNull @BackpressureSupport(FULL) public static <@NonNull T,@NonNull R> @NonNull Flowable<R> combineLatestArrayDelayError(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T>[] sources, @NonNull @NonNull Function<? super java.lang.Object[],? extends @NonNull R> combiner, int bufferSize)
Combines a collection of sourcePublisher
s by emitting an item that aggregates the latest values of each of the sourcePublisher
s each time an item is received from any of the sourcePublisher
s, where this aggregation is defined by a specified function and delays any error from the sources until all sourcePublisher
s 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 anObject[]
instead. Unfortunately, aFunction<Integer[], R>
passed to the method would trigger aClassCastException
.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 until that point). If that input source is also synchronous, other sources after it will not be subscribed to.
If the provided array of source
Publisher
s is empty, the resulting sequence completes immediately without emitting any items and without any calls to the combiner function.- Backpressure:
- The returned
Publisher
honors backpressure from downstream. The sourcePublisher
s are requested in a bounded manner, however, their backpressure is not enforced (the operator won't signalMissingBackpressureException
) and may lead toOutOfMemoryError
due to internal buffer bloat. - Scheduler:
combineLatestArrayDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common base type of source valuesR
- the result type- Parameters:
sources
- the collection of sourcePublisher
scombiner
- the aggregation function used to combine the items emitted by the sourcePublisher
sbufferSize
- the internal buffer size and prefetch amount applied to every sourceFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
orcombiner
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: CombineLatest
-
combineLatestDelayError
@SchedulerSupport("none") @CheckReturnValue @BackpressureSupport(FULL) @NonNull public static <@NonNull T,@NonNull R> @NonNull Flowable<R> combineLatestDelayError(@NonNull @NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, @NonNull @NonNull Function<? super java.lang.Object[],? extends @NonNull R> combiner)
Combines a collection of sourcePublisher
s by emitting an item that aggregates the latest values of each of the sourcePublisher
s each time an item is received from any of the sourcePublisher
s, where this aggregation is defined by a specified function and delays any error from the sources until all sourcePublisher
s 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 anObject[]
instead. Unfortunately, aFunction<Integer[], R>
passed to the method would trigger aClassCastException
.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 until that point). If that input source is also synchronous, other sources after it will not be subscribed to.
If the provided iterable of source
Publisher
s is empty, the resulting sequence completes immediately without emitting any items and without any calls to the combiner function.- Backpressure:
- The returned
Publisher
honors backpressure from downstream. The sourcePublisher
s are requested in a bounded manner, however, their backpressure is not enforced (the operator won't signalMissingBackpressureException
) and may lead toOutOfMemoryError
due to internal buffer bloat. - Scheduler:
combineLatestDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common base type of source valuesR
- the result type- Parameters:
sources
- the collection of sourcePublisher
scombiner
- the aggregation function used to combine the items emitted by the sourcePublisher
s- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
orcombiner
isnull
- See Also:
- ReactiveX operators documentation: CombineLatest
-
combineLatestDelayError
@SchedulerSupport("none") @CheckReturnValue @BackpressureSupport(FULL) @NonNull public static <@NonNull T,@NonNull R> @NonNull Flowable<R> combineLatestDelayError(@NonNull @NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, @NonNull @NonNull Function<? super java.lang.Object[],? extends @NonNull R> combiner, int bufferSize)
Combines a collection of sourcePublisher
s by emitting an item that aggregates the latest values of each of the sourcePublisher
s each time an item is received from any of the sourcePublisher
s, where this aggregation is defined by a specified function and delays any error from the sources until all sourcePublisher
s 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 anObject[]
instead. Unfortunately, aFunction<Integer[], R>
passed to the method would trigger aClassCastException
.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 until that point). If that input source is also synchronous, other sources after it will not be subscribed to.
If the provided iterable of source
Publisher
s is empty, the resulting sequence completes immediately without emitting any items and without any calls to the combiner function.- Backpressure:
- The returned
Publisher
honors backpressure from downstream. The sourcePublisher
s are requested in a bounded manner, however, their backpressure is not enforced (the operator won't signalMissingBackpressureException
) and may lead toOutOfMemoryError
due to internal buffer bloat. - Scheduler:
combineLatestDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common base type of source valuesR
- the result type- Parameters:
sources
- the collection of sourcePublisher
scombiner
- the aggregation function used to combine the items emitted by the sourcePublisher
sbufferSize
- the internal buffer size and prefetch amount applied to every sourceFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
orcombiner
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: CombineLatest
-
combineLatest
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public static <@NonNull T1,@NonNull T2,@NonNull R> @NonNull Flowable<R> combineLatest(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull @NonNull BiFunction<? super @NonNull T1,? super @NonNull T2,? extends @NonNull R> combiner)
Combines two sourcePublisher
s by emitting an item that aggregates the latest values of each of the sourcePublisher
s each time an item is received from either of the sourcePublisher
s, 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 until that point). If that input source is also synchronous, other sources after it will not be subscribed to.
- Backpressure:
- The returned
Publisher
honors backpressure from downstream. The sourcePublisher
s are requested in a bounded manner, however, their backpressure is not enforced (the operator won't signalMissingBackpressureException
) and may lead toOutOfMemoryError
due to internal buffer bloat. - Scheduler:
combineLatest
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the element type of the first sourceT2
- the element type of the second sourceR
- the combined output type- Parameters:
source1
- the first sourcePublisher
source2
- the second sourcePublisher
combiner
- the aggregation function used to combine the items emitted by the sourcePublisher
s- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
orcombiner
isnull
- See Also:
- ReactiveX operators documentation: CombineLatest
-
combineLatest
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull R> @NonNull Flowable<R> combineLatest(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T3> source3, @NonNull @NonNull Function3<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? extends @NonNull R> combiner)
Combines three sourcePublisher
s by emitting an item that aggregates the latest values of each of the sourcePublisher
s each time an item is received from any of the sourcePublisher
s, 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 until that point). If that input source is also synchronous, other sources after it will not be subscribed to.
- Backpressure:
- The returned
Publisher
honors backpressure from downstream. The sourcePublisher
s are requested in a bounded manner, however, their backpressure is not enforced (the operator won't signalMissingBackpressureException
) and may lead toOutOfMemoryError
due to internal buffer bloat. - Scheduler:
combineLatest
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the element type of the first sourceT2
- the element type of the second sourceT3
- the element type of the third sourceR
- the combined output type- Parameters:
source1
- the first sourcePublisher
source2
- the second sourcePublisher
source3
- the third sourcePublisher
combiner
- the aggregation function used to combine the items emitted by the sourcePublisher
s- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
orcombiner
isnull
- See Also:
- ReactiveX operators documentation: CombineLatest
-
combineLatest
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull R> @NonNull Flowable<R> combineLatest(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T3> source3, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T4> source4, @NonNull @NonNull Function4<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? extends @NonNull R> combiner)
Combines four sourcePublisher
s by emitting an item that aggregates the latest values of each of the sourcePublisher
s each time an item is received from any of the sourcePublisher
s, 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 until that point). If that input source is also synchronous, other sources after it will not be subscribed to.
- Backpressure:
- The returned
Publisher
honors backpressure from downstream. The sourcePublisher
s are requested in a bounded manner, however, their backpressure is not enforced (the operator won't signalMissingBackpressureException
) and may lead toOutOfMemoryError
due to internal buffer bloat. - Scheduler:
combineLatest
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the element type of the first sourceT2
- the element type of the second sourceT3
- the element type of the third sourceT4
- the element type of the fourth sourceR
- the combined output type- Parameters:
source1
- the first sourcePublisher
source2
- the second sourcePublisher
source3
- the third sourcePublisher
source4
- the fourth sourcePublisher
combiner
- the aggregation function used to combine the items emitted by the sourcePublisher
s- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
,source4
orcombiner
isnull
- See Also:
- ReactiveX operators documentation: CombineLatest
-
combineLatest
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull R> @NonNull Flowable<R> combineLatest(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T3> source3, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T4> source4, @NonNull @NonNull org.reactivestreams.Publisher<? 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> combiner)
Combines five sourcePublisher
s by emitting an item that aggregates the latest values of each of the sourcePublisher
s each time an item is received from any of the sourcePublisher
s, 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 until that point). If that input source is also synchronous, other sources after it will not be subscribed to.
- Backpressure:
- The returned
Publisher
honors backpressure from downstream. The sourcePublisher
s are requested in a bounded manner, however, their backpressure is not enforced (the operator won't signalMissingBackpressureException
) and may lead toOutOfMemoryError
due to internal buffer bloat. - Scheduler:
combineLatest
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the element type of the first sourceT2
- the element type of the second sourceT3
- the element type of the third sourceT4
- the element type of the fourth sourceT5
- the element type of the fifth sourceR
- the combined output type- Parameters:
source1
- the first sourcePublisher
source2
- the second sourcePublisher
source3
- the third sourcePublisher
source4
- the fourth sourcePublisher
source5
- the fifth sourcePublisher
combiner
- the aggregation function used to combine the items emitted by the sourcePublisher
s- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
,source4
,source5
orcombiner
isnull
- See Also:
- ReactiveX operators documentation: CombineLatest
-
combineLatest
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull R> @NonNull Flowable<R> combineLatest(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T3> source3, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T4> source4, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T5> source5, @NonNull @NonNull org.reactivestreams.Publisher<? 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> combiner)
Combines six sourcePublisher
s by emitting an item that aggregates the latest values of each of the sourcePublisher
s each time an item is received from any of the sourcePublisher
s, 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 until that point). If that input source is also synchronous, other sources after it will not be subscribed to.
- Backpressure:
- The returned
Publisher
honors backpressure from downstream. The sourcePublisher
s are requested in a bounded manner, however, their backpressure is not enforced (the operator won't signalMissingBackpressureException
) and may lead toOutOfMemoryError
due to internal buffer bloat. - Scheduler:
combineLatest
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the element type of the first sourceT2
- the element type of the second sourceT3
- the element type of the third sourceT4
- the element type of the fourth sourceT5
- the element type of the fifth sourceT6
- the element type of the sixth sourceR
- the combined output type- Parameters:
source1
- the first sourcePublisher
source2
- the second sourcePublisher
source3
- the third sourcePublisher
source4
- the fourth sourcePublisher
source5
- the fifth sourcePublisher
source6
- the sixth sourcePublisher
combiner
- the aggregation function used to combine the items emitted by the sourcePublisher
s- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
,source4
,source5
,source6
orcombiner
isnull
- See Also:
- ReactiveX operators documentation: CombineLatest
-
combineLatest
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull T7,@NonNull R> @NonNull Flowable<R> combineLatest(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T3> source3, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T4> source4, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T5> source5, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T6> source6, @NonNull @NonNull org.reactivestreams.Publisher<? 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> combiner)
Combines seven sourcePublisher
s by emitting an item that aggregates the latest values of each of the sourcePublisher
s each time an item is received from any of the sourcePublisher
s, 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 until that point). If that input source is also synchronous, other sources after it will not be subscribed to.
- Backpressure:
- The returned
Publisher
honors backpressure from downstream. The sourcePublisher
s are requested in a bounded manner, however, their backpressure is not enforced (the operator won't signalMissingBackpressureException
) and may lead toOutOfMemoryError
due to internal buffer bloat. - Scheduler:
combineLatest
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the element type of the first sourceT2
- the element type of the second sourceT3
- the element type of the third sourceT4
- the element type of the fourth sourceT5
- the element type of the fifth sourceT6
- the element type of the sixth sourceT7
- the element type of the seventh sourceR
- the combined output type- Parameters:
source1
- the first sourcePublisher
source2
- the second sourcePublisher
source3
- the third sourcePublisher
source4
- the fourth sourcePublisher
source5
- the fifth sourcePublisher
source6
- the sixth sourcePublisher
source7
- the seventh sourcePublisher
combiner
- the aggregation function used to combine the items emitted by the sourcePublisher
s- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
,source4
,source5
,source6
,source7
orcombiner
isnull
- See Also:
- ReactiveX operators documentation: CombineLatest
-
combineLatest
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull T7,@NonNull T8,@NonNull R> @NonNull Flowable<R> combineLatest(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T3> source3, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T4> source4, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T5> source5, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T6> source6, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T7> source7, @NonNull @NonNull org.reactivestreams.Publisher<? 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> combiner)
Combines eight sourcePublisher
s by emitting an item that aggregates the latest values of each of the sourcePublisher
s each time an item is received from any of the sourcePublisher
s, 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 until that point). If that input source is also synchronous, other sources after it will not be subscribed to.
- Backpressure:
- The returned
Publisher
honors backpressure from downstream. The sourcePublisher
s are requested in a bounded manner, however, their backpressure is not enforced (the operator won't signalMissingBackpressureException
) and may lead toOutOfMemoryError
due to internal buffer bloat. - Scheduler:
combineLatest
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the element type of the first sourceT2
- the element type of the second sourceT3
- the element type of the third sourceT4
- the element type of the fourth sourceT5
- the element type of the fifth sourceT6
- the element type of the sixth sourceT7
- the element type of the seventh sourceT8
- the element type of the eighth sourceR
- the combined output type- Parameters:
source1
- the first sourcePublisher
source2
- the second sourcePublisher
source3
- the third sourcePublisher
source4
- the fourth sourcePublisher
source5
- the fifth sourcePublisher
source6
- the sixth sourcePublisher
source7
- the seventh sourcePublisher
source8
- the eighth sourcePublisher
combiner
- the aggregation function used to combine the items emitted by the sourcePublisher
s- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
,source4
,source5
,source6
,source7
,source8
orcombiner
isnull
- See Also:
- ReactiveX operators documentation: CombineLatest
-
combineLatest
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull T7,@NonNull T8,@NonNull T9,@NonNull R> @NonNull Flowable<R> combineLatest(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T3> source3, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T4> source4, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T5> source5, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T6> source6, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T7> source7, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T8> source8, @NonNull @NonNull org.reactivestreams.Publisher<? 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> combiner)
Combines nine sourcePublisher
s by emitting an item that aggregates the latest values of each of the sourcePublisher
s each time an item is received from any of the sourcePublisher
s, 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 until that point). If that input source is also synchronous, other sources after it will not be subscribed to.
- Backpressure:
- The returned
Publisher
honors backpressure from downstream. The sourcePublisher
s are requested in a bounded manner, however, their backpressure is not enforced (the operator won't signalMissingBackpressureException
) and may lead toOutOfMemoryError
due to internal buffer bloat. - Scheduler:
combineLatest
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the element type of the first sourceT2
- the element type of the second sourceT3
- the element type of the third sourceT4
- the element type of the fourth sourceT5
- the element type of the fifth sourceT6
- the element type of the sixth sourceT7
- the element type of the seventh sourceT8
- the element type of the eighth sourceT9
- the element type of the ninth sourceR
- the combined output type- Parameters:
source1
- the first sourcePublisher
source2
- the second sourcePublisher
source3
- the third sourcePublisher
source4
- the fourth sourcePublisher
source5
- the fifth sourcePublisher
source6
- the sixth sourcePublisher
source7
- the seventh sourcePublisher
source8
- the eighth sourcePublisher
source9
- the ninth sourcePublisher
combiner
- the aggregation function used to combine the items emitted by the sourcePublisher
s- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
,source4
,source5
,source6
,source7
,source8
,source9
orcombiner
isnull
- See Also:
- ReactiveX operators documentation: CombineLatest
-
concat
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> concat(@NonNull @NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources)
Concatenates elements of eachPublisher
provided via anIterable
sequence into a single sequence of elements without interleaving them.- Backpressure:
- The operator honors backpressure from downstream. The
Publisher
sources are expected to honor backpressure as well. If any of the sourcePublisher
s violate this, it may throw anIllegalStateException
when thatPublisher
completes. - Scheduler:
concat
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common value type of the sources- Parameters:
sources
- theIterable
sequence ofPublisher
s- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
-
concat
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> concat(@NonNull @NonNull org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources)
Returns aFlowable
that emits the items emitted by each of thePublisher
s emitted by the sourcePublisher
, one after the other, without interleaving them.- Backpressure:
- The operator honors backpressure from downstream. Both the outer and inner
Publisher
sources are expected to honor backpressure as well. If the outer violates this, aMissingBackpressureException
is signaled. If any of the innerPublisher
s violates this, it may throw anIllegalStateException
when an innerPublisher
completes. - Scheduler:
concat
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- aPublisher
that emitsPublisher
s- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
- See Also:
- ReactiveX operators documentation: Concat
-
concat
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> concat(@NonNull @NonNull org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, int prefetch)
Returns aFlowable
that emits the items emitted by each of thePublisher
s emitted by the sourcePublisher
, one after the other, without interleaving them.- Backpressure:
- The operator honors backpressure from downstream. Both the outer and inner
Publisher
sources are expected to honor backpressure as well. If the outer violates this, aMissingBackpressureException
is signaled. If any of the innerPublisher
s violates this, it may throw anIllegalStateException
when an innerPublisher
completes. - Scheduler:
concat
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- aPublisher
that emitsPublisher
sprefetch
- the number ofPublisher
s to prefetch from the sources sequence.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifprefetch
is non-positive- See Also:
- ReactiveX operators documentation: Concat
-
concat
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> concat(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source1, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source2)
Returns aFlowable
that emits the items emitted by twoPublisher
s, one after the other, without interleaving them.- Backpressure:
- The operator honors backpressure from downstream. The
Publisher
sources are expected to honor backpressure as well. If any of the sourcePublisher
s violate this, it may throw anIllegalStateException
when that sourcePublisher
completes. - Scheduler:
concat
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
source1
- aPublisher
to be concatenatedsource2
- aPublisher
to be concatenated- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsource1
orsource2
isnull
- See Also:
- ReactiveX operators documentation: Concat
-
concat
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> concat(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source1, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source2, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source3)
Returns aFlowable
that emits the items emitted by threePublisher
s, one after the other, without interleaving them.- Backpressure:
- The operator honors backpressure from downstream. The
Publisher
sources are expected to honor backpressure as well. If any of the sourcePublisher
s violate this, it may throw anIllegalStateException
when that sourcePublisher
completes. - Scheduler:
concat
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
source1
- aPublisher
to be concatenatedsource2
- aPublisher
to be concatenatedsource3
- aPublisher
to be concatenated- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
orsource3
isnull
- See Also:
- ReactiveX operators documentation: Concat
-
concat
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> concat(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source1, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source2, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source3, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source4)
Returns aFlowable
that emits the items emitted by fourPublisher
s, one after the other, without interleaving them.- Backpressure:
- The operator honors backpressure from downstream. The
Publisher
sources are expected to honor backpressure as well. If any of the sourcePublisher
s violate this, it may throw anIllegalStateException
when that sourcePublisher
completes. - Scheduler:
concat
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
source1
- aPublisher
to be concatenatedsource2
- aPublisher
to be concatenatedsource3
- aPublisher
to be concatenatedsource4
- aPublisher
to be concatenated- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
orsource4
isnull
- See Also:
- ReactiveX operators documentation: Concat
-
concatArray
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @SafeVarargs @NonNull public static <@NonNull T> @NonNull Flowable<T> concatArray(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T>... sources)
Concatenates a variable number ofPublisher
sources.Note: named this way because of overload conflict with
concat(Publisher<Publisher<T>>
).- Backpressure:
- The operator honors backpressure from downstream. The
Publisher
sources are expected to honor backpressure as well. If any of the sourcePublisher
s violate this, it may throw anIllegalStateException
when that sourcePublisher
completes. - Scheduler:
concatArray
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common base value type- Parameters:
sources
- the array of sourcePublisher
s- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
-
concatArrayDelayError
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @SafeVarargs @NonNull public static <@NonNull T> @NonNull Flowable<T> concatArrayDelayError(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T>... sources)
Concatenates a variable number ofPublisher
sources and delays errors from any of them till all terminate.- Backpressure:
- The operator honors backpressure from downstream. The
Publisher
sources are expected to honor backpressure as well. If any of the sourcePublisher
s violate this, it may throw anIllegalStateException
when that sourcePublisher
completes. - Scheduler:
concatArrayDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common base value type- Parameters:
sources
- the array of sourcePublisher
s- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
-
concatArrayEager
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @SafeVarargs @NonNull public static <@NonNull T> @NonNull Flowable<T> concatArrayEager(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T>... sources)
Concatenates an array ofPublisher
s eagerly into a single stream of values.Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the source
Publisher
s. The operator buffers the values emitted by thesePublisher
s and then drains them in order, each one after the previous one completes.- Backpressure:
- The operator honors backpressure from downstream. The
Publisher
sources are expected to honor backpressure as well. If any of the sourcePublisher
s violate this, the operator will signal aMissingBackpressureException
. - Scheduler:
- This method does not operate by default on a particular
Scheduler
.
- Type Parameters:
T
- the value type- Parameters:
sources
- an array ofPublisher
s that need to be eagerly concatenated- Returns:
- the new
Flowable
instance with the specified concatenation behavior - Throws:
java.lang.NullPointerException
- ifsources
isnull
- Since:
- 2.0
-
concatArrayEager
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") @SafeVarargs public static <@NonNull T> @NonNull Flowable<T> concatArrayEager(int maxConcurrency, int prefetch, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T>... sources)
Concatenates an array ofPublisher
s eagerly into a single stream of values.Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the source
Publisher
s. The operator buffers the values emitted by thesePublisher
s and then drains them in order, each one after the previous one completes.- Backpressure:
- The operator honors backpressure from downstream. The
Publisher
sources are expected to honor backpressure as well. If any of the sourcePublisher
s violate this, the operator will signal aMissingBackpressureException
. - Scheduler:
- This method does not operate by default on a particular
Scheduler
.
- Type Parameters:
T
- the value type- Parameters:
sources
- an array ofPublisher
s that need to be eagerly concatenatedmaxConcurrency
- the maximum number of concurrent subscriptions at a time,Integer.MAX_VALUE
is interpreted as an indication to subscribe to all sources at onceprefetch
- the number of elements to prefetch from eachPublisher
source- Returns:
- the new
Flowable
instance with the specified concatenation behavior - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
orprefetch
is non-positive- Since:
- 2.0
-
concatArrayEagerDelayError
@CheckReturnValue @SchedulerSupport("none") @BackpressureSupport(FULL) @SafeVarargs @NonNull public static <@NonNull T> @NonNull Flowable<T> concatArrayEagerDelayError(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T>... sources)
Concatenates an array ofPublisher
s 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 source
Publisher
s. The operator buffers the values emitted by thesePublisher
s and then drains them in order, each one after the previous one completes.- Backpressure:
- The operator honors backpressure from downstream. The
Publisher
sources are expected to honor backpressure as well. If any of the sourcePublisher
s violate this, the operator will signal aMissingBackpressureException
. - Scheduler:
- This method does not operate by default on a particular
Scheduler
.
- Type Parameters:
T
- the value type- Parameters:
sources
- an array ofPublisher
s that need to be eagerly concatenated- Returns:
- the new
Flowable
instance with the specified concatenation behavior - Throws:
java.lang.NullPointerException
- ifsources
isnull
- Since:
- 2.2.1 - experimental
-
concatArrayEagerDelayError
@CheckReturnValue @SchedulerSupport("none") @BackpressureSupport(FULL) @SafeVarargs @NonNull public static <@NonNull T> @NonNull Flowable<T> concatArrayEagerDelayError(int maxConcurrency, int prefetch, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T>... sources)
Concatenates an array ofPublisher
s 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 source
Publisher
s. The operator buffers the values emitted by thesePublisher
s and then drains them in order, each one after the previous one completes.- Backpressure:
- The operator honors backpressure from downstream. The
Publisher
sources are expected to honor backpressure as well. If any of the sourcePublisher
s violate this, the operator will signal aMissingBackpressureException
. - Scheduler:
- This method does not operate by default on a particular
Scheduler
.
- Type Parameters:
T
- the value type- Parameters:
sources
- an array ofPublisher
s that need to be eagerly concatenatedmaxConcurrency
- the maximum number of concurrent subscriptions at a time,Integer.MAX_VALUE
is interpreted as indication to subscribe to all sources at onceprefetch
- the number of elements to prefetch from eachPublisher
source- Returns:
- the new
Flowable
instance with the specified concatenation behavior - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
orprefetch
is non-positive- Since:
- 2.2.1 - experimental
-
concatDelayError
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> concatDelayError(@NonNull @NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources)
Concatenates theIterable
sequence ofPublisher
s into a single sequence by subscribing to eachPublisher
, one after the other, one at a time and delays any errors till the all innerPublisher
s terminate.- Backpressure:
- The operator honors backpressure from downstream. Both the outer and inner
Publisher
sources are expected to honor backpressure as well. If the outer violates this, aMissingBackpressureException
is signaled. If any of the innerPublisher
s violates this, it may throw anIllegalStateException
when an innerPublisher
completes. - Scheduler:
concatDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- theIterable
sequence ofPublisher
s- Returns:
- the new
Flowable
with the concatenating behavior - Throws:
java.lang.NullPointerException
- ifsources
isnull
-
concatDelayError
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> concatDelayError(@NonNull @NonNull org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources)
Concatenates thePublisher
sequence ofPublisher
s into a single sequence by subscribing to each innerPublisher
, one after the other, one at a time and delays any errors till the all inner and the outerPublisher
s terminate.- Backpressure:
concatDelayError
fully supports backpressure.- Scheduler:
concatDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- thePublisher
sequence ofPublisher
s- Returns:
- the new
Flowable
with the concatenating behavior - Throws:
java.lang.NullPointerException
- ifsources
isnull
-
concatDelayError
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> concatDelayError(@NonNull @NonNull org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, int prefetch, boolean tillTheEnd)
Concatenates thePublisher
sequence ofPublisher
s into a single sequence by subscribing to each innerPublisher
, one after the other, one at a time and delays any errors till the all inner and the outerPublisher
s terminate.- Backpressure:
concatDelayError
fully supports backpressure.- Scheduler:
concatDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- thePublisher
sequence ofPublisher
sprefetch
- the number of elements to prefetch from the outerPublisher
tillTheEnd
- iftrue
, exceptions from the outer and all innerPublisher
s are delayed to the end iffalse
, exception from the outerPublisher
is delayed till the current innerPublisher
terminates- Returns:
- the new
Flowable
with the concatenating behavior - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifprefetch
isnull
-
concatEager
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> concatEager(@NonNull @NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources)
Concatenates a sequence ofPublisher
s eagerly into a single stream of values.Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the source
Publisher
s. The operator buffers the values emitted by thesePublisher
s and then drains them in order, each one after the previous one completes.- Backpressure:
- Backpressure is honored towards the downstream and the inner
Publisher
s are expected to support backpressure. Violating this assumption, the operator will signalMissingBackpressureException
. - Scheduler:
- This method does not operate by default on a particular
Scheduler
.
- Type Parameters:
T
- the value type- Parameters:
sources
- a sequence ofPublisher
s that need to be eagerly concatenated- Returns:
- the new
Flowable
instance with the specified concatenation behavior - Throws:
java.lang.NullPointerException
- ifsources
isnull
- Since:
- 2.0
-
concatEager
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> concatEager(@NonNull @NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, int maxConcurrency, int prefetch)
Concatenates a sequence ofPublisher
s 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 source
Publisher
s. The operator buffers the values emitted by thesePublisher
s and then drains them in order, each one after the previous one completes.- Backpressure:
- Backpressure is honored towards the downstream and both the outer and inner
Publisher
s are expected to support backpressure. Violating this assumption, the operator will signalMissingBackpressureException
. - Scheduler:
- This method does not operate by default on a particular
Scheduler
.
- Type Parameters:
T
- the value type- Parameters:
sources
- a sequence ofPublisher
s that need to be eagerly concatenatedmaxConcurrency
- the maximum number of concurrently running innerPublisher
s;Integer.MAX_VALUE
is interpreted as all innerPublisher
s can be active at the same timeprefetch
- the number of elements to prefetch from each innerPublisher
source- Returns:
- the new
Flowable
instance with the specified concatenation behavior - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
orprefetch
is non-positive- Since:
- 2.0
-
concatEager
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> concatEager(@NonNull @NonNull org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources)
Concatenates aPublisher
sequence ofPublisher
s eagerly into a single stream of values.Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the emitted source
Publisher
s as they are observed. The operator buffers the values emitted by thesePublisher
s and then drains them in order, each one after the previous one completes.- Backpressure:
- Backpressure is honored towards the downstream and both the outer and inner
Publisher
s are expected to support backpressure. Violating this assumption, the operator will signalMissingBackpressureException
. - Scheduler:
- This method does not operate by default on a particular
Scheduler
.
- Type Parameters:
T
- the value type- Parameters:
sources
- a sequence ofPublisher
s that need to be eagerly concatenated- Returns:
- the new
Flowable
instance with the specified concatenation behavior - Throws:
java.lang.NullPointerException
- ifsources
isnull
- Since:
- 2.0
-
concatEager
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> concatEager(@NonNull @NonNull org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, int maxConcurrency, int prefetch)
Concatenates aPublisher
sequence ofPublisher
s 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
Publisher
s as they are observed. The operator buffers the values emitted by thesePublisher
s and then drains them in order, each one after the previous one completes.- Backpressure:
- Backpressure is honored towards the downstream and both the outer and inner
Publisher
s are expected to support backpressure. Violating this assumption, the operator will signalMissingBackpressureException
. - Scheduler:
- This method does not operate by default on a particular
Scheduler
.
- Type Parameters:
T
- the value type- Parameters:
sources
- a sequence ofPublisher
s that need to be eagerly concatenatedmaxConcurrency
- the maximum number of concurrently running innerPublisher
s;Integer.MAX_VALUE
is interpreted as all innerPublisher
s can be active at the same timeprefetch
- the number of elements to prefetch from each innerPublisher
source- Returns:
- the new
Flowable
instance with the specified concatenation behavior - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
orprefetch
is non-positive- Since:
- 2.0
-
concatEagerDelayError
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> concatEagerDelayError(@NonNull @NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources)
Concatenates a sequence ofPublisher
s 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 source
Publisher
s. The operator buffers the values emitted by thesePublisher
s and then drains them in order, each one after the previous one completes.- Backpressure:
- Backpressure is honored towards the downstream and the inner
Publisher
s are expected to support backpressure. Violating this assumption, the operator will signalMissingBackpressureException
. - Scheduler:
- This method does not operate by default on a particular
Scheduler
.
- Type Parameters:
T
- the value type- Parameters:
sources
- a sequence ofPublisher
s that need to be eagerly concatenated- Returns:
- the new
Flowable
instance with the specified concatenation behavior - Throws:
java.lang.NullPointerException
- ifsources
isnull
- Since:
- 3.0.0
-
concatEagerDelayError
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> concatEagerDelayError(@NonNull @NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, int maxConcurrency, int prefetch)
Concatenates a sequence ofPublisher
s 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 source
Publisher
s. The operator buffers the values emitted by thesePublisher
s and then drains them in order, each one after the previous one completes.- Backpressure:
- Backpressure is honored towards the downstream and both the outer and inner
Publisher
s are expected to support backpressure. Violating this assumption, the operator will signalMissingBackpressureException
. - Scheduler:
- This method does not operate by default on a particular
Scheduler
.
- Type Parameters:
T
- the value type- Parameters:
sources
- a sequence ofPublisher
s that need to be eagerly concatenatedmaxConcurrency
- the maximum number of concurrently running innerPublisher
s;Integer.MAX_VALUE
is interpreted as all innerPublisher
s can be active at the same timeprefetch
- the number of elements to prefetch from each innerPublisher
source- Returns:
- the new
Flowable
instance with the specified concatenation behavior - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
orprefetch
is non-positive- Since:
- 3.0.0
-
concatEagerDelayError
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> concatEagerDelayError(@NonNull @NonNull org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources)
Concatenates aPublisher
sequence ofPublisher
s eagerly into a single stream of values, delaying errors until all the inner and the outer sequences terminate.Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the emitted source
Publisher
s as they are observed. The operator buffers the values emitted by thesePublisher
s and then drains them in order, each one after the previous one completes.- Backpressure:
- Backpressure is honored towards the downstream and both the outer and inner
Publisher
s are expected to support backpressure. Violating this assumption, the operator will signalMissingBackpressureException
. - Scheduler:
- This method does not operate by default on a particular
Scheduler
.
- Type Parameters:
T
- the value type- Parameters:
sources
- a sequence ofPublisher
s that need to be eagerly concatenated- Returns:
- the new
Flowable
instance with the specified concatenation behavior - Throws:
java.lang.NullPointerException
- ifsources
isnull
- Since:
- 3.0.0
-
concatEagerDelayError
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> concatEagerDelayError(@NonNull @NonNull org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, int maxConcurrency, int prefetch)
Concatenates aPublisher
sequence ofPublisher
s eagerly into a single stream of values, delaying errors until all the inner and outer 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 emitted source
Publisher
s as they are observed. The operator buffers the values emitted by thesePublisher
s and then drains them in order, each one after the previous one completes.- Backpressure:
- Backpressure is honored towards the downstream and both the outer and inner
Publisher
s are expected to support backpressure. Violating this assumption, the operator will signalMissingBackpressureException
. - Scheduler:
- This method does not operate by default on a particular
Scheduler
.
- Type Parameters:
T
- the value type- Parameters:
sources
- a sequence ofPublisher
s that need to be eagerly concatenatedmaxConcurrency
- the maximum number of concurrently running innerPublisher
s;Integer.MAX_VALUE
is interpreted as all innerPublisher
s can be active at the same timeprefetch
- the number of elements to prefetch from each innerPublisher
source- Returns:
- the new
Flowable
instance with the specified concatenation behavior - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
orprefetch
is non-positive- Since:
- 3.0.0
-
create
@CheckReturnValue @NonNull @BackpressureSupport(SPECIAL) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> create(@NonNull @NonNull FlowableOnSubscribe<@NonNull T> source, @NonNull @NonNull BackpressureStrategy mode)
Provides an API (via a coldFlowable
) that bridges the reactive world with the callback-style, generally non-backpressured world.Example:
Flowable.<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); }, BackpressureStrategy.BUFFER);
Whenever a
Subscriber
subscribes to the returnedFlowable
, the providedFlowableOnSubscribe
callback is invoked with a fresh instance of aFlowableEmitter
that will interact only with that specificSubscriber
. If thisSubscriber
cancels the flow (makingFlowableEmitter.isCancelled()
returntrue
), other observers subscribed to the same returnedFlowable
are not affected.You should call the
Emitter.onNext(Object)
,Emitter.onError(Throwable)
andEmitter.onComplete()
methods in a serialized fashion. The rest of its methods are thread-safe.- Backpressure:
- The backpressure behavior is determined by the
mode
parameter. - Scheduler:
create
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the element type- Parameters:
source
- the emitter that is called when aSubscriber
subscribes to the returnedFlowable
mode
- the backpressure mode to apply if the downstreamSubscriber
doesn't request (fast) enough- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsource
ormode
isnull
- See Also:
FlowableOnSubscribe
,BackpressureStrategy
,Cancellable
-
defer
@CheckReturnValue @NonNull @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> defer(@NonNull @NonNull Supplier<? extends @NonNull org.reactivestreams.Publisher<? extends @NonNull T>> supplier)
Returns aFlowable
that calls aPublisher
factory to create aPublisher
for each newSubscriber
that subscribes. That is, for each subscriber, the actualPublisher
that subscriber observes is determined by the factory function.The defer
Subscriber
allows you to defer or delay emitting items from aPublisher
until such time as aSubscriber
subscribes to thePublisher
. This allows aSubscriber
to easily obtain updates or a refreshed version of the sequence.- Backpressure:
- The operator itself doesn't interfere with backpressure which is determined by the
Publisher
returned by thesupplier
. - Scheduler:
defer
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of the items emitted by thePublisher
- Parameters:
supplier
- thePublisher
factory function to invoke for eachSubscriber
that subscribes to the resultingFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsupplier
isnull
- See Also:
- ReactiveX operators documentation: Defer
-
empty
@CheckReturnValue @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> empty()
Returns aFlowable
that emits no items to theSubscriber
and immediately invokes itsonComplete
method.- Backpressure:
- This source doesn't produce any elements and effectively ignores downstream backpressure.
- Scheduler:
empty
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of the items (ostensibly) emitted by thePublisher
- Returns:
- the shared
Flowable
instance - See Also:
- ReactiveX operators documentation: Empty
-
error
@CheckReturnValue @NonNull @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> error(@NonNull @NonNull Supplier<? extends @NonNull java.lang.Throwable> supplier)
Returns aFlowable
that invokes aSubscriber
'sonError
method when theSubscriber
subscribes to it.- Backpressure:
- This source doesn't produce any elements and effectively ignores downstream backpressure.
- Scheduler:
error
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of the items (ostensibly) emitted by the resultingFlowable
- Parameters:
supplier
- aSupplier
factory to return aThrowable
for each individualSubscriber
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsupplier
isnull
- See Also:
- ReactiveX operators documentation: Throw
-
error
@CheckReturnValue @NonNull @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> error(@NonNull @NonNull java.lang.Throwable throwable)
Returns aFlowable
that invokes aSubscriber
'sonError
method when theSubscriber
subscribes to it.- Backpressure:
- This source doesn't produce any elements and effectively ignores downstream backpressure.
- Scheduler:
error
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of the items (ostensibly) emitted by the resultingFlowable
- Parameters:
throwable
- the particularThrowable
to pass toonError
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifthrowable
isnull
- See Also:
- ReactiveX operators documentation: Throw
-
fromAction
@CheckReturnValue @NonNull @SchedulerSupport("none") @BackpressureSupport(PASS_THROUGH) public static <@NonNull T> @NonNull Flowable<T> fromAction(@NonNull @NonNull Action action)
Returns aFlowable
instance that runs the givenAction
for eachSubscriber
and emits either its exception or simply completes.- Backpressure:
- This source doesn't produce any elements and effectively ignores downstream backpressure.
- Scheduler:
fromAction
does not operate by default on a particularScheduler
.- Error handling:
- If the
Action
throws an exception, the respectiveThrowable
is delivered to the downstream viaSubscriber.onError(Throwable)
, except when the downstream has canceled the resultingFlowable
source. In this latter case, theThrowable
is delivered to the global error handler viaRxJavaPlugins.onError(Throwable)
as anUndeliverableException
.
- Type Parameters:
T
- the target type- Parameters:
action
- theAction
to run for eachSubscriber
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifaction
isnull
- Since:
- 3.0.0
-
fromArray
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") @SafeVarargs public static <@NonNull T> @NonNull Flowable<T> fromArray(@NonNull @NonNull T... items)
Converts an array into aPublisher
that emits the items in the array.- Backpressure:
- The operator honors backpressure from downstream and iterates the given
array
on demand (i.e., when requested). - Scheduler:
fromArray
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of items in the array and the type of items to be emitted by the resultingFlowable
- Parameters:
items
- the array of elements- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifitems
isnull
- See Also:
- ReactiveX operators documentation: From
-
fromCallable
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> fromCallable(@NonNull @NonNull java.util.concurrent.Callable<? extends @NonNull T> callable)
Returns aFlowable
that, when aSubscriber
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 a
Subscriber
subscribes to thePublisher
. That is to say, it makes the function "lazy."- Backpressure:
- The operator honors backpressure from downstream.
- Scheduler:
fromCallable
does not operate by default on a particularScheduler
.- Error handling:
- If the
Callable
throws an exception, the respectiveThrowable
is delivered to the downstream viaSubscriber.onError(Throwable)
, except when the downstream has canceled thisFlowable
source. In this latter case, theThrowable
is delivered to the global error handler viaRxJavaPlugins.onError(Throwable)
as anUndeliverableException
.
- Type Parameters:
T
- the type of the item emitted by thePublisher
- Parameters:
callable
- a function, the execution of which should be deferred;fromCallable
will invoke this function only when aSubscriber
subscribes to thePublisher
thatfromCallable
returns- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifcallable
isnull
- Since:
- 2.0
- See Also:
defer(Supplier)
,fromSupplier(Supplier)
-
fromCompletable
@CheckReturnValue @NonNull @SchedulerSupport("none") @BackpressureSupport(PASS_THROUGH) public static <@NonNull T> @NonNull Flowable<T> fromCompletable(@NonNull @NonNull CompletableSource completableSource)
Wraps aCompletableSource
into aFlowable
.- Backpressure:
- This source doesn't produce any elements and effectively ignores downstream backpressure.
- Scheduler:
fromCompletable
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the target type- Parameters:
completableSource
- theCompletableSource
to convert from- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifcompletableSource
isnull
-
fromFuture
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> fromFuture(@NonNull @NonNull java.util.concurrent.Future<? extends @NonNull T> future)
Converts aFuture
into aPublisher
.The operator calls
Future.get()
, which is a blocking method, on the subscription thread. It is recommended applyingsubscribeOn(Scheduler)
to move this blocking wait to a background thread, and if theScheduler
supports it, interrupt the wait when the flow is disposed.Also note that this operator will consume a
CompletionStage
-basedFuture
subclass (such asCompletableFuture
) in a blocking manner as well. Use thefromCompletionStage(CompletionStage)
operator to convert and consume such sources in a non-blocking fashion instead.Unlike 1.x, canceling the
Flowable
won't cancel the future. If necessary, one can use composition to achieve the cancellation effect:futurePublisher.doOnCancel(() -> future.cancel(true));
.- Backpressure:
- The operator honors backpressure from downstream.
- Scheduler:
fromFuture
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of object that theFuture
returns, and also the type of item to be emitted by the resultingFlowable
- Parameters:
future
- the sourceFuture
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- iffuture
isnull
- See Also:
- ReactiveX operators documentation: From,
fromCompletionStage(CompletionStage)
-
fromFuture
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> fromFuture(@NonNull @NonNull java.util.concurrent.Future<? extends @NonNull T> future, long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Converts aFuture
into aPublisher
, with a timeout on theFuture
.The operator calls
Future.get(long, TimeUnit)
, which is a blocking method, on the subscription thread. It is recommended applyingsubscribeOn(Scheduler)
to move this blocking wait to a background thread, and if theScheduler
supports it, interrupt the wait when the flow is disposed.Unlike 1.x, canceling the
Flowable
won't cancel the future. If necessary, one can use composition to achieve the cancellation effect:futurePublisher.doOnCancel(() -> future.cancel(true));
.Also note that this operator will consume a
CompletionStage
-basedFuture
subclass (such asCompletableFuture
) in a blocking manner as well. Use thefromCompletionStage(CompletionStage)
operator to convert and consume such sources in a non-blocking fashion instead.- Backpressure:
- The operator honors backpressure from downstream.
- Scheduler:
fromFuture
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of object that theFuture
returns, and also the type of item to be emitted by the resultingFlowable
- Parameters:
future
- the sourceFuture
timeout
- the maximum time to wait before callingget
unit
- theTimeUnit
of thetimeout
argument- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- iffuture
orunit
isnull
- See Also:
- ReactiveX operators documentation: From,
fromCompletionStage(CompletionStage)
-
fromIterable
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> fromIterable(@NonNull @NonNull java.lang.Iterable<? extends @NonNull T> source)
Converts anIterable
sequence into aPublisher
that emits the items in the sequence.- Backpressure:
- The operator honors backpressure from downstream and iterates the given
iterable
on demand (i.e., when requested). - Scheduler:
fromIterable
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of items in theIterable
sequence and the type of items to be emitted by the resultingFlowable
- Parameters:
source
- the sourceIterable
sequence- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsource
isnull
- See Also:
- ReactiveX operators documentation: From,
fromStream(Stream)
-
fromMaybe
@CheckReturnValue @NonNull @SchedulerSupport("none") @BackpressureSupport(FULL) public static <@NonNull T> @NonNull Flowable<T> fromMaybe(@NonNull @NonNull MaybeSource<@NonNull T> maybe)
Returns aFlowable
instance that when subscribed to, subscribes to theMaybeSource
instance and emitsonSuccess
as a single item or forwards anyonComplete
oronError
signal.- Backpressure:
- The operator honors backpressure from downstream.
- Scheduler:
fromMaybe
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the value type of theMaybeSource
element- Parameters:
maybe
- theMaybeSource
instance to subscribe to, notnull
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmaybe
isnull
- Since:
- 3.0.0
-
fromObservable
@BackpressureSupport(SPECIAL) @CheckReturnValue @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> fromObservable(@NonNull @NonNull ObservableSource<@NonNull T> source, @NonNull @NonNull BackpressureStrategy strategy)
Converts the givenObservableSource
into aFlowable
by applying the specified backpressure strategy.Marble diagrams for the various backpressure strategies are as follows:
BackpressureStrategy.BUFFER
BackpressureStrategy.DROP
BackpressureStrategy.LATEST
BackpressureStrategy.ERROR
BackpressureStrategy.MISSING
- Backpressure:
- The operator applies the chosen backpressure strategy of
BackpressureStrategy
enum. - Scheduler:
fromObservable
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the element type of the source and resulting sequence- Parameters:
source
- theObservableSource
to convertstrategy
- the backpressure strategy to apply- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsource
orstrategy
isnull
-
fromPublisher
@CheckReturnValue @NonNull @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> fromPublisher(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> publisher)
Converts an arbitrary Reactive StreamsPublisher
into aFlowable
if not already aFlowable
.The
Publisher
must follow the Reactive-Streams specification. Violating the specification may result in undefined behavior.If possible, use
create(FlowableOnSubscribe, BackpressureStrategy)
to create a source-likeFlowable
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 operator is a pass-through for backpressure and its behavior is determined by the backpressure behavior of the wrapped publisher.
- Scheduler:
fromPublisher
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the value type of the flow- Parameters:
publisher
- thePublisher
to convert- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifpublisher
isnull
- See Also:
create(FlowableOnSubscribe, BackpressureStrategy)
-
fromRunnable
@CheckReturnValue @NonNull @SchedulerSupport("none") @BackpressureSupport(PASS_THROUGH) public static <@NonNull T> @NonNull Flowable<T> fromRunnable(@NonNull @NonNull java.lang.Runnable run)
Returns aFlowable
instance that runs the givenRunnable
for eachSubscriber
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 thefromAction(Action)
method which allows the wrapped code to throw anyThrowable
exception and will signal it to observers as-is.- Backpressure:
- This source doesn't produce any elements and effectively ignores downstream backpressure.
- Scheduler:
fromRunnable
does not operate by default on a particularScheduler
.- Error handling:
- If the
Runnable
throws an exception, the respectiveThrowable
is delivered to the downstream viaSubscriber.onError(Throwable)
, except when the downstream has canceled the resultingFlowable
source. In this latter case, theThrowable
is delivered to the global error handler viaRxJavaPlugins.onError(Throwable)
as anUndeliverableException
.
- Type Parameters:
T
- the target type- Parameters:
run
- theRunnable
to run for eachSubscriber
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifrun
isnull
- Since:
- 3.0.0
- See Also:
fromAction(Action)
-
fromSingle
@CheckReturnValue @NonNull @SchedulerSupport("none") @BackpressureSupport(FULL) public static <@NonNull T> @NonNull Flowable<T> fromSingle(@NonNull @NonNull SingleSource<@NonNull T> source)
Returns aFlowable
instance that when subscribed to, subscribes to theSingleSource
instance and emitsonSuccess
as a single item or forwards theonError
signal.- Backpressure:
- The operator honors backpressure from downstream.
- Scheduler:
fromSingle
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the value type of theSingleSource
element- Parameters:
source
- theSingleSource
instance to subscribe to, notnull
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsource
isnull
- Since:
- 3.0.0
-
fromSupplier
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> fromSupplier(@NonNull @NonNull Supplier<? extends @NonNull T> supplier)
Returns aFlowable
that, when aSubscriber
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 a
Subscriber
subscribes to thePublisher
. That is to say, it makes the function "lazy."- Backpressure:
- The operator honors backpressure from downstream.
- Scheduler:
fromSupplier
does not operate by default on a particularScheduler
.- Error handling:
- If the
Supplier
throws an exception, the respectiveThrowable
is delivered to the downstream viaSubscriber.onError(Throwable)
, except when the downstream has canceled thisFlowable
source. In this latter case, theThrowable
is delivered to the global error handler viaRxJavaPlugins.onError(Throwable)
as anUndeliverableException
.
- Type Parameters:
T
- the type of the item emitted by thePublisher
- Parameters:
supplier
- a function, the execution of which should be deferred;fromSupplier
will invoke this function only when aSubscriber
subscribes to thePublisher
thatfromSupplier
returns- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsupplier
isnull
- Since:
- 3.0.0
- See Also:
defer(Supplier)
,fromCallable(Callable)
-
generate
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> generate(@NonNull @NonNull Consumer<@NonNull Emitter<@NonNull T>> generator)
Returns a cold, synchronous, stateless and backpressure-aware generator of values.Note that the
Emitter.onNext(T)
,Emitter.onError(java.lang.Throwable)
andEmitter.onComplete()
methods provided to the function via theEmitter
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.- Backpressure:
- The operator honors downstream backpressure.
- Scheduler:
generate
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the generated value type- Parameters:
generator
- theConsumer
called whenever a particular downstreamSubscriber
has requested a value. The callback then should callonNext
,onError
oronComplete
to signal a value or a terminal event. Signaling multipleonNext
in a call will make the operator signalIllegalStateException
.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifgenerator
isnull
-
generate
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T,@NonNull S> @NonNull Flowable<T> generate(@NonNull @NonNull Supplier<@NonNull S> initialState, @NonNull @NonNull BiConsumer<@NonNull S,Emitter<@NonNull T>> generator)
Returns a cold, synchronous, stateful and backpressure-aware generator of values.Note that the
Emitter.onNext(T)
,Emitter.onError(java.lang.Throwable)
andEmitter.onComplete()
methods provided to the function via theEmitter
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.- Backpressure:
- The operator honors downstream backpressure.
- Scheduler:
generate
does not operate by default on a particularScheduler
.
- Type Parameters:
S
- the type of the per-Subscriber
stateT
- the generated value type- Parameters:
initialState
- theSupplier
to generate the initial state for eachSubscriber
generator
- theConsumer
called with the current state whenever a particular downstreamSubscriber
has requested a value. The callback then should callonNext
,onError
oronComplete
to signal a value or a terminal event. Signaling multipleonNext
in a call will make the operator signalIllegalStateException
.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifinitialState
orgenerator
isnull
-
generate
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T,@NonNull S> @NonNull Flowable<T> generate(@NonNull @NonNull Supplier<@NonNull S> initialState, @NonNull @NonNull BiConsumer<@NonNull S,Emitter<@NonNull T>> generator, @NonNull @NonNull Consumer<? super @NonNull S> disposeState)
Returns a cold, synchronous, stateful and backpressure-aware generator of values.Note that the
Emitter.onNext(T)
,Emitter.onError(java.lang.Throwable)
andEmitter.onComplete()
methods provided to the function via theEmitter
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.- Backpressure:
- The operator honors downstream backpressure.
- Scheduler:
generate
does not operate by default on a particularScheduler
.
- Type Parameters:
S
- the type of the per-Subscriber
stateT
- the generated value type- Parameters:
initialState
- theSupplier
to generate the initial state for eachSubscriber
generator
- theConsumer
called with the current state whenever a particular downstreamSubscriber
has requested a value. The callback then should callonNext
,onError
oronComplete
to signal a value or a terminal event. Signaling multipleonNext
in a call will make the operator signalIllegalStateException
.disposeState
- theConsumer
that is called with the current state when the generator terminates the sequence or it gets canceled- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifinitialState
,generator
ordisposeState
isnull
-
generate
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public static <@NonNull T,@NonNull S> @NonNull Flowable<T> generate(@NonNull @NonNull Supplier<@NonNull S> initialState, @NonNull @NonNull BiFunction<@NonNull S,@NonNull Emitter<@NonNull T>,@NonNull S> generator)
Returns a cold, synchronous, stateful and backpressure-aware generator of values.Note that the
Emitter.onNext(T)
,Emitter.onError(java.lang.Throwable)
andEmitter.onComplete()
methods provided to the function via theEmitter
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.- Backpressure:
- The operator honors downstream backpressure.
- Scheduler:
generate
does not operate by default on a particularScheduler
.
- Type Parameters:
S
- the type of the per-Subscriber
stateT
- the generated value type- Parameters:
initialState
- theSupplier
to generate the initial state for eachSubscriber
generator
- theFunction
called with the current state whenever a particular downstreamSubscriber
has requested a value. The callback then should callonNext
,onError
oronComplete
to signal a value or a terminal event and should return a (new) state for the next invocation. Signaling multipleonNext
in a call will make the operator signalIllegalStateException
.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifinitialState
orgenerator
isnull
-
generate
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T,@NonNull S> @NonNull Flowable<T> generate(@NonNull @NonNull Supplier<@NonNull S> initialState, @NonNull @NonNull BiFunction<@NonNull S,@NonNull Emitter<@NonNull T>,@NonNull S> generator, @NonNull @NonNull Consumer<? super @NonNull S> disposeState)
Returns a cold, synchronous, stateful and backpressure-aware generator of values.Note that the
Emitter.onNext(T)
,Emitter.onError(java.lang.Throwable)
andEmitter.onComplete()
methods provided to the function via theEmitter
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.- Backpressure:
- The operator honors downstream backpressure.
- Scheduler:
generate
does not operate by default on a particularScheduler
.
- Type Parameters:
S
- the type of the per-Subscriber
stateT
- the generated value type- Parameters:
initialState
- theSupplier
to generate the initial state for eachSubscriber
generator
- theFunction
called with the current state whenever a particular downstreamSubscriber
has requested a value. The callback then should callonNext
,onError
oronComplete
to signal a value or a terminal event and should return a (new) state for the next invocation. Signaling multipleonNext
in a call will make the operator signalIllegalStateException
.disposeState
- theConsumer
that is called with the current state when the generator terminates the sequence or it gets canceled- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifinitialState
,generator
ordisposeState
isnull
-
interval
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("io.reactivex:computation") @NonNull public static @NonNull Flowable<java.lang.Long> interval(long initialDelay, long period, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits a0L
after theinitialDelay
and ever-increasing numbers after eachperiod
of time thereafter.- Backpressure:
- The operator generates values based on time and ignores downstream backpressure which
may lead to
MissingBackpressureException
at some point in the chain. Downstream consumers should consider applying one of theonBackpressureXXX
operators as well. - Scheduler:
interval
operates by default on thecomputation
Scheduler
.
- Parameters:
initialDelay
- the initial delay time to wait before emitting the first value of 0Lperiod
- the period of time between emissions of the subsequent numbersunit
- the time unit for bothinitialDelay
andperiod
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- Since:
- 1.0.12
- See Also:
- ReactiveX operators documentation: Interval
-
interval
@CheckReturnValue @NonNull @BackpressureSupport(ERROR) @SchedulerSupport("custom") public static @NonNull Flowable<java.lang.Long> interval(long initialDelay, long period, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns aFlowable
that emits a0L
after theinitialDelay
and ever-increasing numbers after eachperiod
of time thereafter, on a specifiedScheduler
.- Backpressure:
- The operator generates values based on time and ignores downstream backpressure which
may lead to
MissingBackpressureException
at some point in the chain. Downstream consumers should consider applying one of theonBackpressureXXX
operators as well. - Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
initialDelay
- the initial delay time to wait before emitting the first value of 0Lperiod
- the period of time between emissions of the subsequent numbersunit
- the time unit for bothinitialDelay
andperiod
scheduler
- theScheduler
on which the waiting happens and items are emitted- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- Since:
- 1.0.12
- See Also:
- ReactiveX operators documentation: Interval
-
interval
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("io.reactivex:computation") @NonNull public static @NonNull Flowable<java.lang.Long> interval(long period, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits a sequential number every specified interval of time.- Backpressure:
- The operator signals a
MissingBackpressureException
if the downstream is not ready to receive the next value. - Scheduler:
interval
operates by default on thecomputation
Scheduler
.
- Parameters:
period
- the period size in time units (see below)unit
- time units to use for the interval size- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Interval
-
interval
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("custom") @NonNull public static @NonNull Flowable<java.lang.Long> interval(long period, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns aFlowable
that emits a sequential number every specified interval of time, on a specifiedScheduler
.- Backpressure:
- The operator generates values based on time and ignores downstream backpressure which
may lead to
MissingBackpressureException
at some point in the chain. Downstream consumers should consider applying one of theonBackpressureXXX
operators as well. - Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
period
- the period size in time units (see below)unit
- time units to use for the interval sizescheduler
- theScheduler
to use for scheduling the items- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Interval
-
intervalRange
@CheckReturnValue @NonNull @BackpressureSupport(ERROR) @SchedulerSupport("io.reactivex:computation") public static @NonNull Flowable<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.- Backpressure:
- The operator signals a
MissingBackpressureException
if the downstream can't keep up. - Scheduler:
intervalRange
by default operates on thecomputation
Scheduler
.
- Parameters:
start
- that start value of the rangecount
- the number of values to emit in total, if zero, the operator emits anonComplete
after the initial delay.initialDelay
- the initial delay before signaling the first value (the start)period
- the period between subsequent valuesunit
- the unit of measure of theinitialDelay
andperiod
amounts- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
java.lang.IllegalArgumentException
- ifcount
is less than zero, or ifstart
+count
− 1 exceedsLong.MAX_VALUE
- See Also:
range(int, int)
-
intervalRange
@CheckReturnValue @NonNull @BackpressureSupport(ERROR) @SchedulerSupport("custom") public static @NonNull Flowable<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.
- Backpressure:
- The operator signals a
MissingBackpressureException
if the downstream can't keep up. - Scheduler:
- you provide the
Scheduler
.
- Parameters:
start
- that start value of the rangecount
- the number of values to emit in total, if zero, the operator emits anonComplete
after the initial delay.initialDelay
- the initial delay before signaling the first value (the start)period
- the period between subsequent valuesunit
- the unit of measure of theinitialDelay
andperiod
amountsscheduler
- the targetScheduler
where the values and terminal signals will be emitted- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
java.lang.IllegalArgumentException
- ifcount
is less than zero, or ifstart
+count
− 1 exceedsLong.MAX_VALUE
-
just
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> just(@NonNull T item)
Returns aFlowable
that signals the given (constant reference) item and then completes.Note that the item is taken and re-emitted as is and not computed by any means by
just
. UsefromCallable(Callable)
to generate a single item on demand (whenSubscriber
s subscribe to it).See the multi-parameter overloads of
just
to emit more than one (constant reference) items one after the other. UsefromArray(Object...)
to emit an arbitrary number of items that are known upfront.To emit the items of an
Iterable
sequence (such as aList
), usefromIterable(Iterable)
.- Backpressure:
- The operator honors backpressure from downstream.
- Scheduler:
just
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of that item- Parameters:
item
- the item to emit- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifitem
isnull
- See Also:
- ReactiveX operators documentation: Just,
just(Object, Object)
,fromCallable(Callable)
,fromArray(Object...)
,fromIterable(Iterable)
-
just
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> just(@NonNull T item1, @NonNull T item2)
Converts two items into aPublisher
that emits those items.- Backpressure:
- The operator honors backpressure from downstream and signals each value on-demand (i.e., when requested).
- Scheduler:
just
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of these items- Parameters:
item1
- first itemitem2
- second item- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifitem1
oritem2
isnull
- See Also:
- ReactiveX operators documentation: Just
-
just
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> just(@NonNull T item1, @NonNull T item2, @NonNull T item3)
Converts three items into aPublisher
that emits those items.- Backpressure:
- The operator honors backpressure from downstream and signals each value on-demand (i.e., when requested).
- Scheduler:
just
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of these items- Parameters:
item1
- first itemitem2
- second itemitem3
- third item- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifitem1
,item2
oritem3
isnull
- See Also:
- ReactiveX operators documentation: Just
-
just
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> just(@NonNull T item1, @NonNull T item2, @NonNull T item3, @NonNull T item4)
Converts four items into aPublisher
that emits those items.- Backpressure:
- The operator honors backpressure from downstream and signals each value on-demand (i.e., when requested).
- Scheduler:
just
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of these items- Parameters:
item1
- first itemitem2
- second itemitem3
- third itemitem4
- fourth item- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifitem1
,item2
,item3
, oritem4
isnull
- See Also:
- ReactiveX operators documentation: Just
-
just
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> just(@NonNull T item1, @NonNull T item2, @NonNull T item3, @NonNull T item4, @NonNull T item5)
Converts five items into aPublisher
that emits those items.- Backpressure:
- The operator honors backpressure from downstream and signals each value on-demand (i.e., when requested).
- Scheduler:
just
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of these items- Parameters:
item1
- first itemitem2
- second itemitem3
- third itemitem4
- fourth itemitem5
- fifth item- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifitem1
,item2
,item3
,item4
oritem5
isnull
- See Also:
- ReactiveX operators documentation: Just
-
just
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> just(@NonNull T item1, @NonNull T item2, @NonNull T item3, @NonNull T item4, @NonNull T item5, @NonNull T item6)
Converts six items into aPublisher
that emits those items.- Backpressure:
- The operator honors backpressure from downstream and signals each value on-demand (i.e., when requested).
- Scheduler:
just
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of these items- Parameters:
item1
- first itemitem2
- second itemitem3
- third itemitem4
- fourth itemitem5
- fifth itemitem6
- sixth item- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifitem1
,item2
,item3
,item4
,item5
oritem6
isnull
- See Also:
- ReactiveX operators documentation: Just
-
just
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> just(@NonNull T item1, @NonNull T item2, @NonNull T item3, @NonNull T item4, @NonNull T item5, @NonNull T item6, @NonNull T item7)
Converts seven items into aPublisher
that emits those items.- Backpressure:
- The operator honors backpressure from downstream and signals each value on-demand (i.e., when requested).
- Scheduler:
just
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of these items- Parameters:
item1
- first itemitem2
- second itemitem3
- third itemitem4
- fourth itemitem5
- fifth itemitem6
- sixth itemitem7
- seventh item- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifitem1
,item2
,item3
,item4
,item5
,item6
oritem7
isnull
- See Also:
- ReactiveX operators documentation: Just
-
just
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> just(@NonNull T item1, @NonNull T item2, @NonNull T item3, @NonNull T item4, @NonNull T item5, @NonNull T item6, @NonNull T item7, @NonNull T item8)
Converts eight items into aPublisher
that emits those items.- Backpressure:
- The operator honors backpressure from downstream and signals each value on-demand (i.e., when requested).
- Scheduler:
just
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of these items- Parameters:
item1
- first itemitem2
- second itemitem3
- third itemitem4
- fourth itemitem5
- fifth itemitem6
- sixth itemitem7
- seventh itemitem8
- eighth item- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifitem1
,item2
,item3
,item4
,item5
,item6
,item7
oritem8
isnull
- See Also:
- ReactiveX operators documentation: Just
-
just
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> just(@NonNull T item1, @NonNull T item2, @NonNull T item3, @NonNull T item4, @NonNull T item5, @NonNull T item6, @NonNull T item7, @NonNull T item8, @NonNull T item9)
Converts nine items into aPublisher
that emits those items.- Backpressure:
- The operator honors backpressure from downstream and signals each value on-demand (i.e., when requested).
- Scheduler:
just
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of these items- Parameters:
item1
- first itemitem2
- second itemitem3
- third itemitem4
- fourth itemitem5
- fifth itemitem6
- sixth itemitem7
- seventh itemitem8
- eighth itemitem9
- ninth item- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifitem1
,item2
,item3
,item4
,item5
,item6
,item7
,item8
oritem9
isnull
- See Also:
- ReactiveX operators documentation: Just
-
just
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> just(@NonNull T item1, @NonNull T item2, @NonNull T item3, @NonNull T item4, @NonNull T item5, @NonNull T item6, @NonNull T item7, @NonNull T item8, @NonNull T item9, @NonNull T item10)
Converts ten items into aPublisher
that emits those items.- Backpressure:
- The operator honors backpressure from downstream and signals each value on-demand (i.e., when requested).
- Scheduler:
just
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of these items- Parameters:
item1
- first itemitem2
- second itemitem3
- third itemitem4
- fourth itemitem5
- fifth itemitem6
- sixth itemitem7
- seventh itemitem8
- eighth itemitem9
- ninth itemitem10
- tenth item- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifitem1
,item2
,item3
,item4
,item5
,item6
,item7
,item8
,item9
, oritem10
isnull
- See Also:
- ReactiveX operators documentation: Just
-
merge
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> merge(@NonNull @NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, int maxConcurrency, int bufferSize)
Flattens anIterable
ofPublisher
s into onePublisher
, without any transformation, while limiting the number of concurrent subscriptions to thesePublisher
s.You can combine the items emitted by multiple
Publisher
s so that they appear as a singlePublisher
, by using themerge
method.- Backpressure:
- The operator honors backpressure from downstream. The source
Publisher
s are expected to honor backpressure; if violated, the operator may signalMissingBackpressureException
. - Scheduler:
merge
does not operate by default on a particularScheduler
.- Error handling:
- If any of the source
Publisher
s signal aThrowable
viaonError
, the resultingFlowable
terminates with thatThrowable
and all other sourcePublisher
s are canceled. If more than onePublisher
signals an error, the resultingFlowable
may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeException
containing two or more of the various error signals.Throwable
s that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable)
method asUndeliverableException
errors. Similarly,Throwable
s signaled by source(s) after the returnedFlowable
has been canceled or terminated with a (composite) error will be sent to the same global error handler. UsemergeDelayError(Iterable, int, int)
to merge sources and terminate only when all sourcePublisher
s have completed or failed with an error.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- theIterable
ofPublisher
smaxConcurrency
- the maximum number ofPublisher
s that may be subscribed to concurrentlybufferSize
- the number of items to prefetch from each innerPublisher
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
orbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Merge,
mergeDelayError(Iterable, int, int)
-
mergeArray
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @SafeVarargs @NonNull public static <@NonNull T> @NonNull Flowable<T> mergeArray(int maxConcurrency, int bufferSize, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T>... sources)
Flattens an array ofPublisher
s into onePublisher
, without any transformation, while limiting the number of concurrent subscriptions to thesePublisher
s.You can combine the items emitted by multiple
Publisher
s so that they appear as a singlePublisher
, by using themerge
method.- Backpressure:
- The operator honors backpressure from downstream. The source
Publisher
s are expected to honor backpressure; if violated, the operator may signalMissingBackpressureException
. - Scheduler:
mergeArray
does not operate by default on a particularScheduler
.- Error handling:
- If any of the source
Publisher
s signal aThrowable
viaonError
, the resultingFlowable
terminates with thatThrowable
and all other sourcePublisher
s are canceled. If more than onePublisher
signals an error, the resultingFlowable
may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeException
containing two or more of the various error signals.Throwable
s that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable)
method asUndeliverableException
errors. Similarly,Throwable
s signaled by source(s) after the returnedFlowable
has been canceled or terminated with a (composite) error will be sent to the same global error handler. UsemergeArrayDelayError(int, int, Publisher[])
to merge sources and terminate only when all sourcePublisher
s have completed or failed with an error.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- the array ofPublisher
smaxConcurrency
- the maximum number ofPublisher
s that may be subscribed to concurrentlybufferSize
- the number of items to prefetch from each innerPublisher
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
orbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Merge,
mergeArrayDelayError(int, int, Publisher...)
-
merge
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> merge(@NonNull @NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources)
Flattens anIterable
ofPublisher
s into onePublisher
, without any transformation.You can combine the items emitted by multiple
Publisher
s so that they appear as a singlePublisher
, by using themerge
method.- Backpressure:
- The operator honors backpressure from downstream. The source
Publisher
s are expected to honor backpressure; if violated, the operator may signalMissingBackpressureException
. - Scheduler:
merge
does not operate by default on a particularScheduler
.- Error handling:
- If any of the source
Publisher
s signal aThrowable
viaonError
, the resultingFlowable
terminates with thatThrowable
and all other sourcePublisher
s are canceled. If more than onePublisher
signals an error, the resultingFlowable
may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeException
containing two or more of the various error signals.Throwable
s that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable)
method asUndeliverableException
errors. Similarly,Throwable
s signaled by source(s) after the returnedFlowable
has been canceled or terminated with a (composite) error will be sent to the same global error handler. UsemergeDelayError(Iterable)
to merge sources and terminate only when all sourcePublisher
s have completed or failed with an error.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- theIterable
ofPublisher
s- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
- See Also:
- ReactiveX operators documentation: Merge,
mergeDelayError(Iterable)
-
merge
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> merge(@NonNull @NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, int maxConcurrency)
Flattens anIterable
ofPublisher
s into onePublisher
, without any transformation, while limiting the number of concurrent subscriptions to thesePublisher
s.You can combine the items emitted by multiple
Publisher
s so that they appear as a singlePublisher
, by using themerge
method.- Backpressure:
- The operator honors backpressure from downstream. The source
Publisher
s are expected to honor backpressure; if violated, the operator may signalMissingBackpressureException
. - Scheduler:
merge
does not operate by default on a particularScheduler
.- Error handling:
- If any of the source
Publisher
s signal aThrowable
viaonError
, the resultingFlowable
terminates with thatThrowable
and all other sourcePublisher
s are canceled. If more than onePublisher
signals an error, the resultingFlowable
may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeException
containing two or more of the various error signals.Throwable
s that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable)
method asUndeliverableException
errors. Similarly,Throwable
s signaled by source(s) after the returnedFlowable
has been canceled or terminated with a (composite) error will be sent to the same global error handler. UsemergeDelayError(Iterable, int)
to merge sources and terminate only when all sourcePublisher
s have completed or failed with an error.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- theIterable
ofPublisher
smaxConcurrency
- the maximum number ofPublisher
s that may be subscribed to concurrently- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
is less than or equal to 0- See Also:
- ReactiveX operators documentation: Merge,
mergeDelayError(Iterable, int)
-
merge
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> merge(@NonNull @NonNull org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources)
Flattens aPublisher
that emitsPublisher
s into a singlePublisher
that emits the items emitted by thosPublisher
s , without any transformation.You can combine the items emitted by multiple
Publisher
s so that they appear as a singlePublisher
, by using themerge
method.- Backpressure:
- The operator honors backpressure from downstream. The outer
Publisher
is consumed in unbounded mode (i.e., no backpressure is applied to it). The innerPublisher
s are expected to honor backpressure; if violated, the operator may signalMissingBackpressureException
. - Scheduler:
merge
does not operate by default on a particularScheduler
.- Error handling:
- If any of the source
Publisher
s signal aThrowable
viaonError
, the resultingFlowable
terminates with thatThrowable
and all other sourcePublisher
s are canceled. If more than onePublisher
signals an error, the resultingFlowable
may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeException
containing two or more of the various error signals.Throwable
s that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable)
method asUndeliverableException
errors. Similarly,Throwable
s signaled by source(s) after the returnedFlowable
has been canceled or terminated with a (composite) error will be sent to the same global error handler. UsemergeDelayError(Publisher)
to merge sources and terminate only when all sourcePublisher
s have completed or failed with an error.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- aPublisher
that emitsPublisher
s- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
- See Also:
- ReactiveX operators documentation: Merge,
mergeDelayError(Publisher)
-
merge
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> merge(@NonNull @NonNull org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, int maxConcurrency)
Flattens aPublisher
that emitsPublisher
s into a singlePublisher
that emits the items emitted by thosePublisher
s, without any transformation, while limiting the maximum number of concurrent subscriptions to thesePublisher
s.You can combine the items emitted by multiple
Publisher
s so that they appear as a singlePublisher
, by using themerge
method.- Backpressure:
- The operator honors backpressure from downstream. Both the outer and inner
Publisher
s are expected to honor backpressure; if violated, the operator may signalMissingBackpressureException
. - Scheduler:
merge
does not operate by default on a particularScheduler
.- Error handling:
- If any of the source
Publisher
s signal aThrowable
viaonError
, the resultingFlowable
terminates with thatThrowable
and all other sourcePublisher
s are canceled. If more than onePublisher
signals an error, the resultingFlowable
may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeException
containing two or more of the various error signals.Throwable
s that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable)
method asUndeliverableException
errors. Similarly,Throwable
s signaled by source(s) after the returnedFlowable
has been canceled or terminated with a (composite) error will be sent to the same global error handler. UsemergeDelayError(Publisher, int)
to merge sources and terminate only when all sourcePublisher
s have completed or failed with an error.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- aPublisher
that emitsPublisher
smaxConcurrency
- the maximum number ofPublisher
s that may be subscribed to concurrently- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
is less than or equal to 0- Since:
- 1.1.0
- See Also:
- ReactiveX operators documentation: Merge,
mergeDelayError(Publisher, int)
-
mergeArray
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @SafeVarargs @NonNull public static <@NonNull T> @NonNull Flowable<T> mergeArray(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T>... sources)
Flattens an array ofPublisher
s into onePublisher
, without any transformation.You can combine items emitted by multiple
Publisher
s so that they appear as a singlePublisher
, by using themerge
method.- Backpressure:
- The operator honors backpressure from downstream. The source
Publisher
s are expected to honor backpressure; if violated, the operator may signalMissingBackpressureException
. - Scheduler:
mergeArray
does not operate by default on a particularScheduler
.- Error handling:
- If any of the source
Publisher
s signal aThrowable
viaonError
, the resultingFlowable
terminates with thatThrowable
and all other sourcePublisher
s are canceled. If more than onePublisher
signals an error, the resultingFlowable
may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeException
containing two or more of the various error signals.Throwable
s that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable)
method asUndeliverableException
errors. Similarly,Throwable
s signaled by source(s) after the returnedFlowable
has been canceled or terminated with a (composite) error will be sent to the same global error handler. UsemergeArrayDelayError(Publisher...)
to merge sources and terminate only when all sourcePublisher
s have completed or failed with an error.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- the array ofPublisher
s- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
- See Also:
- ReactiveX operators documentation: Merge,
mergeArrayDelayError(Publisher...)
-
merge
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> merge(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source1, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source2)
Flattens twoPublisher
s into a singlePublisher
, without any transformation.You can combine items emitted by multiple
Publisher
s so that they appear as a singlePublisher
, by using themerge
method.- Backpressure:
- The operator honors backpressure from downstream. The source
Publisher
s are expected to honor backpressure; if violated, the operator may signalMissingBackpressureException
. - Scheduler:
merge
does not operate by default on a particularScheduler
.- Error handling:
- If any of the source
Publisher
s signal aThrowable
viaonError
, the resultingFlowable
terminates with thatThrowable
and all other sourcePublisher
s are canceled. If more than onePublisher
signals an error, the resultingFlowable
may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeException
containing two or more of the various error signals.Throwable
s that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable)
method asUndeliverableException
errors. Similarly,Throwable
s signaled by source(s) after the returnedFlowable
has been canceled or terminated with a (composite) error will be sent to the same global error handler. UsemergeDelayError(Publisher, Publisher)
to merge sources and terminate only when all sourcePublisher
s have completed or failed with an error.
- Type Parameters:
T
- the common element base type- Parameters:
source1
- aPublisher
to be mergedsource2
- aPublisher
to be merged- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsource1
orsource2
isnull
- See Also:
- ReactiveX operators documentation: Merge,
mergeDelayError(Publisher, Publisher)
-
merge
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> merge(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source1, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source2, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source3)
Flattens threePublisher
s into a singlePublisher
, without any transformation.You can combine items emitted by multiple
Publisher
s so that they appear as a singlePublisher
, by using themerge
method.- Backpressure:
- The operator honors backpressure from downstream. The source
Publisher
s are expected to honor backpressure; if violated, the operator may signalMissingBackpressureException
. - Scheduler:
merge
does not operate by default on a particularScheduler
.- Error handling:
- If any of the source
Publisher
s signal aThrowable
viaonError
, the resultingFlowable
terminates with thatThrowable
and all other sourcePublisher
s are canceled. If more than onePublisher
signals an error, the resultingFlowable
may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeException
containing two or more of the various error signals.Throwable
s that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable)
method asUndeliverableException
errors. Similarly,Throwable
s signaled by source(s) after the returnedFlowable
has been canceled or terminated with a (composite) error will be sent to the same global error handler. UsemergeDelayError(Publisher, Publisher, Publisher)
to merge sources and terminate only when all sourcePublisher
s have completed or failed with an error.
- Type Parameters:
T
- the common element base type- Parameters:
source1
- aPublisher
to be mergedsource2
- aPublisher
to be mergedsource3
- aPublisher
to be merged- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
orsource3
isnull
- See Also:
- ReactiveX operators documentation: Merge,
mergeDelayError(Publisher, Publisher, Publisher)
-
merge
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> merge(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source1, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source2, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source3, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source4)
Flattens fourPublisher
s into a singlePublisher
, without any transformation.You can combine items emitted by multiple
Publisher
s so that they appear as a singlePublisher
, by using themerge
method.- Backpressure:
- The operator honors backpressure from downstream. The source
Publisher
s are expected to honor backpressure; if violated, the operator may signalMissingBackpressureException
. - Scheduler:
merge
does not operate by default on a particularScheduler
.- Error handling:
- If any of the source
Publisher
s signal aThrowable
viaonError
, the resultingFlowable
terminates with thatThrowable
and all other sourcePublisher
s are canceled. If more than onePublisher
signals an error, the resultingFlowable
may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeException
containing two or more of the various error signals.Throwable
s that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable)
method asUndeliverableException
errors. Similarly,Throwable
s signaled by source(s) after the returnedFlowable
has been canceled or terminated with a (composite) error will be sent to the same global error handler. UsemergeDelayError(Publisher, Publisher, Publisher, Publisher)
to merge sources and terminate only when all sourcePublisher
s have completed or failed with an error.
- Type Parameters:
T
- the common element base type- Parameters:
source1
- aPublisher
to be mergedsource2
- aPublisher
to be mergedsource3
- aPublisher
to be mergedsource4
- aPublisher
to be merged- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
orsource4
isnull
- See Also:
- ReactiveX operators documentation: Merge,
mergeDelayError(Publisher, Publisher, Publisher, Publisher)
-
mergeDelayError
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> mergeDelayError(@NonNull @NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources)
Flattens anIterable
ofPublisher
s into onePublisher
, in a way that allows aSubscriber
to receive all successfully emitted items from each of the sourcePublisher
s without being interrupted by an error notification from one of them.This behaves like
merge(Publisher)
except that if any of the mergedPublisher
s notify of an error viaonError
,mergeDelayError
will refrain from propagating that error notification until all of the mergedPublisher
s have finished emitting items.Even if multiple merged
Publisher
s sendonError
notifications,mergeDelayError
will only invoke theonError
method of itsSubscriber
s once.- Backpressure:
- The operator honors backpressure from downstream. All inner
Publisher
s are expected to honor backpressure; if violated, the operator may signalMissingBackpressureException
. - Scheduler:
mergeDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- theIterable
ofPublisher
s- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
- See Also:
- ReactiveX operators documentation: Merge
-
mergeDelayError
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> mergeDelayError(@NonNull @NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, int maxConcurrency, int bufferSize)
Flattens anIterable
ofPublisher
s into onePublisher
, in a way that allows aSubscriber
to receive all successfully emitted items from each of the sourcePublisher
s without being interrupted by an error notification from one of them, while limiting the number of concurrent subscriptions to thesePublisher
s.This behaves like
merge(Publisher)
except that if any of the mergedPublisher
s notify of an error viaonError
,mergeDelayError
will refrain from propagating that error notification until all of the mergedPublisher
s have finished emitting items.Even if multiple merged
Publisher
s sendonError
notifications,mergeDelayError
will only invoke theonError
method of itsSubscriber
s once.- Backpressure:
- The operator honors backpressure from downstream. All inner
Publisher
s are expected to honor backpressure; if violated, the operator may signalMissingBackpressureException
. - Scheduler:
mergeDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- theIterable
ofPublisher
smaxConcurrency
- the maximum number ofPublisher
s that may be subscribed to concurrentlybufferSize
- the number of items to prefetch from each innerPublisher
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
orbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Merge
-
mergeArrayDelayError
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @SafeVarargs @NonNull public static <@NonNull T> @NonNull Flowable<T> mergeArrayDelayError(int maxConcurrency, int bufferSize, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T>... sources)
Flattens an array ofPublisher
s into onePublisher
, in a way that allows aSubscriber
to receive all successfully emitted items from each of the sourcePublisher
s without being interrupted by an error notification from one of them, while limiting the number of concurrent subscriptions to thesePublisher
s.This behaves like
merge(Publisher)
except that if any of the mergedPublisher
s notify of an error viaonError
,mergeDelayError
will refrain from propagating that error notification until all of the mergedPublisher
s have finished emitting items.Even if multiple merged
Publisher
s sendonError
notifications,mergeDelayError
will only invoke theonError
method of itsSubscriber
s once.- Backpressure:
- The operator honors backpressure from downstream. All source
Publisher
s are expected to honor backpressure; if violated, the operator may signalMissingBackpressureException
. - Scheduler:
mergeArrayDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- the array ofPublisher
smaxConcurrency
- the maximum number ofPublisher
s that may be subscribed to concurrentlybufferSize
- the number of items to prefetch from each innerPublisher
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
orbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Merge
-
mergeDelayError
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> mergeDelayError(@NonNull @NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, int maxConcurrency)
Flattens anIterable
ofPublisher
s into onePublisher
, in a way that allows aSubscriber
to receive all successfully emitted items from each of the sourcePublisher
s without being interrupted by an error notification from one of them, while limiting the number of concurrent subscriptions to thesePublisher
s.This behaves like
merge(Publisher)
except that if any of the mergedPublisher
s notify of an error viaonError
,mergeDelayError
will refrain from propagating that error notification until all of the mergedPublisher
s have finished emitting items.Even if multiple merged
Publisher
s sendonError
notifications,mergeDelayError
will only invoke theonError
method of itsSubscriber
s once.- Backpressure:
- The operator honors backpressure from downstream. All inner
Publisher
s are expected to honor backpressure; if violated, the operator may signalMissingBackpressureException
. - Scheduler:
mergeDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- theIterable
ofPublisher
smaxConcurrency
- the maximum number ofPublisher
s that may be subscribed to concurrently- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
is non-positive- See Also:
- ReactiveX operators documentation: Merge
-
mergeDelayError
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> mergeDelayError(@NonNull @NonNull org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources)
Flattens aPublisher
that emitsPublisher
s into onePublisher
, in a way that allows aSubscriber
to receive all successfully emitted items from all of the sourcePublisher
s without being interrupted by an error notification from one of them.This behaves like
merge(Publisher)
except that if any of the mergedPublisher
s notify of an error viaonError
,mergeDelayError
will refrain from propagating that error notification until all of the mergedPublisher
s have finished emitting items.Even if multiple merged
Publisher
s sendonError
notifications,mergeDelayError
will only invoke theonError
method of itsSubscriber
s once.- Backpressure:
- The operator honors backpressure from downstream. The outer
Publisher
is consumed in unbounded mode (i.e., no backpressure is applied to it). The innerPublisher
s are expected to honor backpressure; if violated, the operator may signalMissingBackpressureException
. - Scheduler:
mergeDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- aPublisher
that emitsPublisher
s- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
- See Also:
- ReactiveX operators documentation: Merge
-
mergeDelayError
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> mergeDelayError(@NonNull @NonNull org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, int maxConcurrency)
Flattens aPublisher
that emitsPublisher
s into onePublisher
, in a way that allows aSubscriber
to receive all successfully emitted items from all of the sourcePublisher
s without being interrupted by an error notification from one of them, while limiting the number of concurrent subscriptions to thesePublisher
s.This behaves like
merge(Publisher)
except that if any of the mergedPublisher
s notify of an error viaonError
,mergeDelayError
will refrain from propagating that error notification until all of the mergedPublisher
s have finished emitting items.Even if multiple merged
Publisher
s sendonError
notifications,mergeDelayError
will only invoke theonError
method of itsSubscriber
s once.- Backpressure:
- The operator honors backpressure from downstream. Both the outer and inner
Publisher
s are expected to honor backpressure; if violated, the operator may signalMissingBackpressureException
. - Scheduler:
mergeDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- aPublisher
that emitsPublisher
smaxConcurrency
- the maximum number ofPublisher
s that may be subscribed to concurrently- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
is non-positive- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: Merge
-
mergeArrayDelayError
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @SafeVarargs @NonNull public static <@NonNull T> @NonNull Flowable<T> mergeArrayDelayError(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T>... sources)
Flattens an array ofPublisher
s into oneFlowable
, in a way that allows aSubscriber
to receive all successfully emitted items from each of the sourcePublisher
s without being interrupted by an error notification from one of them.This behaves like
merge(Publisher)
except that if any of the mergedPublisher
s notify of an error viaonError
,mergeDelayError
will refrain from propagating that error notification until all of the mergedPublisher
s have finished emitting items.Even if multiple merged
Publisher
s sendonError
notifications,mergeDelayError
will only invoke theonError
method of itsSubscriber
s once.- Backpressure:
- The operator honors backpressure from downstream. Both the outer and inner
Publisher
s are expected to honor backpressure; if violated, the operator may signalMissingBackpressureException
. - Scheduler:
mergeArrayDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
sources
- the array ofPublisher
s- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
- See Also:
- ReactiveX operators documentation: Merge
-
mergeDelayError
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> mergeDelayError(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source1, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source2)
Flattens twoPublisher
s into onePublisher
, in a way that allows aSubscriber
to receive all successfully emitted items from each of the sourcePublisher
s without being interrupted by an error notification from one of them.This behaves like
merge(Publisher, Publisher)
except that if any of the mergedPublisher
s notify of an error viaonError
,mergeDelayError
will refrain from propagating that error notification until all of the mergedPublisher
s have finished emitting items.Even if both merged
Publisher
s sendonError
notifications,mergeDelayError
will only invoke theonError
method of itsSubscriber
s once.- Backpressure:
- The operator honors backpressure from downstream. The source
Publisher
s are expected to honor backpressure; if violated, the operator may signalMissingBackpressureException
. - Scheduler:
mergeDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
source1
- aPublisher
to be mergedsource2
- aPublisher
to be merged- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsource1
orsource2
isnull
- See Also:
- ReactiveX operators documentation: Merge
-
mergeDelayError
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> mergeDelayError(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source1, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source2, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source3)
Flattens threePublisher
s into onePublisher
, in a way that allows aSubscriber
to receive all successfully emitted items from all of the sourcePublisher
s without being interrupted by an error notification from one of them.This behaves like
merge(Publisher, Publisher, Publisher)
except that if any of the mergedPublisher
s notify of an error viaonError
,mergeDelayError
will refrain from propagating that error notification until all of the mergedPublisher
s have finished emitting items.Even if multiple merged
Publisher
s sendonError
notifications,mergeDelayError
will only invoke theonError
method of itsSubscriber
s once.- Backpressure:
- The operator honors backpressure from downstream. The source
Publisher
s are expected to honor backpressure; if violated, the operator may signalMissingBackpressureException
. - Scheduler:
mergeDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
source1
- aPublisher
to be mergedsource2
- aPublisher
to be mergedsource3
- aPublisher
to be merged- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
orsource3
isnull
- See Also:
- ReactiveX operators documentation: Merge
-
mergeDelayError
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> mergeDelayError(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source1, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source2, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source3, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source4)
Flattens fourPublisher
s into onePublisher
, in a way that allows aSubscriber
to receive all successfully emitted items from all of the sourcePublisher
s without being interrupted by an error notification from one of them.This behaves like
merge(Publisher, Publisher, Publisher, Publisher)
except that if any of the mergedPublisher
s notify of an error viaonError
,mergeDelayError
will refrain from propagating that error notification until all of the mergedPublisher
s have finished emitting items.Even if multiple merged
Publisher
s sendonError
notifications,mergeDelayError
will only invoke theonError
method of itsSubscriber
s once.- Backpressure:
- The operator honors backpressure from downstream. The source
Publisher
s are expected to honor backpressure; if violated, the operator may signalMissingBackpressureException
. - Scheduler:
mergeDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element base type- Parameters:
source1
- aPublisher
to be mergedsource2
- aPublisher
to be mergedsource3
- aPublisher
to be mergedsource4
- aPublisher
to be merged- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
orsource4
isnull
- See Also:
- ReactiveX operators documentation: Merge
-
never
@CheckReturnValue @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> never()
Returns aFlowable
that never sends any items or notifications to aSubscriber
.This
Publisher
is useful primarily for testing purposes.- Backpressure:
- This source doesn't produce any elements and effectively ignores downstream backpressure.
- Scheduler:
never
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of items (not) emitted by thePublisher
- Returns:
- the shared
Flowable
instance - See Also:
- ReactiveX operators documentation: Never
-
range
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public static @NonNull Flowable<java.lang.Integer> range(int start, int count)
Returns aFlowable
that emits a sequence ofInteger
s within a specified range.- Backpressure:
- The operator honors backpressure from downstream and signals values on-demand (i.e., when requested).
- Scheduler:
range
does not operate by default on a particularScheduler
.
- Parameters:
start
- the value of the firstInteger
in the sequencecount
- the number of sequentialInteger
s to generate- Returns:
- the new
Flowable
instance - Throws:
java.lang.IllegalArgumentException
- ifcount
is less than zero, or ifstart
+count
− 1 exceedsInteger.MAX_VALUE
- See Also:
- ReactiveX operators documentation: Range,
rangeLong(long, long)
,intervalRange(long, long, long, long, TimeUnit)
-
rangeLong
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public static @NonNull Flowable<java.lang.Long> rangeLong(long start, long count)
Returns aFlowable
that emits a sequence ofLong
s within a specified range.- Backpressure:
- The operator honors backpressure from downstream and signals values on-demand (i.e., when requested).
- Scheduler:
rangeLong
does not operate by default on a particularScheduler
.
- Parameters:
start
- the value of the firstLong
in the sequencecount
- the number of sequentialLong
s to generate- Returns:
- the new
Flowable
instance - Throws:
java.lang.IllegalArgumentException
- ifcount
is less than zero, or ifstart
+count
− 1 exceedsLong.MAX_VALUE
- See Also:
- ReactiveX operators documentation: Range
-
sequenceEqual
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Single<java.lang.Boolean> sequenceEqual(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source1, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source2)
Returns aSingle
that emits aBoolean
value that indicates whether twoPublisher
sequences are the same by comparing the items emitted by eachPublisher
pairwise.- Backpressure:
- This operator honors downstream backpressure and expects both of its sources
to honor backpressure as well. If violated, the operator will emit a
MissingBackpressureException
. - Scheduler:
sequenceEqual
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of items emitted by eachPublisher
- Parameters:
source1
- the firstPublisher
to comparesource2
- the secondPublisher
to compare- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifsource1
orsource2
isnull
- See Also:
- ReactiveX operators documentation: SequenceEqual
-
sequenceEqual
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Single<java.lang.Boolean> sequenceEqual(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source1, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source2, @NonNull @NonNull BiPredicate<? super @NonNull T,? super @NonNull T> isEqual)
Returns aSingle
that emits aBoolean
value that indicates whether twoPublisher
sequences are the same by comparing the items emitted by eachPublisher
pairwise based on the results of a specified equality function.- Backpressure:
- The operator honors backpressure from downstream. The source
Publisher
s are expected to honor backpressure; if violated, the operator signals aMissingBackpressureException
. - Scheduler:
sequenceEqual
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of items emitted by eachPublisher
- Parameters:
source1
- the firstPublisher
to comparesource2
- the secondPublisher
to compareisEqual
- a function used to compare items emitted by eachPublisher
- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
orisEqual
isnull
- See Also:
- ReactiveX operators documentation: SequenceEqual
-
sequenceEqual
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T> @NonNull Single<java.lang.Boolean> sequenceEqual(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source1, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source2, @NonNull @NonNull BiPredicate<? super @NonNull T,? super @NonNull T> isEqual, int bufferSize)
Returns aSingle
that emits aBoolean
value that indicates whether twoPublisher
sequences are the same by comparing the items emitted by eachPublisher
pairwise based on the results of a specified equality function.- Backpressure:
- The operator honors backpressure from downstream. The source
Publisher
s are expected to honor backpressure; if violated, the operator signals aMissingBackpressureException
. - Scheduler:
sequenceEqual
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of items emitted by eachPublisher
- Parameters:
source1
- the firstPublisher
to comparesource2
- the secondPublisher
to compareisEqual
- a function used to compare items emitted by eachPublisher
bufferSize
- the number of items to prefetch from the first and second sourcePublisher
- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
orisEqual
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: SequenceEqual
-
sequenceEqual
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Single<java.lang.Boolean> sequenceEqual(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source1, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> source2, int bufferSize)
Returns aSingle
that emits aBoolean
value that indicates whether twoPublisher
sequences are the same by comparing the items emitted by eachPublisher
pairwise.- Backpressure:
- This operator honors downstream backpressure and expects both of its sources
to honor backpressure as well. If violated, the operator will emit a
MissingBackpressureException
. - Scheduler:
sequenceEqual
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the type of items emitted by eachPublisher
- Parameters:
source1
- the firstPublisher
to comparesource2
- the secondPublisher
to comparebufferSize
- the number of items to prefetch from the first and second sourcePublisher
- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifsource1
orsource2
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: SequenceEqual
-
switchOnNext
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> switchOnNext(@NonNull @NonNull org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, int bufferSize)
Converts aPublisher
that emitsPublisher
s into aPublisher
that emits the items emitted by the most recently emitted of thosePublisher
s.switchOnNext
subscribes to aPublisher
that emitsPublisher
s. Each time it observes one of these emittedPublisher
s, thePublisher
returned byswitchOnNext
begins emitting the items emitted by thatPublisher
. When a newPublisher
is emitted,switchOnNext
stops emitting items from the earlier-emittedPublisher
and begins emitting items from the new one.The resulting
Flowable
completes if both the outerPublisher
and the last innerPublisher
, if any, complete. If the outerPublisher
signals anonError
, the innerPublisher
is canceled and the error delivered in-sequence.- Backpressure:
- The operator honors backpressure from downstream. The outer
Publisher
is consumed in an unbounded manner (i.e., without backpressure) and the innerPublisher
s are expected to honor backpressure but it is not enforced; the operator won't signal aMissingBackpressureException
but the violation may lead toOutOfMemoryError
due to internal buffer bloat. - Scheduler:
switchOnNext
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the item type- Parameters:
sources
- the sourcePublisher
that emitsPublisher
sbufferSize
- the number of items to prefetch from the innerPublisher
s- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Switch
-
switchOnNext
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> switchOnNext(@NonNull @NonNull org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources)
Converts aPublisher
that emitsPublisher
s into aPublisher
that emits the items emitted by the most recently emitted of thosePublisher
s.switchOnNext
subscribes to aPublisher
that emitsPublisher
s. Each time it observes one of these emittedPublisher
s, thePublisher
returned byswitchOnNext
begins emitting the items emitted by thatPublisher
. When a newPublisher
is emitted,switchOnNext
stops emitting items from the earlier-emittedPublisher
and begins emitting items from the new one.The resulting
Flowable
completes if both the outerPublisher
and the last innerPublisher
, if any, complete. If the outerPublisher
signals anonError
, the innerPublisher
is canceled and the error delivered in-sequence.- Backpressure:
- The operator honors backpressure from downstream. The outer
Publisher
is consumed in an unbounded manner (i.e., without backpressure) and the innerPublisher
s are expected to honor backpressure but it is not enforced; the operator won't signal aMissingBackpressureException
but the violation may lead toOutOfMemoryError
due to internal buffer bloat. - Scheduler:
switchOnNext
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the item type- Parameters:
sources
- the sourcePublisher
that emitsPublisher
s- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
- See Also:
- ReactiveX operators documentation: Switch
-
switchOnNextDelayError
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> switchOnNextDelayError(@NonNull @NonNull org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources)
Converts aPublisher
that emitsPublisher
s into aPublisher
that emits the items emitted by the most recently emitted of thosePublisher
s and delays any exception until allPublisher
s terminate.switchOnNext
subscribes to aPublisher
that emitsPublisher
s. Each time it observes one of these emittedPublisher
s, thePublisher
returned byswitchOnNext
begins emitting the items emitted by thatPublisher
. When a newPublisher
is emitted,switchOnNext
stops emitting items from the earlier-emittedPublisher
and begins emitting items from the new one.The resulting
Flowable
completes if both the mainPublisher
and the last innerPublisher
, if any, complete. If the mainPublisher
signals anonError
, the termination of the last innerPublisher
will emit that error as is or wrapped into aCompositeException
along with the other possible errors the former innerPublisher
s signaled.- Backpressure:
- The operator honors backpressure from downstream. The outer
Publisher
is consumed in an unbounded manner (i.e., without backpressure) and the innerPublisher
s are expected to honor backpressure but it is not enforced; the operator won't signal aMissingBackpressureException
but the violation may lead toOutOfMemoryError
due to internal buffer bloat. - Scheduler:
switchOnNextDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the item type- Parameters:
sources
- the sourcePublisher
that emitsPublisher
s- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: Switch
-
switchOnNextDelayError
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<T> switchOnNextDelayError(@NonNull @NonNull org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, int prefetch)
Converts aPublisher
that emitsPublisher
s into aPublisher
that emits the items emitted by the most recently emitted of thosePublisher
s and delays any exception until allPublisher
s terminate.switchOnNext
subscribes to aPublisher
that emitsPublisher
s. Each time it observes one of these emittedPublisher
s, thePublisher
returned byswitchOnNext
begins emitting the items emitted by thatPublisher
. When a newPublisher
is emitted,switchOnNext
stops emitting items from the earlier-emittedPublisher
and begins emitting items from the new one.The resulting
Flowable
completes if both the mainPublisher
and the last innerPublisher
, if any, complete. If the mainPublisher
signals anonError
, the termination of the last innerPublisher
will emit that error as is or wrapped into aCompositeException
along with the other possible errors the former innerPublisher
s signaled.- Backpressure:
- The operator honors backpressure from downstream. The outer
Publisher
is consumed in an unbounded manner (i.e., without backpressure) and the innerPublisher
s are expected to honor backpressure but it is not enforced; the operator won't signal aMissingBackpressureException
but the violation may lead toOutOfMemoryError
due to internal buffer bloat. - Scheduler:
switchOnNextDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the item type- Parameters:
sources
- the sourcePublisher
that emitsPublisher
sprefetch
- the number of items to prefetch from the innerPublisher
s- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
isnull
java.lang.IllegalArgumentException
- ifprefetch
is non-positive- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: Switch
-
timer
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("io.reactivex:computation") @NonNull public static @NonNull Flowable<java.lang.Long> timer(long delay, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits0L
after a specified delay, and then completes.- Backpressure:
- This operator does not support backpressure as it uses time. If the downstream needs a slower rate
it should slow the timer or use something like
onBackpressureDrop()
. - Scheduler:
timer
operates by default on thecomputation
Scheduler
.
- Parameters:
delay
- the initial delay before emitting a single0L
unit
- time units to use fordelay
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Timer
-
timer
@CheckReturnValue @NonNull @BackpressureSupport(ERROR) @SchedulerSupport("custom") public static @NonNull Flowable<java.lang.Long> timer(long delay, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns aFlowable
that emits0L
after a specified delay, on a specifiedScheduler
, and then completes.- Backpressure:
- This operator does not support backpressure as it uses time. If the downstream needs a slower rate
it should slow the timer or use something like
onBackpressureDrop()
. - Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
delay
- the initial delay before emitting a single 0Lunit
- time units to use fordelay
scheduler
- theScheduler
to use for scheduling the item- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Timer
-
unsafeCreate
@CheckReturnValue @NonNull @BackpressureSupport(NONE) @SchedulerSupport("none") public static <@NonNull T> @NonNull Flowable<T> unsafeCreate(@NonNull @NonNull org.reactivestreams.Publisher<@NonNull T> onSubscribe)
Create aFlowable
by wrapping aPublisher
which has to be implemented according to the Reactive Streams specification by handling backpressure and cancellation correctly; no safeguards are provided by theFlowable
itself.- Backpressure:
- This operator is a pass-through for backpressure and the behavior is determined by the
provided
Publisher
implementation. - Scheduler:
unsafeCreate
by default doesn't operate on any particularScheduler
.
- Type Parameters:
T
- the value type emitted- Parameters:
onSubscribe
- thePublisher
instance to wrap- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifonSubscribe
isnull
java.lang.IllegalArgumentException
- ifonSubscribe
is a subclass ofFlowable
; such instances don't need conversion and is possibly a port remnant from 1.x or one should usehide()
instead.
-
using
@CheckReturnValue @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") @NonNull public static <@NonNull T,@NonNull D> @NonNull Flowable<T> using(@NonNull @NonNull Supplier<? extends @NonNull D> resourceSupplier, @NonNull @NonNull Function<? super @NonNull D,? extends org.reactivestreams.Publisher<? extends @NonNull T>> sourceSupplier, @NonNull @NonNull Consumer<? super @NonNull D> resourceCleanup)
Constructs aFlowable
that creates a dependent resource object, aPublisher
with that resource and calls the providedresourceDisposer
function if this inner source terminates or the downstream cancels the flow.- Backpressure:
- The operator is a pass-through for backpressure and otherwise depends on the
backpressure support of the
Publisher
returned by theresourceFactory
. - Scheduler:
using
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the element type of the generatedPublisher
D
- the type of the resource associated with the output sequence- Parameters:
resourceSupplier
- the factory function to create a resource object that depends on thePublisher
sourceSupplier
- the factory function to create aPublisher
resourceCleanup
- the function that will dispose of the resource- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifresourceSupplier
,sourceSupplier
orresourceCleanup
isnull
- See Also:
- ReactiveX operators documentation: Using
-
using
@CheckReturnValue @NonNull @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") public static <@NonNull T,@NonNull D> @NonNull Flowable<T> using(@NonNull @NonNull Supplier<? extends @NonNull D> resourceSupplier, @NonNull @NonNull Function<? super @NonNull D,? extends org.reactivestreams.Publisher<? extends @NonNull T>> sourceSupplier, @NonNull @NonNull Consumer<? super @NonNull D> resourceCleanup, boolean eager)
Constructs aFlowable
that creates a dependent resource object, aPublisher
with that resource and calls the providedresourceDisposer
function if this inner source terminates or the downstream disposes the flow; doing it before these end-states have been reached ifeager == true
, after otherwise.- Backpressure:
- The operator is a pass-through for backpressure and otherwise depends on the
backpressure support of the
Publisher
returned by theresourceFactory
. - Scheduler:
using
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the element type of the generatedPublisher
D
- the type of the resource associated with the output sequence- Parameters:
resourceSupplier
- the factory function to create a resource object that depends on thePublisher
sourceSupplier
- the factory function to create aPublisher
resourceCleanup
- the function that will dispose of the resourceeager
- Iftrue
, the resource disposal will happen either on acancel()
call before the upstream is disposed or just before the emission of a terminal event (onComplete
oronError
). Iffalse
the resource disposal will happen either on acancel()
call after the upstream is disposed or just after the emission of a terminal event (onComplete
oronError
).- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifresourceSupplier
,sourceSupplier
orresourceCleanup
isnull
- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: Using
-
zip
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T,@NonNull R> @NonNull Flowable<R> zip(@NonNull @NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, @NonNull @NonNull Function<? super java.lang.Object[],? extends @NonNull R> zipper)
Returns aFlowable
that emits the results of a specified combiner function applied to combinations of items emitted, in sequence, by anIterable
of otherPublisher
s.zip
applies this function in strict sequence, so the first item emitted by the newPublisher
will be the result of the function applied to the first item emitted by each of the sourcePublisher
s; the second item emitted by the newPublisher
will be the result of the function applied to the second item emitted by each of thosePublisher
s; and so forth.The resulting
Flowable
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of the sourcePublisher
that emits the fewest items.The operator subscribes to its sources in the order they are specified and completes eagerly if one of the sources is shorter than the rest while canceling the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling
doOnComplete()
). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will cancel B immediately. For example:zip(Arrays.asList(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2)), (a) -> a)
action1
will be called butaction2
won't.
To work around this termination property, usedoOnCancel(Action)
as well or useusing()
to do cleanup in case of completion or cancellation.- Backpressure:
- The operator expects backpressure from the sources and honors backpressure from the downstream.
(I.e., zipping with
interval(long, TimeUnit)
may result inMissingBackpressureException
, use one of theonBackpressureX
to handle similar, backpressure-ignoring sources. - Scheduler:
zip
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common value typeR
- the zipped result type- Parameters:
sources
- anIterable
of sourcePublisher
szipper
- a function that, when applied to an item emitted by each of the sourcePublisher
s, results in an item that will be emitted by the resultingFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
orzipper
isnull
- See Also:
- ReactiveX operators documentation: Zip
-
zip
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T,@NonNull R> @NonNull Flowable<R> zip(@NonNull @NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<? extends @NonNull T>> sources, @NonNull @NonNull Function<? super java.lang.Object[],? extends @NonNull R> zipper, boolean delayError, int bufferSize)
Returns aFlowable
that emits the results of a specified combiner function applied to combinations of items emitted, in sequence, by anIterable
of otherPublisher
s.zip
applies this function in strict sequence, so the first item emitted by the newPublisher
will be the result of the function applied to the first item emitted by each of the sourcePublisher
s; the second item emitted by the newPublisher
will be the result of the function applied to the second item emitted by each of thosePublisher
s; and so forth.The resulting
Floawble
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of the sourcePublisher
that emits the fewest items.The operator subscribes to its sources in the order they are specified and completes eagerly if one of the sources is shorter than the rest while canceling the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling
doOnComplete()
). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will cancel B immediately. For example:zip(Arrays.asList(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2)), (a) -> a)
action1
will be called butaction2
won't.
To work around this termination property, usedoOnCancel(Action)
as well or useusing()
to do cleanup in case of completion or cancellation.- Backpressure:
- The operator expects backpressure from the sources and honors backpressure from the downstream.
(I.e., zipping with
interval(long, TimeUnit)
may result inMissingBackpressureException
, use one of theonBackpressureX
to handle similar, backpressure-ignoring sources. - Scheduler:
zip
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common source value typeR
- the zipped result type- Parameters:
sources
- anIterable
of sourcePublisher
szipper
- a function that, when applied to an item emitted by each of the sourcePublisher
s, results in an item that will be emitted by the resultingFlowable
delayError
- delay errors signaled by any of the sourcePublisher
until allPublisher
s terminatebufferSize
- the number of elements to prefetch from each sourcePublisher
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
orzipper
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Zip
-
zip
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T1,@NonNull T2,@NonNull R> @NonNull Flowable<R> zip(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull @NonNull BiFunction<? super @NonNull T1,? super @NonNull T2,? extends @NonNull R> zipper)
Returns aFlowable
that emits the results of a specified combiner function applied to combinations of two items emitted, in sequence, by two otherPublisher
s.zip
applies this function in strict sequence, so the first item emitted by the newPublisher
will be the result of the function applied to the first item emitted byo1
and the first item emitted byo2
; the second item emitted by the newPublisher
will be the result of the function applied to the second item emitted byo1
and the second item emitted byo2
; and so forth.The resulting
Flowable
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of the sourcePublisher
that emits the fewest items.The operator subscribes to its sources in the order they are specified and completes eagerly if one of the sources is shorter than the rest while canceling the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling
doOnComplete()
). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will cancel B immediately. For example:zip(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2), (a, b) -> a + b)
action1
will be called butaction2
won't.
To work around this termination property, usedoOnCancel(Action)
as well or useusing()
to do cleanup in case of completion or cancellation.- Backpressure:
- The operator expects backpressure from the sources and honors backpressure from the downstream.
(I.e., zipping with
interval(long, TimeUnit)
may result inMissingBackpressureException
, use one of theonBackpressureX
to handle similar, backpressure-ignoring sources. - Scheduler:
zip
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the value type of the first sourceT2
- the value type of the second sourceR
- the zipped result type- Parameters:
source1
- the first sourcePublisher
source2
- a second sourcePublisher
zipper
- a function that, when applied to an item emitted by each of the sourcePublisher
s, results in an item that will be emitted by the resultingFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
orzipper
isnull
- See Also:
- ReactiveX operators documentation: Zip
-
zip
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T1,@NonNull T2,@NonNull R> @NonNull Flowable<R> zip(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull @NonNull BiFunction<? super @NonNull T1,? super @NonNull T2,? extends @NonNull R> zipper, boolean delayError)
Returns aFlowable
that emits the results of a specified combiner function applied to combinations of two items emitted, in sequence, by two otherPublisher
s.zip
applies this function in strict sequence, so the first item emitted by the newPublisher
will be the result of the function applied to the first item emitted byo1
and the first item emitted byo2
; the second item emitted by the newPublisher
will be the result of the function applied to the second item emitted byo1
and the second item emitted byo2
; and so forth.The resulting
Flowable
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of the sourcePublisher
that emits the fewest items.The operator subscribes to its sources in the order they are specified and completes eagerly if one of the sources is shorter than the rest while canceling the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling
doOnComplete()
). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will cancel B immediately. For example:zip(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2), (a, b) -> a + b)
action1
will be called butaction2
won't.
To work around this termination property, usedoOnCancel(Action)
as well or useusing()
to do cleanup in case of completion or cancellation.- Backpressure:
- The operator expects backpressure from the sources and honors backpressure from the downstream.
(I.e., zipping with
interval(long, TimeUnit)
may result inMissingBackpressureException
, use one of theonBackpressureX
to handle similar, backpressure-ignoring sources. - Scheduler:
zip
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the value type of the first sourceT2
- the value type of the second sourceR
- the zipped result type- Parameters:
source1
- the first sourcePublisher
source2
- a second sourcePublisher
zipper
- a function that, when applied to an item emitted by each of the sourcePublisher
s, results in an item that will be emitted by the resultingFlowable
delayError
- delay errors from any of the sourcePublisher
s till the other terminates- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
orzipper
isnull
- See Also:
- ReactiveX operators documentation: Zip
-
zip
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T1,@NonNull T2,@NonNull R> @NonNull Flowable<R> zip(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull @NonNull BiFunction<? super @NonNull T1,? super @NonNull T2,? extends @NonNull R> zipper, boolean delayError, int bufferSize)
Returns aFlowable
that emits the results of a specified combiner function applied to combinations of two items emitted, in sequence, by two otherPublisher
s.zip
applies this function in strict sequence, so the first item emitted by the newPublisher
will be the result of the function applied to the first item emitted byo1
and the first item emitted byo2
; the second item emitted by the newPublisher
will be the result of the function applied to the second item emitted byo1
and the second item emitted byo2
; and so forth.The resulting
Flowable
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of the sourcePublisher
that emits the fewest items.The operator subscribes to its sources in the order they are specified and completes eagerly if one of the sources is shorter than the rest while canceling the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling
doOnComplete()
). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will cancel B immediately. For example:zip(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2), (a, b) -> a + b)
action1
will be called butaction2
won't.
To work around this termination property, usedoOnCancel(Action)
as well or useusing()
to do cleanup in case of completion or cancellation.- Backpressure:
- The operator expects backpressure from the sources and honors backpressure from the downstream.
(I.e., zipping with
interval(long, TimeUnit)
may result inMissingBackpressureException
, use one of theonBackpressureX
to handle similar, backpressure-ignoring sources. - Scheduler:
zip
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the value type of the first sourceT2
- the value type of the second sourceR
- the zipped result type- Parameters:
source1
- the first sourcePublisher
source2
- a second sourcePublisher
zipper
- a function that, when applied to an item emitted by each of the sourcePublisher
s, results in an item that will be emitted by the resultingFlowable
delayError
- delay errors from any of the sourcePublisher
s till the other terminatesbufferSize
- the number of elements to prefetch from each sourcePublisher
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
orzipper
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Zip
-
zip
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull R> @NonNull Flowable<R> zip(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T3> source3, @NonNull @NonNull Function3<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? extends @NonNull R> zipper)
Returns aFlowable
that emits the results of a specified combiner function applied to combinations of three items emitted, in sequence, by three otherPublisher
s.zip
applies this function in strict sequence, so the first item emitted by the newPublisher
will be the result of the function applied to the first item emitted byo1
, the first item emitted byo2
, and the first item emitted byo3
; the second item emitted by the newPublisher
will be the result of the function applied to the second item emitted byo1
, the second item emitted byo2
, and the second item emitted byo3
; and so forth.The resulting
Flowable
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of the sourcePublisher
that emits the fewest items.The operator subscribes to its sources in the order they are specified and completes eagerly if one of the sources is shorter than the rest while canceling the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling
doOnComplete()
). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will cancel B immediately. For example:zip(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2), ..., (a, b, c) -> a + b)
action1
will be called butaction2
won't.
To work around this termination property, usedoOnCancel(Action)
as well or useusing()
to do cleanup in case of completion or cancellation.- Backpressure:
- The operator expects backpressure from the sources and honors backpressure from the downstream.
(I.e., zipping with
interval(long, TimeUnit)
may result inMissingBackpressureException
, use one of theonBackpressureX
to handle similar, backpressure-ignoring sources. - Scheduler:
zip
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the value type of the first sourceT2
- the value type of the second sourceT3
- the value type of the third sourceR
- the zipped result type- Parameters:
source1
- the first sourcePublisher
source2
- a second sourcePublisher
source3
- a third sourcePublisher
zipper
- a function that, when applied to an item emitted by each of the sourcePublisher
s, results in an item that will be emitted by the resultingFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
orzipper
isnull
- See Also:
- ReactiveX operators documentation: Zip
-
zip
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull R> @NonNull Flowable<R> zip(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T3> source3, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T4> source4, @NonNull @NonNull Function4<? super @NonNull T1,? super @NonNull T2,? super @NonNull T3,? super @NonNull T4,? extends @NonNull R> zipper)
Returns aFlowable
that emits the results of a specified combiner function applied to combinations of four items emitted, in sequence, by four otherPublisher
s.zip
applies this function in strict sequence, so the first item emitted by the newPublisher
will be the result of the function applied to the first item emitted byo1
, the first item emitted byo2
, the first item emitted byo3
, and the first item emitted by04
; the second item emitted by the newPublisher
will be the result of the function applied to the second item emitted by each of thosePublisher
s; and so forth.The resulting
Flowable
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of the sourcePublisher
that emits the fewest items.The operator subscribes to its sources in the order they are specified and completes eagerly if one of the sources is shorter than the rest while canceling the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling
doOnComplete()
). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will cancel B immediately. For example:zip(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2), ..., (a, b, c, d) -> a + b)
action1
will be called butaction2
won't.
To work around this termination property, usedoOnCancel(Action)
as well or useusing()
to do cleanup in case of completion or cancellation.- Backpressure:
- The operator expects backpressure from the sources and honors backpressure from the downstream.
(I.e., zipping with
interval(long, TimeUnit)
may result inMissingBackpressureException
, use one of theonBackpressureX
to handle similar, backpressure-ignoring sources. - Scheduler:
zip
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the value type of the first sourceT2
- the value type of the second sourceT3
- the value type of the third sourceT4
- the value type of the fourth sourceR
- the zipped result type- Parameters:
source1
- the first sourcePublisher
source2
- a second sourcePublisher
source3
- a third sourcePublisher
source4
- a fourth sourcePublisher
zipper
- a function that, when applied to an item emitted by each of the sourcePublisher
s, results in an item that will be emitted by the resultingFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
,source4
orzipper
isnull
- See Also:
- ReactiveX operators documentation: Zip
-
zip
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull R> @NonNull Flowable<R> zip(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T3> source3, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T4> source4, @NonNull @NonNull org.reactivestreams.Publisher<? 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 aFlowable
that emits the results of a specified combiner function applied to combinations of five items emitted, in sequence, by five otherPublisher
s.zip
applies this function in strict sequence, so the first item emitted by the newPublisher
will be the result of the function applied to the first item emitted byo1
, the first item emitted byo2
, the first item emitted byo3
, the first item emitted byo4
, and the first item emitted byo5
; the second item emitted by the newPublisher
will be the result of the function applied to the second item emitted by each of thosePublisher
s; and so forth.The resulting
Flowable
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of the sourcePublisher
that emits the fewest items.The operator subscribes to its sources in the order they are specified and completes eagerly if one of the sources is shorter than the rest while canceling the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling
doOnComplete()
). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will cancel B immediately. For example:zip(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2), ..., (a, b, c, d, e) -> a + b)
action1
will be called butaction2
won't.
To work around this termination property, usedoOnCancel(Action)
as well or useusing()
to do cleanup in case of completion or cancellation.- Backpressure:
- The operator expects backpressure from the sources and honors backpressure from the downstream.
(I.e., zipping with
interval(long, TimeUnit)
may result inMissingBackpressureException
, use one of theonBackpressureX
to handle similar, backpressure-ignoring sources. - Scheduler:
zip
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the value type of the first sourceT2
- the value type of the second sourceT3
- the value type of the third sourceT4
- the value type of the fourth sourceT5
- the value type of the fifth sourceR
- the zipped result type- Parameters:
source1
- the first sourcePublisher
source2
- a second sourcePublisher
source3
- a third sourcePublisher
source4
- a fourth sourcePublisher
source5
- a fifth sourcePublisher
zipper
- a function that, when applied to an item emitted by each of the sourcePublisher
s, results in an item that will be emitted by the resultingFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
,source4
,source5
orzipper
isnull
- See Also:
- ReactiveX operators documentation: Zip
-
zip
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull R> @NonNull Flowable<R> zip(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T3> source3, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T4> source4, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T5> source5, @NonNull @NonNull org.reactivestreams.Publisher<? 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 aFlowable
that emits the results of a specified combiner function applied to combinations of six items emitted, in sequence, by six otherPublisher
s.zip
applies this function in strict sequence, so the first item emitted by the newPublisher
will be the result of the function applied to the first item emitted by each sourcePublisher
, the second item emitted by the newPublisher
will be the result of the function applied to the second item emitted by each of thosePublisher
s, and so forth.The resulting
Flowable
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of the sourcePublisher
that emits the fewest items.The operator subscribes to its sources in the order they are specified and completes eagerly if one of the sources is shorter than the rest while canceling the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling
doOnComplete()
). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will cancel B immediately. For example:zip(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2), ..., (a, b, c, d, e, f) -> a + b)
action1
will be called butaction2
won't.
To work around this termination property, usedoOnCancel(Action)
as well or useusing()
to do cleanup in case of completion or cancellation.- Backpressure:
- The operator expects backpressure from the sources and honors backpressure from the downstream.
(I.e., zipping with
interval(long, TimeUnit)
may result inMissingBackpressureException
, use one of theonBackpressureX
to handle similar, backpressure-ignoring sources. - Scheduler:
zip
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the value type of the first sourceT2
- the value type of the second sourceT3
- the value type of the third sourceT4
- the value type of the fourth sourceT5
- the value type of the fifth sourceT6
- the value type of the sixth sourceR
- the zipped result type- Parameters:
source1
- the first sourcePublisher
source2
- a second sourcePublisher
source3
- a third sourcePublisher
source4
- a fourth sourcePublisher
source5
- a fifth sourcePublisher
source6
- a sixth sourcePublisher
zipper
- a function that, when applied to an item emitted by each of the sourcePublisher
s, results in an item that will be emitted by the resultingFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
,source4
,source5
,source6
orzipper
isnull
- See Also:
- ReactiveX operators documentation: Zip
-
zip
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull T7,@NonNull R> @NonNull Flowable<R> zip(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T3> source3, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T4> source4, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T5> source5, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T6> source6, @NonNull @NonNull org.reactivestreams.Publisher<? 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 aFlowable
that emits the results of a specified combiner function applied to combinations of seven items emitted, in sequence, by seven otherPublisher
s.zip
applies this function in strict sequence, so the first item emitted by the newPublisher
will be the result of the function applied to the first item emitted by each sourcePublisher
, the second item emitted by the newPublisher
will be the result of the function applied to the second item emitted by each of thosePublisher
s, and so forth.The resulting
Flowable
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of the sourcePublisher
that emits the fewest items.The operator subscribes to its sources in the order they are specified and completes eagerly if one of the sources is shorter than the rest while canceling the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling
doOnComplete()
). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will cancel B immediately. For example:zip(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2), ..., (a, b, c, d, e, f, g) -> a + b)
action1
will be called butaction2
won't.
To work around this termination property, usedoOnCancel(Action)
as well or useusing()
to do cleanup in case of completion or cancellation.- Backpressure:
- The operator expects backpressure from the sources and honors backpressure from the downstream.
(I.e., zipping with
interval(long, TimeUnit)
may result inMissingBackpressureException
, use one of theonBackpressureX
to handle similar, backpressure-ignoring sources. - Scheduler:
zip
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the value type of the first sourceT2
- the value type of the second sourceT3
- the value type of the third sourceT4
- the value type of the fourth sourceT5
- the value type of the fifth sourceT6
- the value type of the sixth sourceT7
- the value type of the seventh sourceR
- the zipped result type- Parameters:
source1
- the first sourcePublisher
source2
- a second sourcePublisher
source3
- a third sourcePublisher
source4
- a fourth sourcePublisher
source5
- a fifth sourcePublisher
source6
- a sixth sourcePublisher
source7
- a seventh sourcePublisher
zipper
- a function that, when applied to an item emitted by each of the sourcePublisher
s, results in an item that will be emitted by the resultingFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
,source4
,source5
,source6
,source7
orzipper
isnull
- See Also:
- ReactiveX operators documentation: Zip
-
zip
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull T7,@NonNull T8,@NonNull R> @NonNull Flowable<R> zip(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T3> source3, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T4> source4, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T5> source5, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T6> source6, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T7> source7, @NonNull @NonNull org.reactivestreams.Publisher<? 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 aFlowable
that emits the results of a specified combiner function applied to combinations of eight items emitted, in sequence, by eight otherPublisher
s.zip
applies this function in strict sequence, so the first item emitted by the newPublisher
will be the result of the function applied to the first item emitted by each sourcePublisher
, the second item emitted by the newPublisher
will be the result of the function applied to the second item emitted by each of thosePublisher
s, and so forth.The resulting
Flowable
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of the sourcePublisher
that emits the fewest items.The operator subscribes to its sources in the order they are specified and completes eagerly if one of the sources is shorter than the rest while canceling the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling
doOnComplete()
). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will cancel B immediately. For example:zip(range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2), ..., (a, b, c, d, e, f, g, h) -> a + b)
action1
will be called butaction2
won't.
To work around this termination property, usedoOnCancel(Action)
as well or useusing()
to do cleanup in case of completion or cancellation.- Backpressure:
- The operator expects backpressure from the sources and honors backpressure from the downstream.
(I.e., zipping with
interval(long, TimeUnit)
may result inMissingBackpressureException
, use one of theonBackpressureX
to handle similar, backpressure-ignoring sources. - Scheduler:
zip
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the value type of the first sourceT2
- the value type of the second sourceT3
- the value type of the third sourceT4
- the value type of the fourth sourceT5
- the value type of the fifth sourceT6
- the value type of the sixth sourceT7
- the value type of the seventh sourceT8
- the value type of the eighth sourceR
- the zipped result type- Parameters:
source1
- the first sourcePublisher
source2
- a second sourcePublisher
source3
- a third sourcePublisher
source4
- a fourth sourcePublisher
source5
- a fifth sourcePublisher
source6
- a sixth sourcePublisher
source7
- a seventh sourcePublisher
source8
- an eighth sourcePublisher
zipper
- a function that, when applied to an item emitted by each of the sourcePublisher
s, results in an item that will be emitted by the resultingFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
,source4
,source5
,source6
,source7
,source8
orzipper
isnull
- See Also:
- ReactiveX operators documentation: Zip
-
zip
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public static <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull T5,@NonNull T6,@NonNull T7,@NonNull T8,@NonNull T9,@NonNull R> @NonNull Flowable<R> zip(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T1> source1, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T2> source2, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T3> source3, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T4> source4, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T5> source5, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T6> source6, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T7> source7, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T8> source8, @NonNull @NonNull org.reactivestreams.Publisher<? 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 aFlowable
that emits the results of a specified combiner function applied to combinations of nine items emitted, in sequence, by nine otherPublisher
s.zip
applies this function in strict sequence, so the first item emitted by the newPublisher
will be the result of the function applied to the first item emitted by each sourcePublisher
, the second item emitted by the newPublisher
will be the result of the function applied to the second item emitted by each of thosePublisher
s, and so forth.The resulting
Flowable
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of the sourcePublisher
that emits the fewest items.The operator subscribes to its sources in the order they are specified and completes eagerly if one of the sources is shorter than the rest while canceling the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling
doOnComplete()
). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will cancel B immediately. For example:zip(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 butaction2
won't.
To work around this termination property, usedoOnCancel(Action)
as well or useusing()
to do cleanup in case of completion or cancellation.- Backpressure:
- The operator expects backpressure from the sources and honors backpressure from the downstream.
(I.e., zipping with
interval(long, TimeUnit)
may result inMissingBackpressureException
, use one of theonBackpressureX
to handle similar, backpressure-ignoring sources. - Scheduler:
zip
does not operate by default on a particularScheduler
.
- Type Parameters:
T1
- the value type of the first sourceT2
- the value type of the second sourceT3
- the value type of the third sourceT4
- the value type of the fourth sourceT5
- the value type of the fifth sourceT6
- the value type of the sixth sourceT7
- the value type of the seventh sourceT8
- the value type of the eighth sourceT9
- the value type of the ninth sourceR
- the zipped result type- Parameters:
source1
- the first sourcePublisher
source2
- a second sourcePublisher
source3
- a third sourcePublisher
source4
- a fourth sourcePublisher
source5
- a fifth sourcePublisher
source6
- a sixth sourcePublisher
source7
- a seventh sourcePublisher
source8
- an eighth sourcePublisher
source9
- a ninth sourcePublisher
zipper
- a function that, when applied to an item emitted by each of the sourcePublisher
s, results in an item that will be emitted by the resultingFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
,source4
,source5
,source6
,source7
,source8
,source9
orzipper
isnull
- See Also:
- ReactiveX operators documentation: Zip
-
zipArray
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") @SafeVarargs public static <@NonNull T,@NonNull R> @NonNull Flowable<R> zipArray(@NonNull @NonNull Function<? super java.lang.Object[],? extends @NonNull R> zipper, boolean delayError, int bufferSize, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T>... sources)
Returns aFlowable
that emits the results of a specified combiner function applied to combinations of items emitted, in sequence, by an array of otherPublisher
s.zip
applies this function in strict sequence, so the first item emitted by the newPublisher
will be the result of the function applied to the first item emitted by each of the sourcePublisher
s; the second item emitted by the newPublisher
will be the result of the function applied to the second item emitted by each of thosePublisher
s; and so forth.The resulting
Flowable
returned fromzip
will invokeonNext
as many times as the number ofonNext
invocations of the sourcePublisher
that emits the fewest items.The operator subscribes to its sources in the order they are specified and completes eagerly if one of the sources is shorter than the rest while canceling the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling
doOnComplete()
). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will cancel B immediately. For example:zip(new Publisher[]{range(1, 5).doOnComplete(action1), range(6, 5).doOnComplete(action2)}, (a) -> a)
action1
will be called butaction2
won't.
To work around this termination property, usedoOnCancel(Action)
as well or useusing()
to do cleanup in case of completion or cancellation.- Backpressure:
- The operator expects backpressure from the sources and honors backpressure from the downstream.
(I.e., zipping with
interval(long, TimeUnit)
may result inMissingBackpressureException
, use one of theonBackpressureX
to handle similar, backpressure-ignoring sources. - Scheduler:
zipArray
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the common element typeR
- the result type- Parameters:
sources
- an array of sourcePublisher
szipper
- a function that, when applied to an item emitted by each of the sourcePublisher
s, results in an item that will be emitted by the resultingFlowable
delayError
- delay errors signaled by any of the sourcePublisher
until allPublisher
s terminatebufferSize
- the number of elements to prefetch from each sourcePublisher
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsources
orzipper
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Zip
-
all
@CheckReturnValue @NonNull @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") public final @NonNull Single<java.lang.Boolean> all(@NonNull @NonNull Predicate<? super @NonNull T> predicate)
Returns aSingle
that emits aBoolean
that indicates whether all of the items emitted by the currentFlowable
satisfy a condition.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., without applying backpressure). - Scheduler:
all
does not operate by default on a particularScheduler
.
- Parameters:
predicate
- a function that evaluates an item and returns aBoolean
- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifpredicate
isnull
- See Also:
- ReactiveX operators documentation: All
-
ambWith
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final @NonNull Flowable<T> ambWith(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> other)
Mirrors thePublisher
(current or provided) that first either emits an item or sends a termination notification.When the current
Flowable
signals an item or terminates first, the subscription to the otherPublisher
is canceled. If the otherPublisher
signals an item or terminates first, the subscription to the currentFlowable
is canceled.- Backpressure:
- The operator itself doesn't interfere with backpressure which is determined by the winning
Publisher
's backpressure behavior. - Scheduler:
ambWith
does not operate by default on a particularScheduler
.- Error handling:
-
If the losing
Publisher
signals an error, the error is routed to the global error handler viaRxJavaPlugins.onError(Throwable)
.
- Parameters:
other
- aPublisher
competing to react first. A subscription to this providedPublisher
will occur after subscribing to the currentFlowable
.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifother
isnull
- See Also:
- ReactiveX operators documentation: Amb
-
any
@CheckReturnValue @NonNull @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") public final @NonNull Single<java.lang.Boolean> any(@NonNull @NonNull Predicate<? super @NonNull T> predicate)
Returns aSingle
that emitstrue
if any item emitted by the currentFlowable
satisfies a specified condition, otherwisefalse
. Note: this always emitsfalse
if the currentFlowable
is empty.In Rx.Net this is the
any
operator but we renamed it in RxJava to better match Java naming idioms.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., no backpressure applied to it). - Scheduler:
any
does not operate by default on a particularScheduler
.
- Parameters:
predicate
- the condition to test items emitted by the currentFlowable
- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifpredicate
isnull
- See Also:
- ReactiveX operators documentation: Contains
-
blockingFirst
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final T blockingFirst()
Returns the first item emitted by thisFlowable
, or throwsNoSuchElementException
if it emits no items.- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner (i.e., no backpressure applied to it). - Scheduler:
blockingFirst
does not operate by default on a particularScheduler
.- Error handling:
- If the source signals an error, the operator wraps a checked
Exception
intoRuntimeException
and throws that. Otherwise,RuntimeException
s andError
s are rethrown as they are.
- Returns:
- the new
Flowable
instance - Throws:
java.util.NoSuchElementException
- if thisFlowable
emits no items- See Also:
- ReactiveX documentation: First
-
blockingFirst
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final T blockingFirst(@NonNull @NonNull T defaultItem)
Returns the first item emitted by thisFlowable
, or a default value if it emits no items.- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner (i.e., no backpressure applied to it). - Scheduler:
blockingFirst
does not operate by default on a particularScheduler
.- Error handling:
- If the source signals an error, the operator wraps a checked
Exception
intoRuntimeException
and throws that. Otherwise,RuntimeException
s andError
s are rethrown as they are.
- Parameters:
defaultItem
- a default value to return if thisFlowable
emits no items- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifdefaultItem
isnull
- See Also:
- ReactiveX documentation: First
-
blockingForEach
@BackpressureSupport(FULL) @SchedulerSupport("none") public final void blockingForEach(@NonNull @NonNull Consumer<? super @NonNull T> onNext)
Consumes the currentFlowable
in a blocking fashion and invokes the givenConsumer
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 whilesubscribe(Consumer)
executes the consumer on the original caller thread of the sequence.- Backpressure:
- The operator requests
bufferSize()
upfront, then 75% of this amount when 75% is received. - Scheduler:
blockingForEach
does not operate by default on a particularScheduler
.- Error handling:
- If the source signals an error, the operator wraps a checked
Exception
intoRuntimeException
and throws that. Otherwise,RuntimeException
s andError
s are rethrown as they are.
- Parameters:
onNext
- theConsumer
to invoke for each item emitted by theFlowable
- Throws:
java.lang.NullPointerException
- ifonNext
isnull
java.lang.RuntimeException
- if an error occurs;Error
s andRuntimeException
s are rethrown as they are, checkedException
s are wrapped intoRuntimeException
s- See Also:
- ReactiveX documentation: Subscribe,
subscribe(Consumer)
,blockingForEach(Consumer, int)
-
blockingForEach
@BackpressureSupport(FULL) @SchedulerSupport("none") public final void blockingForEach(@NonNull @NonNull Consumer<? super @NonNull T> onNext, int bufferSize)
Consumes the currentFlowable
in a blocking fashion and invokes the givenConsumer
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 whilesubscribe(Consumer)
executes the consumer on the original caller thread of the sequence.- Backpressure:
- The operator requests the given
prefetch
amount upfront, then 75% of this amount when 75% is received. - Scheduler:
blockingForEach
does not operate by default on a particularScheduler
.- Error handling:
- If the source signals an error, the operator wraps a checked
Exception
intoRuntimeException
and throws that. Otherwise,RuntimeException
s andError
s are rethrown as they are.
- Parameters:
onNext
- theConsumer
to invoke for each item emitted by theFlowable
bufferSize
- the number of items to prefetch upfront, then 75% of it after 75% received- Throws:
java.lang.NullPointerException
- ifonNext
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positivejava.lang.RuntimeException
- if an error occurs;Error
s andRuntimeException
s are rethrown as they are, checkedException
s are wrapped intoRuntimeException
s- See Also:
- ReactiveX documentation: Subscribe,
subscribe(Consumer)
-
blockingIterable
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull java.lang.Iterable<T> blockingIterable()
Converts thisFlowable
into anIterable
.- Backpressure:
- The operator expects the upstream to honor backpressure otherwise the returned
Iterable
's iterator will throw aMissingBackpressureException
. - Scheduler:
blockingIterable
does not operate by default on a particularScheduler
.
- Returns:
- the new
Iterable
instance - See Also:
- ReactiveX documentation: To
-
blockingIterable
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull java.lang.Iterable<T> blockingIterable(int bufferSize)
Converts thisFlowable
into anIterable
.- Backpressure:
- The operator expects the upstream to honor backpressure otherwise the returned
Iterable
's iterator will throw aMissingBackpressureException
. - Scheduler:
blockingIterable
does not operate by default on a particularScheduler
.
- Parameters:
bufferSize
- the number of items to prefetch from the currentFlowable
- Returns:
- the new
Iterable
instance - Throws:
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX documentation: To
-
blockingLast
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final T blockingLast()
Returns the last item emitted by thisFlowable
, or throwsNoSuchElementException
if thisFlowable
emits no items.- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner (i.e., no backpressure applied to it). - Scheduler:
blockingLast
does not operate by default on a particularScheduler
.- Error handling:
- If the source signals an error, the operator wraps a checked
Exception
intoRuntimeException
and throws that. Otherwise,RuntimeException
s andError
s are rethrown as they are.
- Returns:
- the new
Flowable
instance - Throws:
java.util.NoSuchElementException
- if thisFlowable
emits no items- See Also:
- ReactiveX documentation: Last
-
blockingLast
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final T blockingLast(@NonNull @NonNull T defaultItem)
Returns the last item emitted by thisFlowable
, or a default value if it emits no items.- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner (i.e., no backpressure applied to it). - Scheduler:
blockingLast
does not operate by default on a particularScheduler
.- Error handling:
- If the source signals an error, the operator wraps a checked
Exception
intoRuntimeException
and throws that. Otherwise,RuntimeException
s andError
s are rethrown as they are.
- Parameters:
defaultItem
- a default value to return if thisFlowable
emits no items- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifdefaultItem
isnull
- See Also:
- ReactiveX documentation: Last
-
blockingLatest
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final @NonNull java.lang.Iterable<T> blockingLatest()
Returns anIterable
that returns the latest item emitted by thisFlowable
, waiting if necessary for one to become available.If this
Flowable
produces items faster thanIterator.next
takes them,onNext
events might be skipped, butonError
oronComplete
events are not.Note also that an
onNext
directly followed byonComplete
might hide theonNext
event.- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner (i.e., no backpressure applied to it). - Scheduler:
blockingLatest
does not operate by default on a particularScheduler
.
- Returns:
- the new
Iterable
instance - See Also:
- ReactiveX documentation: First
-
blockingMostRecent
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final @NonNull java.lang.Iterable<T> blockingMostRecent(@NonNull @NonNull T initialItem)
Returns anIterable
that always returns the item most recently emitted by thisFlowable
.- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner (i.e., no backpressure applied to it). - Scheduler:
blockingMostRecent
does not operate by default on a particularScheduler
.
- Parameters:
initialItem
- the initial item that theIterable
sequence will yield if thisFlowable
has not yet emitted an item- Returns:
- the new
Iterable
instance - Throws:
java.lang.NullPointerException
- ifinitialItem
isnull
- See Also:
- ReactiveX documentation: First
-
blockingNext
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final @NonNull java.lang.Iterable<T> blockingNext()
Returns anIterable
that blocks until thisFlowable
emits another item, then returns that item.- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner (i.e., no backpressure applied to it). - Scheduler:
blockingNext
does not operate by default on a particularScheduler
.
- Returns:
- the new
Iterable
instance - See Also:
- ReactiveX documentation: TakeLast
-
blockingSingle
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final T blockingSingle()
If thisFlowable
completes after emitting a single item, return that item, otherwise throw aNoSuchElementException
.- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner (i.e., no backpressure applied to it). - Scheduler:
blockingSingle
does not operate by default on a particularScheduler
.- Error handling:
- If the source signals an error, the operator wraps a checked
Exception
intoRuntimeException
and throws that. Otherwise,RuntimeException
s andError
s are rethrown as they are.
- Returns:
- the new
Flowable
instance - See Also:
- ReactiveX documentation: First
-
blockingSingle
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final T blockingSingle(@NonNull @NonNull T defaultItem)
If thisFlowable
completes after emitting a single item, return that item; if it emits more than one item, throw anIllegalArgumentException
; if it emits no items, return a default value.- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner (i.e., no backpressure applied to it). - Scheduler:
blockingSingle
does not operate by default on a particularScheduler
.- Error handling:
- If the source signals an error, the operator wraps a checked
Exception
intoRuntimeException
and throws that. Otherwise,RuntimeException
s andError
s are rethrown as they are.
- Parameters:
defaultItem
- a default value to return if thisFlowable
emits no items- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifdefaultItem
isnull
- See Also:
- ReactiveX documentation: First
-
toFuture
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final @NonNull java.util.concurrent.Future<T> toFuture()
Returns aFuture
representing the only value emitted by thisFlowable
.If the
Flowable
emits more than one item,Future
will receive anIndexOutOfBoundsException
. If theFlowable
is empty,Future
will receive aNoSuchElementException
. TheFlowable
source has to terminate in order for the returnedFuture
to terminate as well.If the
Flowable
may emit more than one item, useFlowable.toList().toFuture()
.- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner (i.e., no backpressure applied to it). - Scheduler:
toFuture
does not operate by default on a particularScheduler
.
- Returns:
- the new
Future
instance - See Also:
- ReactiveX documentation: To
-
blockingSubscribe
@BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") public final void blockingSubscribe()
Runs the currentFlowable
to a terminal event, ignoring any values and rethrowing any exception.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.
- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner (i.e., no backpressure applied to it). - Scheduler:
blockingSubscribe
does not operate by default on a particularScheduler
.
-
blockingSubscribe
@BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") public final void blockingSubscribe(@NonNull @NonNull Consumer<? super @NonNull T> onNext)
Subscribes to the source and calls the given callbacks on the current thread.If the
Flowable
emits an error, it is wrapped into anOnErrorNotImplementedException
and routed to theRxJavaPlugins.onError(Throwable)
handler. Using the overloadsblockingSubscribe(Consumer, Consumer)
orblockingSubscribe(Consumer, Consumer, Action)
instead is recommended.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.
- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner (i.e., no backpressure applied to it). - Scheduler:
blockingSubscribe
does not operate by default on a particularScheduler
.
- Parameters:
onNext
- the callback action for each source value- Throws:
java.lang.NullPointerException
- ifonNext
isnull
- Since:
- 2.0
- See Also:
blockingSubscribe(Consumer, Consumer)
,blockingSubscribe(Consumer, Consumer, Action)
-
blockingSubscribe
@BackpressureSupport(FULL) @SchedulerSupport("none") public final void blockingSubscribe(@NonNull @NonNull Consumer<? super @NonNull T> onNext, int bufferSize)
Subscribes to the source and calls the given callbacks on the current thread.If the
Flowable
emits an error, it is wrapped into anOnErrorNotImplementedException
and routed to theRxJavaPlugins.onError(Throwable)
handler. Using the overloadsblockingSubscribe(Consumer, Consumer)
orblockingSubscribe(Consumer, Consumer, Action)
instead is recommended.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.
- Backpressure:
- The operator consumes the current
Flowable
in an bounded manner (up to bufferSize outstanding request amount for items). - Scheduler:
blockingSubscribe
does not operate by default on a particularScheduler
.
History: 2.1.15 - experimental
- Parameters:
onNext
- the callback action for each source valuebufferSize
- the size of the buffer- Throws:
java.lang.NullPointerException
- ifonNext
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- Since:
- 2.2
- See Also:
blockingSubscribe(Consumer, Consumer)
,blockingSubscribe(Consumer, Consumer, Action)
-
blockingSubscribe
@BackpressureSupport(UNBOUNDED_IN) @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.
- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner (i.e., no backpressure applied to it). - Scheduler:
blockingSubscribe
does not operate by default on a particularScheduler
.
- Parameters:
onNext
- the callback action for each source valueonError
- the callback action for an error event- Throws:
java.lang.NullPointerException
- ifonNext
oronError
isnull
- Since:
- 2.0
- See Also:
blockingSubscribe(Consumer, Consumer, Action)
-
blockingSubscribe
@BackpressureSupport(FULL) @SchedulerSupport("none") public final void blockingSubscribe(@NonNull @NonNull Consumer<? super @NonNull T> onNext, @NonNull @NonNull Consumer<? super java.lang.Throwable> onError, int bufferSize)
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.
- Backpressure:
- The operator consumes the current
Flowable
in an bounded manner (up to bufferSize outstanding request amount for items). - Scheduler:
blockingSubscribe
does not operate by default on a particularScheduler
.
History: 2.1.15 - experimental
- Parameters:
onNext
- the callback action for each source valueonError
- the callback action for an error eventbufferSize
- the size of the buffer- Throws:
java.lang.NullPointerException
- ifonNext
oronError
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- Since:
- 2.2
- See Also:
blockingSubscribe(Consumer, Consumer, Action)
-
blockingSubscribe
@BackpressureSupport(UNBOUNDED_IN) @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.
- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner (i.e., no backpressure applied to it). - Scheduler:
blockingSubscribe
does not operate by default on a particularScheduler
.
- Parameters:
onNext
- the callback action for each source valueonError
- the callback action for an error eventonComplete
- the callback action for the completion event.- Throws:
java.lang.NullPointerException
- ifonNext
,onError
oronComplete
isnull
- Since:
- 2.0
-
blockingSubscribe
@BackpressureSupport(FULL) @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, int bufferSize)
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.
- Backpressure:
- The operator consumes the current
Flowable
in an bounded manner (up to bufferSize outstanding request amount for items). - Scheduler:
blockingSubscribe
does not operate by default on a particularScheduler
.
History: 2.1.15 - experimental
- Parameters:
onNext
- the callback action for each source valueonError
- the callback action for an error eventonComplete
- the callback action for the completion event.bufferSize
- the size of the buffer- Throws:
java.lang.NullPointerException
- ifonNext
,onError
oronComplete
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- Since:
- 2.2
-
blockingSubscribe
@BackpressureSupport(SPECIAL) @SchedulerSupport("none") public final void blockingSubscribe(@NonNull @NonNull org.reactivestreams.Subscriber<? super @NonNull T> subscriber)
Subscribes to the source and calls theSubscriber
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
Subscriber
cancels theSubscription
it receives viaSubscriber.onSubscribe(Subscription)
. Therefore, calling this method from special threads such as the Android Main Thread or the Swing Event Dispatch Thread is not recommended.- Backpressure:
- The supplied
Subscriber
determines how backpressure is applied. - Scheduler:
blockingSubscribe
does not operate by default on a particularScheduler
.
- Parameters:
subscriber
- the subscriber to forward events and calls to in the current thread- Throws:
java.lang.NullPointerException
- ifsubscriber
isnull
- Since:
- 2.0
-
buffer
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<java.util.List<T>> buffer(int count)
Returns aFlowable
that emits buffers of items it collects from the currentFlowable
. The resultingFlowable
emits connected, non-overlapping buffers, each containingcount
items. When the currentFlowable
completes, the resultingFlowable
emits the current buffer and propagates the notification from the currentFlowable
. Note that if the currentFlowable
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.- Backpressure:
- The operator honors backpressure from downstream and expects the current
Flowable
to honor it as well, although not enforced; violation may lead toMissingBackpressureException
somewhere downstream. - Scheduler:
- This version of
buffer
does not operate by default on a particularScheduler
.
- Parameters:
count
- the maximum number of items in each buffer before it should be emitted- Returns:
- the new
Flowable
instance - Throws:
java.lang.IllegalArgumentException
- ifcount
is non-positive- See Also:
- ReactiveX operators documentation: Buffer
-
buffer
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<java.util.List<T>> buffer(int count, int skip)
Returns aFlowable
that emits buffers of items it collects from the currentFlowable
. The resultingFlowable
emits buffers everyskip
items, each containingcount
items. When the currentFlowable
completes, the resultingFlowable
emits the current buffer and propagates the notification from the currentFlowable
. Note that if the currentFlowable
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.- Backpressure:
- The operator honors backpressure from downstream and expects the current
Flowable
to honor it as well, although not enforced; violation may lead toMissingBackpressureException
somewhere downstream. - Scheduler:
- This version of
buffer
does not operate by default on a particularScheduler
.
- Parameters:
count
- the maximum size of each buffer before it should be emittedskip
- how many items emitted by the currentFlowable
should be skipped before starting a new buffer. Note that whenskip
andcount
are equal, this is the same operation asbuffer(int)
.- Returns:
- the new
Flowable
instance - Throws:
java.lang.IllegalArgumentException
- ifcount
orskip
is non-positive- See Also:
- ReactiveX operators documentation: Buffer
-
buffer
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final <@NonNull U extends java.util.Collection<? super @NonNull T>> @NonNull Flowable<U> buffer(int count, int skip, @NonNull @NonNull Supplier<@NonNull U> bufferSupplier)
Returns aFlowable
that emits buffers of items it collects from the currentFlowable
. The resultingFlowable
emits buffers everyskip
items, each containingcount
items. When the currentFlowable
completes, the resultingFlowable
emits the current buffer and propagates the notification from the currentFlowable
. Note that if the currentFlowable
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.- Backpressure:
- The operator honors backpressure from downstream and expects the current
Flowable
to honor it as well, although not enforced; violation may lead toMissingBackpressureException
somewhere downstream. - Scheduler:
- This version of
buffer
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the collection subclass type to buffer into- Parameters:
count
- the maximum size of each buffer before it should be emittedskip
- how many items emitted by the currentFlowable
should be skipped before starting a new buffer. Note that whenskip
andcount
are equal, this is the same operation asbuffer(int)
.bufferSupplier
- a factory function that returns an instance of the collection subclass to be used and returned as the buffer- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifbufferSupplier
isnull
java.lang.IllegalArgumentException
- ifcount
orskip
is non-positive- See Also:
- ReactiveX operators documentation: Buffer
-
buffer
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull U extends java.util.Collection<? super @NonNull T>> @NonNull Flowable<U> buffer(int count, @NonNull @NonNull Supplier<@NonNull U> bufferSupplier)
Returns aFlowable
that emits buffers of items it collects from the currentFlowable
. The resultingFlowable
emits connected, non-overlapping buffers, each containingcount
items. When the currentFlowable
completes, the resultingFlowable
emits the current buffer and propagates the notification from the currentFlowable
. Note that if the currentFlowable
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.- Backpressure:
- The operator honors backpressure from downstream and expects the current
Flowable
to honor it as well, although not enforced; violation may lead toMissingBackpressureException
somewhere downstream. - Scheduler:
- This version of
buffer
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the collection subclass type to buffer into- Parameters:
count
- the maximum number of items in each buffer before it should be emittedbufferSupplier
- a factory function that returns an instance of the collection subclass to be used and returned as the buffer- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifbufferSupplier
isnull
java.lang.IllegalArgumentException
- ifcount
is non-positive- See Also:
- ReactiveX operators documentation: Buffer
-
buffer
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Flowable<java.util.List<T>> buffer(long timespan, long timeskip, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits buffers of items it collects from the currentFlowable
. The resultingFlowable
starts a new buffer periodically, as determined by thetimeskip
argument. It emits each buffer after a fixed timespan, specified by thetimespan
argument. When the currentFlowable
completes, the resultingFlowable
emits the current buffer and propagates the notification from the currentFlowable
. Note that if the currentFlowable
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.- Backpressure:
- This operator does not support backpressure as it uses time. It requests
Long.MAX_VALUE
upstream and does not obey downstream requests. - Scheduler:
- This version of
buffer
operates by default on thecomputation
Scheduler
.
- Parameters:
timespan
- the period of time each buffer collects items before it is emittedtimeskip
- the period of time after which a new buffer will be createdunit
- the unit of time that applies to thetimespan
andtimeskip
arguments- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Buffer
-
buffer
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("custom") @NonNull public final @NonNull Flowable<java.util.List<T>> buffer(long timespan, long timeskip, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns aFlowable
that emits buffers of items it collects from the currentFlowable
. The resultingFlowable
starts a new buffer periodically, as determined by thetimeskip
argument, and on the specifiedscheduler
. It emits each buffer after a fixed timespan, specified by thetimespan
argument. When the currentFlowable
completes, the resultingFlowable
emits the current buffer and propagates the notification from the currentFlowable
. Note that if the currentFlowable
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.- Backpressure:
- This operator does not support backpressure as it uses time. It requests
Long.MAX_VALUE
upstream and does not obey downstream requests. - Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
timespan
- the period of time each buffer collects items before it is emittedtimeskip
- the period of time after which a new buffer will be createdunit
- the unit of time that applies to thetimespan
andtimeskip
argumentsscheduler
- theScheduler
to use when determining the end and start of a buffer- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Buffer
-
buffer
@CheckReturnValue @NonNull @BackpressureSupport(ERROR) @SchedulerSupport("custom") public final <@NonNull U extends java.util.Collection<? super @NonNull T>> @NonNull Flowable<U> buffer(long timespan, long timeskip, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, @NonNull @NonNull Supplier<@NonNull U> bufferSupplier)
Returns aFlowable
that emits buffers of items it collects from the currentFlowable
. The resultingFlowable
starts a new buffer periodically, as determined by thetimeskip
argument, and on the specifiedscheduler
. It emits each buffer after a fixed timespan, specified by thetimespan
argument. When the currentFlowable
completes, the resultingFlowable
emits the current buffer and propagates the notification from the currentFlowable
. Note that if the currentFlowable
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.- Backpressure:
- This operator does not support backpressure as it uses time. It requests
Long.MAX_VALUE
upstream and does not obey downstream requests. - 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 emittedtimeskip
- the period of time after which a new buffer will be createdunit
- the unit of time that applies to thetimespan
andtimeskip
argumentsscheduler
- theScheduler
to use when determining the end and start of a bufferbufferSupplier
- a factory function that returns an instance of the collection subclass to be used and returned as the buffer- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
,scheduler
orbufferSupplier
isnull
- See Also:
- ReactiveX operators documentation: Buffer
-
buffer
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Flowable<java.util.List<T>> buffer(long timespan, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits buffers of items it collects from the currentFlowable
. The resultingFlowable
emits connected, non-overlapping buffers, each of a fixed duration specified by thetimespan
argument. When the currentFlowable
completes, the resultingFlowable
emits the current buffer and propagates the notification from the currentFlowable
. Note that if the currentFlowable
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.- Backpressure:
- This operator does not support backpressure as it uses time. It requests
Long.MAX_VALUE
upstream and does not obey downstream requests. - Scheduler:
- This version of
buffer
operates by default on thecomputation
Scheduler
.
- Parameters:
timespan
- the period of time each buffer collects items before it is emitted and replaced with a new bufferunit
- the unit of time that applies to thetimespan
argument- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Buffer
-
buffer
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Flowable<java.util.List<T>> buffer(long timespan, @NonNull @NonNull java.util.concurrent.TimeUnit unit, int count)
Returns aFlowable
that emits buffers of items it collects from the currentFlowable
. The resultingFlowable
emits connected, non-overlapping buffers, each of a fixed duration specified by thetimespan
argument or a maximum size specified by thecount
argument (whichever is reached first). When the currentFlowable
completes, the resultingFlowable
emits the current buffer and propagates the notification from the currentFlowable
. Note that if the currentFlowable
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.- Backpressure:
- This operator does not support backpressure as it uses time. It requests
Long.MAX_VALUE
upstream and does not obey downstream requests. - Scheduler:
- This version of
buffer
operates by default on thecomputation
Scheduler
.
- Parameters:
timespan
- the period of time each buffer collects items before it is emitted and replaced with a new bufferunit
- the unit of time which applies to thetimespan
argumentcount
- the maximum size of each buffer before it is emitted- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
java.lang.IllegalArgumentException
- ifcount
is non-positive- See Also:
- ReactiveX operators documentation: Buffer
-
buffer
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("custom") @NonNull public final @NonNull Flowable<java.util.List<T>> buffer(long timespan, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, int count)
Returns aFlowable
that emits buffers of items it collects from the currentFlowable
. The resultingFlowable
emits connected, non-overlapping buffers, each of a fixed duration specified by thetimespan
argument as measured on the specifiedscheduler
, or a maximum size specified by thecount
argument (whichever is reached first). When the currentFlowable
completes, the resultingFlowable
emits the current buffer and propagates the notification from the currentFlowable
. Note that if the currentFlowable
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.- Backpressure:
- This operator does not support backpressure as it uses time. It requests
Long.MAX_VALUE
upstream and does not obey downstream requests. - 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 bufferunit
- the unit of time which applies to thetimespan
argumentscheduler
- theScheduler
to use when determining the end and start of a buffercount
- the maximum size of each buffer before it is emitted- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
java.lang.IllegalArgumentException
- ifcount
is non-positive- See Also:
- ReactiveX operators documentation: Buffer
-
buffer
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("custom") @NonNull public final <@NonNull U extends java.util.Collection<? super @NonNull T>> @NonNull Flowable<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 aFlowable
that emits buffers of items it collects from the currentFlowable
. The resultingFlowable
emits connected, non-overlapping buffers, each of a fixed duration specified by thetimespan
argument as measured on the specifiedscheduler
, or a maximum size specified by thecount
argument (whichever is reached first). When the currentFlowable
completes, the resultingFlowable
emits the current buffer and propagates the notification from the currentFlowable
. Note that if the currentFlowable
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.- Backpressure:
- This operator does not support backpressure as it uses time. It requests
Long.MAX_VALUE
upstream and does not obey downstream requests. - 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 bufferunit
- the unit of time which applies to thetimespan
argumentscheduler
- theScheduler
to use when determining the end and start of a buffercount
- the maximum size of each buffer before it is emittedbufferSupplier
- a factory function that returns an instance of the collection subclass to be used and returned as the bufferrestartTimerOnMaxSize
- iftrue
, the time window is restarted when the max capacity of the current buffer is reached- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
,scheduler
orbufferSupplier
isnull
java.lang.IllegalArgumentException
- ifcount
is non-positive- See Also:
- ReactiveX operators documentation: Buffer
-
buffer
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("custom") @NonNull public final @NonNull Flowable<java.util.List<T>> buffer(long timespan, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns aFlowable
that emits buffers of items it collects from the currentFlowable
. The resultingFlowable
emits connected, non-overlapping buffers, each of a fixed duration specified by thetimespan
argument and on the specifiedscheduler
. When the currentFlowable
completes, the resultingFlowable
emits the current buffer and propagates the notification from the currentFlowable
. Note that if the currentFlowable
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.- Backpressure:
- This operator does not support backpressure as it uses time. It requests
Long.MAX_VALUE
upstream and does not obey downstream requests. - 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 bufferunit
- the unit of time which applies to thetimespan
argumentscheduler
- theScheduler
to use when determining the end and start of a buffer- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Buffer
-
buffer
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("none") @NonNull public final <@NonNull TOpening,@NonNull TClosing> @NonNull Flowable<java.util.List<T>> buffer(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull TOpening> openingIndicator, @NonNull @NonNull Function<? super @NonNull TOpening,? extends org.reactivestreams.Publisher<? extends @NonNull TClosing>> closingIndicator)
Returns aFlowable
that emits buffers of items it collects from the currentFlowable
. The resultingFlowable
emits buffers that it creates when the specifiedopeningIndicator
Publisher
emits an item, and closes when thePublisher
returned fromclosingIndicator
emits an item. If any of the currentPFlowable
,openingIndicator
orclosingIndicator
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.- Backpressure:
- This operator does not support backpressure as it is instead controlled by the given
Publisher
s and buffers data. It requestsLong.MAX_VALUE
upstream and does not obey downstream requests. - Scheduler:
- This version of
buffer
does not operate by default on a particularScheduler
.
- Type Parameters:
TOpening
- the element type of the buffer-openingPublisher
TClosing
- the element type of the individual buffer-closingPublisher
s- Parameters:
openingIndicator
- thePublisher
that, when it emits an item, causes a new buffer to be createdclosingIndicator
- theFunction
that is used to produce aPublisher
for every buffer created. When thisPublisher
emits an item, the associated buffer is emitted.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifopeningIndicator
orclosingIndicator
isnull
- See Also:
- ReactiveX operators documentation: Buffer
-
buffer
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("none") @NonNull public final <@NonNull TOpening,@NonNull TClosing,@NonNull U extends java.util.Collection<? super @NonNull T>> @NonNull Flowable<U> buffer(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull TOpening> openingIndicator, @NonNull @NonNull Function<? super @NonNull TOpening,? extends org.reactivestreams.Publisher<? extends @NonNull TClosing>> closingIndicator, @NonNull @NonNull Supplier<@NonNull U> bufferSupplier)
Returns aFlowable
that emits buffers of items it collects from the currentFlowable
. The resultingFlowable
emits buffers that it creates when the specifiedopeningIndicator
Publisher
emits an item, and closes when thePublisher
returned fromclosingIndicator
emits an item. If any of the currentFlowable
,openingIndicator
orclosingIndicator
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.- Backpressure:
- This operator does not support backpressure as it is instead controlled by the given
Publisher
s and buffers data. It requestsLong.MAX_VALUE
upstream and does not obey downstream requests. - Scheduler:
- This version of
buffer
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the collection subclass type to buffer intoTOpening
- the element type of the buffer-openingPublisher
TClosing
- the element type of the individual buffer-closingPublisher
s- Parameters:
openingIndicator
- thePublisher
that, when it emits an item, causes a new buffer to be createdclosingIndicator
- theFunction
that is used to produce aPublisher
for every buffer created. When thisPublisher
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
Flowable
instance - Throws:
java.lang.NullPointerException
- ifopeningIndicator
,closingIndicator
orbufferSupplier
isnull
- See Also:
- ReactiveX operators documentation: Buffer
-
buffer
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("none") @NonNull public final <@NonNull B> @NonNull Flowable<java.util.List<T>> buffer(@NonNull @NonNull org.reactivestreams.Publisher<@NonNull B> boundaryIndicator)
Returns aFlowable
that emits non-overlapping buffered items from the currentFlowable
each time the specified boundaryPublisher
emits an item.Completion of either the source or the boundary
Publisher
causes the returnedPublisher
to emit the latest buffer and complete. If either the currentFlowable
or the boundaryPublisher
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.- Backpressure:
- This operator does not support backpressure as it is instead controlled by the
Publisher
boundary
and buffers data. It requestsLong.MAX_VALUE
upstream and does not obey downstream requests. - Scheduler:
- This version of
buffer
does not operate by default on a particularScheduler
.
- Type Parameters:
B
- the boundary value type (ignored)- Parameters:
boundaryIndicator
- the boundaryPublisher
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifboundaryIndicator
isnull
- See Also:
buffer(Publisher, int)
, ReactiveX operators documentation: Buffer
-
buffer
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("none") @NonNull public final <@NonNull B> @NonNull Flowable<java.util.List<T>> buffer(@NonNull @NonNull org.reactivestreams.Publisher<@NonNull B> boundaryIndicator, int initialCapacity)
Returns aFlowable
that emits non-overlapping buffered items from the currentFlowable
each time the specified boundaryPublisher
emits an item.Completion of either the source or the boundary
Publisher
causes the returnedPublisher
to emit the latest buffer and complete. If either the currentFlowable
or the boundaryPublisher
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.- Backpressure:
- This operator does not support backpressure as it is instead controlled by the
Publisher
boundary
and buffers data. It requestsLong.MAX_VALUE
upstream and does not obey downstream requests. - Scheduler:
- This version of
buffer
does not operate by default on a particularScheduler
.
- Type Parameters:
B
- the boundary value type (ignored)- Parameters:
boundaryIndicator
- the boundaryPublisher
initialCapacity
- the initial capacity of each buffer chunk- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifboundaryIndicator
isnull
java.lang.IllegalArgumentException
- ifinitialCapacity
is non-positive- See Also:
- ReactiveX operators documentation: Buffer,
buffer(Publisher)
-
buffer
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("none") @NonNull public final <@NonNull B,@NonNull U extends java.util.Collection<? super @NonNull T>> @NonNull Flowable<U> buffer(@NonNull @NonNull org.reactivestreams.Publisher<@NonNull B> boundaryIndicator, @NonNull @NonNull Supplier<@NonNull U> bufferSupplier)
Returns aFlowable
that emits non-overlapping buffered items from the currentFlowable
each time the specified boundaryPublisher
emits an item.Completion of either the source or the boundary
Publisher
causes the returnedPublisher
to emit the latest buffer and complete. If either the currentFlowable
or the boundaryPublisher
issues anonError
notification the event is passed on immediately without first emitting the buffer it is in the process of assembling.- Backpressure:
- This operator does not support backpressure as it is instead controlled by the
Publisher
boundary
and buffers data. It requestsLong.MAX_VALUE
upstream and does not obey downstream requests. - Scheduler:
- This version of
buffer
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the collection subclass type to buffer intoB
- the boundary value type (ignored)- Parameters:
boundaryIndicator
- the boundaryPublisher
bufferSupplier
- a factory function that returns an instance of the collection subclass to be used and returned as the buffer- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifboundaryIndicator
orbufferSupplier
isnull
- See Also:
buffer(Publisher, int)
, ReactiveX operators documentation: Buffer
-
cache
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> cache()
Returns aFlowable
that subscribes to thisPublisher
lazily, caches all of its events and replays them, in the same order as received, to all the downstream subscribers.This is useful when you want a
Publisher
to cache responses and you can't control the subscribe/cancel behavior of all theSubscriber
s.The operator subscribes only when the first downstream subscriber subscribes and maintains a single subscription towards this
Publisher
. In contrast, the operator family ofreplay()
that return aConnectableFlowable
require an explicit call toConnectableFlowable.connect()
.Note: You sacrifice the ability to cancel the origin when you use the
cache
operator so be careful not to use this operator onPublisher
s that emit an infinite or very large number of items that will use up memory. A possible workaround is to applytakeUntil(Publisher)
with a predicate or another source before (and perhaps after) the application ofcache()
.
Since the operator doesn't allow clearing the cached values either, the possible workaround is to forget all references to it viaAtomicBoolean shouldStop = new AtomicBoolean(); source.takeUntil(v -> shouldStop.get()) .cache() .takeUntil(v -> shouldStop.get()) .subscribe(...);
onTerminateDetach()
applied along with the previous workaround:AtomicBoolean shouldStop = new AtomicBoolean(); source.takeUntil(v -> shouldStop.get()) .onTerminateDetach() .cache() .takeUntil(v -> shouldStop.get()) .onTerminateDetach() .subscribe(...);
- Backpressure:
- The operator consumes this
Publisher
in an unbounded fashion but respects the backpressure of each downstreamSubscriber
individually. - Scheduler:
cache
does not operate by default on a particularScheduler
.
- Returns:
- the new
Flowable
instance - See Also:
- ReactiveX operators documentation: Replay,
takeUntil(Predicate)
,takeUntil(Publisher)
-
cacheWithInitialCapacity
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> cacheWithInitialCapacity(int initialCapacity)
Returns aFlowable
that subscribes to thisPublisher
lazily, caches all of its events and replays them, in the same order as received, to all the downstream subscribers.This is useful when you want a
Publisher
to cache responses and you can't control the subscribe/cancel behavior of all theSubscriber
s.The operator subscribes only when the first downstream subscriber subscribes and maintains a single subscription towards this
Publisher
. In contrast, the operator family ofreplay()
that return aConnectableFlowable
require an explicit call toConnectableFlowable.connect()
.Note: You sacrifice the ability to cancel the origin when you use the
cache
operator so be careful not to use this operator onPublisher
s that emit an infinite or very large number of items that will use up memory. A possible workaround is to applytakeUntil(Publisher)
with a predicate or another source before (and perhaps after) the application ofcacheWithInitialCapacity()
.
Since the operator doesn't allow clearing the cached values either, the possible workaround is to forget all references to it viaAtomicBoolean shouldStop = new AtomicBoolean(); source.takeUntil(v -> shouldStop.get()) .cache() .takeUntil(v -> shouldStop.get()) .subscribe(...);
onTerminateDetach()
applied along with the previous workaround:AtomicBoolean shouldStop = new AtomicBoolean(); source.takeUntil(v -> shouldStop.get()) .onTerminateDetach() .cache() .takeUntil(v -> shouldStop.get()) .onTerminateDetach() .subscribe(...);
- Backpressure:
- The operator consumes this
Publisher
in an unbounded fashion but respects the backpressure of each downstreamSubscriber
individually. - Scheduler:
cacheWithInitialCapacity
does not operate by default on a particularScheduler
.
Note: The capacity hint is not an upper bound on cache size. For that, consider
replay(int)
in combination withConnectableFlowable.autoConnect()
or similar.- Parameters:
initialCapacity
- hint for number of items to cache (for optimizing underlying data structure)- Returns:
- the new
Flowable
instance - Throws:
java.lang.IllegalArgumentException
- ifinitialCapacity
is non-positive- See Also:
- ReactiveX operators documentation: Replay,
takeUntil(Predicate)
,takeUntil(Publisher)
-
cast
@CheckReturnValue @NonNull @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") public final <@NonNull U> @NonNull Flowable<U> cast(@NonNull @NonNull java.lang.Class<@NonNull U> clazz)
Returns aFlowable
that emits the upstream items while they can be cast viaClass.cast(Object)
until the upstream terminates, or until the upstream signals an item which can't be cast, resulting in aClassCastException
to be signaled to the downstream.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
cast
does not operate by default on a particularScheduler
.
- 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
Flowable
instance - Throws:
java.lang.NullPointerException
- ifclazz
isnull
- See Also:
- ReactiveX operators documentation: Map
-
collect
@CheckReturnValue @NonNull @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") 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 sourcePublisher
into a single mutable data structure and returns aSingle
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 fatalOutOfMemoryError
.- Backpressure:
- This operator does not support backpressure because by intent it will receive all values and reduce
them to a single
onNext
. - Scheduler:
collect
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the accumulator and output type- Parameters:
initialItemSupplier
- the mutable data structure that will collect the itemscollector
- a function that accepts thestate
and an emitted item, and modifiesstate
accordingly- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifinitialItemSupplier
orcollector
isnull
- See Also:
- ReactiveX operators documentation: Reduce,
collect(Collector)
-
collectInto
@CheckReturnValue @NonNull @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") public final <@NonNull U> @NonNull Single<U> collectInto(@NonNull U initialItem, @NonNull @NonNull BiConsumer<? super @NonNull U,? super @NonNull T> collector)
Collects items emitted by the finite sourcePublisher
into a single mutable data structure and returns aSingle
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 fatalOutOfMemoryError
.- Backpressure:
- This operator does not support backpressure because by intent it will receive all values and reduce
them to a single
onNext
. - Scheduler:
collectInto
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the accumulator and output type- Parameters:
initialItem
- the mutable data structure that will collect the itemscollector
- a function that accepts thestate
and an emitted item, and modifiesstate
accordingly- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifinitialItem
orcollector
isnull
- See Also:
- ReactiveX operators documentation: Reduce
-
compose
@CheckReturnValue @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Flowable<R> compose(@NonNull @NonNull FlowableTransformer<? super @NonNull T,? extends @NonNull R> composer)
Transform the currentFlowable
by applying a particularFlowableTransformer
function to it.This method operates on the
Flowable
itself whereaslift(io.reactivex.rxjava3.core.FlowableOperator<? extends R, ? super T>)
operates on theFlowable
'sSubscriber
s.If the operator you are creating is designed to act on the individual items emitted by a current
Flowable
, uselift(io.reactivex.rxjava3.core.FlowableOperator<? extends R, ? super T>)
. If your operator is designed to transform the currentFlowable
as a whole (for instance, by applying a particular set of existing RxJava operators to it) usecompose
.- Backpressure:
- The operator itself doesn't interfere with the backpressure behavior which only depends
on what kind of
Publisher
theFlowableTransformer
returns. - Scheduler:
compose
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the value type of the outputPublisher
- Parameters:
composer
- implements the function that transforms the currentFlowable
- Returns:
- the new composed
Flowable
instance - Throws:
java.lang.NullPointerException
- ifcomposer
isnull
- See Also:
- RxJava wiki: Implementing Your Own Operators
-
concatMap
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Flowable<R> concatMap(@NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper)
Returns a newFlowable
that emits items resulting from applying a function that you supply to each item emitted by the currentFlowable
, where that function returns aPublisher
, and then emitting the items that result from concatenating those returnedPublisher
s.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 themapper
function is confined to a known thread, use theconcatMap(Function, int, Scheduler)
overload.- Backpressure:
- The operator honors backpressure from downstream. Both this and the inner
Publisher
s are expected to honor backpressure as well. If the currentFlowable
violates the rule, the operator will signal aMissingBackpressureException
. If any of the innerPublisher
s doesn't honor backpressure, that may throw anIllegalStateException
when thatPublisher
completes. - Scheduler:
concatMap
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the type of the innerPublisher
sources and thus the output type- Parameters:
mapper
- a function that, when applied to an item emitted by the currentFlowable
, returns aPublisher
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- See Also:
- ReactiveX operators documentation: FlatMap
-
concatMap
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final <@NonNull R> @NonNull Flowable<R> concatMap(@NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper, int prefetch)
Returns a newFlowable
that emits items resulting from applying a function that you supply to each item emitted by the currentFlowable
, where that function returns aPublisher
, and then emitting the items that result from concatenating those returnedPublisher
s.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 themapper
function is confined to a known thread, use theconcatMap(Function, int, Scheduler)
overload.- Backpressure:
- The operator honors backpressure from downstream. Both this and the inner
Publisher
s are expected to honor backpressure as well. If the currentFlowable
violates the rule, the operator will signal aMissingBackpressureException
. If any of the innerPublisher
s doesn't honor backpressure, that may throw anIllegalStateException
when thatPublisher
completes. - Scheduler:
concatMap
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the type of the innerPublisher
sources and thus the output type- Parameters:
mapper
- a function that, when applied to an item emitted by the currentFlowable
, returns aPublisher
prefetch
- the number of elements to prefetch from the currentFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifprefetch
is non-positive- See Also:
- ReactiveX operators documentation: FlatMap,
concatMap(Function, int, Scheduler)
-
concatMap
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("custom") public final <@NonNull R> @NonNull Flowable<R> concatMap(@NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper, int prefetch, @NonNull @NonNull Scheduler scheduler)
Returns a newFlowable
that emits items resulting from applying a function (on a designated scheduler) that you supply to each item emitted by the currentFlowable
, where that function returns aPublisher
, and then emitting the items that result from concatenating those returnedPublisher
s.The difference between
concatMap(Function, int)
and this operator is that this operator guarantees themapper
function is executed on the specified scheduler.- Backpressure:
- The operator honors backpressure from downstream. Both this and the inner
Publisher
s are expected to honor backpressure as well. If the currentFlowable
violates the rule, the operator will signal aMissingBackpressureException
. If any of the innerPublisher
s doesn't honor backpressure, that may throw anIllegalStateException
when thatPublisher
completes. - Scheduler:
concatMap
executes the givenmapper
function on the providedScheduler
.
- Type Parameters:
R
- the type of the innerPublisher
sources and thus the output type- Parameters:
mapper
- a function that, when applied to an item emitted by the currentFlowable
, returns aPublisher
prefetch
- the number of elements to prefetch from the currentFlowable
scheduler
- the scheduler where themapper
function will be executed- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
orscheduler
isnull
java.lang.IllegalArgumentException
- ifprefetch
is non-positive- Since:
- 3.0.0
- See Also:
- ReactiveX operators documentation: FlatMap,
concatMap(Function, int)
,concatMapDelayError(Function, boolean, int, Scheduler)
-
concatMapCompletable
@CheckReturnValue @SchedulerSupport("none") @BackpressureSupport(FULL) @NonNull public final @NonNull Completable concatMapCompletable(@NonNull @NonNull Function<? super @NonNull T,? extends CompletableSource> mapper)
Maps the upstream items intoCompletableSource
s and subscribes to them one after the other completes.- Backpressure:
- The operator expects the upstream to support backpressure. If this
Flowable
violates the rule, the operator will signal aMissingBackpressureException
. - Scheduler:
concatMapCompletable
does not operate by default on a particularScheduler
.
History: 2.1.11 - experimental
- Parameters:
mapper
- the function called with the upstream item and should return aCompletableSource
to become the next source to be subscribed to- Returns:
- the new
Completable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.2
- See Also:
concatMapCompletableDelayError(Function)
-
concatMapCompletable
@CheckReturnValue @NonNull @SchedulerSupport("none") @BackpressureSupport(FULL) public final @NonNull Completable concatMapCompletable(@NonNull @NonNull Function<? super @NonNull T,? extends CompletableSource> mapper, int prefetch)
Maps the upstream items intoCompletableSource
s and subscribes to them one after the other completes.- Backpressure:
- The operator expects the upstream to support backpressure. If this
Flowable
violates the rule, the operator will signal aMissingBackpressureException
. - Scheduler:
concatMapCompletable
does not operate by default on a particularScheduler
.
History: 2.1.11 - experimental
- Parameters:
mapper
- the function called with the upstream item and should return aCompletableSource
to become the next source to be subscribed toprefetch
- The number of upstream items to prefetch so that fresh items are ready to be mapped when a previousCompletableSource
terminates. The operator replenishes after half of the prefetch amount has been consumed and turned intoCompletableSource
s.- Returns:
- the new
Completable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifprefetch
is non-positive- Since:
- 2.2
- See Also:
concatMapCompletableDelayError(Function, boolean, int)
-
concatMapCompletableDelayError
@CheckReturnValue @SchedulerSupport("none") @BackpressureSupport(FULL) @NonNull public final @NonNull Completable concatMapCompletableDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends CompletableSource> mapper)
Maps the upstream items intoCompletableSource
s and subscribes to them one after the other terminates, delaying all errors till both thisFlowable
and all innerCompletableSource
s terminate.- Backpressure:
- The operator expects the upstream to support backpressure. If this
Flowable
violates the rule, the operator will signal aMissingBackpressureException
. - Scheduler:
concatMapCompletableDelayError
does not operate by default on a particularScheduler
.
History: 2.1.11 - experimental
- Parameters:
mapper
- the function called with the upstream item and should return aCompletableSource
to become the next source to be subscribed to- Returns:
- the new
Completable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.2
- See Also:
concatMapCompletable(Function, int)
-
concatMapCompletableDelayError
@CheckReturnValue @SchedulerSupport("none") @BackpressureSupport(FULL) @NonNull public final @NonNull Completable concatMapCompletableDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends CompletableSource> mapper, boolean tillTheEnd)
Maps the upstream items intoCompletableSource
s and subscribes to them one after the other terminates, optionally delaying all errors till both thisFlowable
and all innerCompletableSource
s terminate.- Backpressure:
- The operator expects the upstream to support backpressure. If this
Flowable
violates the rule, the operator will signal aMissingBackpressureException
. - Scheduler:
concatMapCompletableDelayError
does not operate by default on a particularScheduler
.
History: 2.1.11 - experimental
- Parameters:
mapper
- the function called with the upstream item and should return aCompletableSource
to become the next source to be subscribed totillTheEnd
- Iftrue
, errors from thisFlowable
or any of the innerCompletableSource
s are delayed until all of them terminate. Iffalse
, an error from thisFlowable
is delayed until the current innerCompletableSource
terminates and only then is it emitted to the downstream.- Returns:
- the new
Completable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.2
- See Also:
concatMapCompletable(Function)
-
concatMapCompletableDelayError
@CheckReturnValue @NonNull @SchedulerSupport("none") @BackpressureSupport(FULL) public final @NonNull Completable concatMapCompletableDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends CompletableSource> mapper, boolean tillTheEnd, int prefetch)
Maps the upstream items intoCompletableSource
s and subscribes to them one after the other terminates, optionally delaying all errors till both thisFlowable
and all innerCompletableSource
s terminate.- Backpressure:
- The operator expects the upstream to support backpressure. If this
Flowable
violates the rule, the operator will signal aMissingBackpressureException
. - Scheduler:
concatMapCompletableDelayError
does not operate by default on a particularScheduler
.
History: 2.1.11 - experimental
- Parameters:
mapper
- the function called with the upstream item and should return aCompletableSource
to become the next source to be subscribed totillTheEnd
- Iftrue
, errors from thisFlowable
or any of the innerCompletableSource
s are delayed until all of them terminate. Iffalse
, an error from thisFlowable
is delayed until the current innerCompletableSource
terminates and only then is it emitted to the downstream.prefetch
- The number of upstream items to prefetch so that fresh items are ready to be mapped when a previousCompletableSource
terminates. The operator replenishes after half of the prefetch amount has been consumed and turned intoCompletableSource
s.- Returns:
- the new
Completable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifprefetch
is non-positive- Since:
- 2.2
- See Also:
concatMapCompletable(Function, int)
-
concatMapDelayError
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Flowable<R> concatMapDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper)
Maps each of the items into aPublisher
, 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 innerPublisher
s 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 themapper
function is confined to a known thread, use theconcatMapDelayError(Function, boolean, int, Scheduler)
overload.- Backpressure:
- The operator honors backpressure from downstream. Both this and the inner
Publisher
s are expected to honor backpressure as well. If the currentFlowable
violates the rule, the operator will signal aMissingBackpressureException
. If any of the innerPublisher
s doesn't honor backpressure, that may throw anIllegalStateException
when thatPublisher
completes. - Scheduler:
concatMapDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the result value type- Parameters:
mapper
- the function that maps the items of thisPublisher
into the innerPublisher
s.- Returns:
- the new
Flowable
instance with the concatenation behavior - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- See Also:
concatMapDelayError(Function, boolean, int, Scheduler)
-
concatMapDelayError
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final <@NonNull R> @NonNull Flowable<R> concatMapDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper, boolean tillTheEnd, int prefetch)
Maps each of the items into aPublisher
, 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 innerPublisher
s 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 themapper
function is confined to a known thread, use theconcatMapDelayError(Function, boolean, int, Scheduler)
overload.- Backpressure:
- The operator honors backpressure from downstream. Both this and the inner
Publisher
s are expected to honor backpressure as well. If the currentFlowable
violates the rule, the operator will signal aMissingBackpressureException
. If any of the innerPublisher
s doesn't honor backpressure, that may throw anIllegalStateException
when thatPublisher
completes. - Scheduler:
concatMapDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the result value type- Parameters:
mapper
- the function that maps the items of thisPublisher
into the innerPublisher
s.tillTheEnd
- iftrue
, all errors from the outer and innerPublisher
sources are delayed until the end, iffalse
, an error from the main source is signaled when the current innerPublisher
source terminatesprefetch
- the number of elements to prefetch from the currentFlowable
- Returns:
- the new
Flowable
instance with the concatenation behavior - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifprefetch
is non-positive- See Also:
concatMapDelayError(Function, boolean, int, Scheduler)
-
concatMapDelayError
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("custom") public final <@NonNull R> @NonNull Flowable<R> concatMapDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper, boolean tillTheEnd, int prefetch, @NonNull @NonNull Scheduler scheduler)
Maps each of the upstream items into aPublisher
, subscribes to them one after the other, one at a time and emits their values in order while executing the mapper function on the designated scheduler, delaying any error from either this or any of the innerPublisher
s till all of them terminate.The difference between
concatMapDelayError(Function, boolean, int)
and this operator is that this operator guarantees themapper
function is executed on the specified scheduler.- Backpressure:
- The operator honors backpressure from downstream. Both this and the inner
Publisher
s are expected to honor backpressure as well. If the currentFlowable
violates the rule, the operator will signal aMissingBackpressureException
. If any of the innerPublisher
s doesn't honor backpressure, that may throw anIllegalStateException
when thatPublisher
completes. - Scheduler:
concatMapDelayError
executes the givenmapper
function on the providedScheduler
.
- Type Parameters:
R
- the result value type- Parameters:
mapper
- the function that maps the items of thisPublisher
into the innerPublisher
s.tillTheEnd
- iftrue
, all errors from the outer and innerPublisher
sources are delayed until the end, iffalse
, an error from the main source is signaled when the current innerPublisher
source terminatesprefetch
- the number of elements to prefetch from the currentFlowable
scheduler
- the scheduler where themapper
function will be executed- Returns:
- the new
Flowable
instance with the concatenation behavior - Throws:
java.lang.NullPointerException
- ifmapper
orscheduler
isnull
java.lang.IllegalArgumentException
- ifprefetch
is non-positive- Since:
- 3.0.0
- See Also:
concatMapDelayError(Function, boolean, int)
-
concatMapEager
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Flowable<R> concatMapEager(@NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper)
Maps a sequence of values intoPublisher
s and concatenates thesePublisher
s eagerly into a singlePublisher
.Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the inner
Publisher
s. The operator buffers the values emitted by thesePublisher
s and then drains them in order, each one after the previous one completes.- Backpressure:
- Backpressure is honored towards the downstream, however, due to the eagerness requirement, sources are subscribed to in unbounded mode and their values are queued up in an unbounded buffer.
- 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 ofPublisher
s that will be eagerly concatenated- Returns:
- the new
Flowable
instance with the specified concatenation behavior - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.0
-
concatMapEager
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final <@NonNull R> @NonNull Flowable<R> concatMapEager(@NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper, int maxConcurrency, int prefetch)
Maps a sequence of values intoPublisher
s and concatenates thesePublisher
s eagerly into a singlePublisher
.Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the inner
Publisher
s. The operator buffers the values emitted by thesePublisher
s and then drains them in order, each one after the previous one completes.- Backpressure:
- Backpressure is honored towards the downstream, however, due to the eagerness requirement, sources are subscribed to in unbounded mode and their values are queued up in an unbounded buffer.
- 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 ofPublisher
s that will be eagerly concatenatedmaxConcurrency
- the maximum number of concurrent subscribedPublisher
sprefetch
- hints about the number of expected values from each innerPublisher
, must be positive- Returns:
- the new
Flowable
instance with the specified concatenation behavior - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
orprefetch
is non-positive- Since:
- 2.0
-
concatMapEagerDelayError
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Flowable<R> concatMapEagerDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper, boolean tillTheEnd)
Maps a sequence of values intoPublisher
s and concatenates thesePublisher
s eagerly into a singlePublisher
.Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the inner
Publisher
s. The operator buffers the values emitted by thesePublisher
s and then drains them in order, each one after the previous one completes.- Backpressure:
- Backpressure is honored towards the downstream, however, due to the eagerness requirement, sources are subscribed to in unbounded mode and their values are queued up in an unbounded buffer.
- 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 ofPublisher
s that will be eagerly concatenatedtillTheEnd
- iftrue
, all errors from the outer and innerPublisher
sources are delayed until the end, iffalse
, an error from the main source is signaled when the current innerPublisher
source terminates- Returns:
- the new
Flowable
instance with the specified concatenation behavior - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.0
-
concatMapEagerDelayError
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final <@NonNull R> @NonNull Flowable<R> concatMapEagerDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper, boolean tillTheEnd, int maxConcurrency, int prefetch)
Maps a sequence of values intoPublisher
s and concatenates thesePublisher
s eagerly into a singleFlowable
sequence.Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the inner
Publisher
s. The operator buffers the values emitted by thesePublisher
s and then drains them in order, each one after the previous one completes.- Backpressure:
- Backpressure is honored towards the downstream, however, due to the eagerness requirement, sources are subscribed to in unbounded mode and their values are queued up in an unbounded buffer.
- 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 ofPublisher
s that will be eagerly concatenatedtillTheEnd
- iftrue
, exceptions from the currentFlowable
and all the innerPublisher
s are delayed until all of them terminate, iffalse
, exception from the currentFlowable
is delayed until the currently runningPublisher
terminatesmaxConcurrency
- the maximum number of concurrent subscribedPublisher
sprefetch
- the number of elements to prefetch from each sourcePublisher
- Returns:
- the new
Flowable
instance with the specified concatenation behavior - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
orprefetch
is non-positive- Since:
- 2.0
-
concatMapIterable
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull U> @NonNull Flowable<U> concatMapIterable(@NonNull @NonNull Function<? super @NonNull T,? extends java.lang.Iterable<? extends @NonNull U>> mapper)
Returns aFlowable
that concatenate each item emitted by the currentFlowable
with the values in anIterable
corresponding to that item that is generated by a selector.- Backpressure:
- The operator honors backpressure from downstream. The current
Flowable
s is expected to honor backpressure as well. If the currentFlowable
violates the rule, the operator will signal aMissingBackpressureException
. - Scheduler:
concatMapIterable
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the type of item emitted by the resultingFlowable
- Parameters:
mapper
- a function that returns anIterable
sequence of values for when given an item emitted by the currentFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- See Also:
- ReactiveX operators documentation: FlatMap
-
concatMapIterable
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final <@NonNull U> @NonNull Flowable<U> concatMapIterable(@NonNull @NonNull Function<? super @NonNull T,? extends java.lang.Iterable<? extends @NonNull U>> mapper, int prefetch)
Returns aFlowable
that concatenate each item emitted by the currentFlowable
with the values in anIterable
corresponding to that item that is generated by a selector.- Backpressure:
- The operator honors backpressure from downstream. The current
Flowable
is expected to honor backpressure as well. If the currentFlowable
violates the rule, the operator will signal aMissingBackpressureException
. - Scheduler:
concatMapIterable
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the type of item emitted by the resultingFlowable
- Parameters:
mapper
- a function that returns anIterable
sequence of values for when given an item emitted by the currentFlowable
prefetch
- the number of elements to prefetch from the currentFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifprefetch
is non-positive- See Also:
- ReactiveX operators documentation: FlatMap
-
concatMapMaybe
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Flowable<R> concatMapMaybe(@NonNull @NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper)
Maps the upstream items intoMaybeSource
s and subscribes to them one after the other succeeds or completes, emits their success value if available or terminates immediately if either thisFlowable
or the current innerMaybeSource
fail.- Backpressure:
- The operator expects the upstream to support backpressure and honors
the backpressure from downstream. If this
Flowable
violates the rule, the operator will signal aMissingBackpressureException
. - Scheduler:
concatMapMaybe
does not operate by default on a particularScheduler
.
History: 2.1.11 - experimental
- Type Parameters:
R
- the result type of the innerMaybeSource
s- Parameters:
mapper
- the function called with the upstream item and should return aMaybeSource
to become the next source to be subscribed to- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.2
- See Also:
concatMapMaybeDelayError(Function)
,concatMapMaybe(Function, int)
-
concatMapMaybe
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final <@NonNull R> @NonNull Flowable<R> concatMapMaybe(@NonNull @NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper, int prefetch)
Maps the upstream items intoMaybeSource
s and subscribes to them one after the other succeeds or completes, emits their success value if available or terminates immediately if either thisFlowable
or the current innerMaybeSource
fail.- Backpressure:
- The operator expects the upstream to support backpressure and honors
the backpressure from downstream. If this
Flowable
violates the rule, the operator will signal aMissingBackpressureException
. - Scheduler:
concatMapMaybe
does not operate by default on a particularScheduler
.
History: 2.1.11 - experimental
- Type Parameters:
R
- the result type of the innerMaybeSource
s- Parameters:
mapper
- the function called with the upstream item and should return aMaybeSource
to become the next source to be subscribed toprefetch
- The number of upstream items to prefetch so that fresh items are ready to be mapped when a previousMaybeSource
terminates. The operator replenishes after half of the prefetch amount has been consumed and turned intoMaybeSource
s.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifprefetch
is non-positive- Since:
- 2.2
- See Also:
concatMapMaybe(Function)
,concatMapMaybeDelayError(Function, boolean, int)
-
concatMapMaybeDelayError
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Flowable<R> concatMapMaybeDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper)
Maps the upstream items intoMaybeSource
s and subscribes to them one after the other terminates, emits their success value if available and delaying all errors till both thisFlowable
and all innerMaybeSource
s terminate.- Backpressure:
- The operator expects the upstream to support backpressure and honors
the backpressure from downstream. If this
Flowable
violates the rule, the operator will signal aMissingBackpressureException
. - Scheduler:
concatMapMaybeDelayError
does not operate by default on a particularScheduler
.
History: 2.1.11 - experimental
- Type Parameters:
R
- the result type of the innerMaybeSource
s- Parameters:
mapper
- the function called with the upstream item and should return aMaybeSource
to become the next source to be subscribed to- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.2
- See Also:
concatMapMaybe(Function)
,concatMapMaybeDelayError(Function, boolean)
-
concatMapMaybeDelayError
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Flowable<R> concatMapMaybeDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper, boolean tillTheEnd)
Maps the upstream items intoMaybeSource
s and subscribes to them one after the other terminates, emits their success value if available and optionally delaying all errors till both thisFlowable
and all innerMaybeSource
s terminate.- Backpressure:
- The operator expects the upstream to support backpressure and honors
the backpressure from downstream. If this
Flowable
violates the rule, the operator will signal aMissingBackpressureException
. - Scheduler:
concatMapMaybeDelayError
does not operate by default on a particularScheduler
.
History: 2.1.11 - experimental
- Type Parameters:
R
- the result type of the innerMaybeSource
s- Parameters:
mapper
- the function called with the upstream item and should return aMaybeSource
to become the next source to be subscribed totillTheEnd
- Iftrue
, errors from thisFlowable
or any of the innerMaybeSource
s are delayed until all of them terminate. Iffalse
, an error from thisFlowable
is delayed until the current innerMaybeSource
terminates and only then is it emitted to the downstream.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.2
- See Also:
concatMapMaybe(Function, int)
,concatMapMaybeDelayError(Function, boolean, int)
-
concatMapMaybeDelayError
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final <@NonNull R> @NonNull Flowable<R> concatMapMaybeDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper, boolean tillTheEnd, int prefetch)
Maps the upstream items intoMaybeSource
s and subscribes to them one after the other terminates, emits their success value if available and optionally delaying all errors till both thisFlowable
and all innerMaybeSource
s terminate.- Backpressure:
- The operator expects the upstream to support backpressure and honors
the backpressure from downstream. If this
Flowable
violates the rule, the operator will signal aMissingBackpressureException
. - Scheduler:
concatMapMaybeDelayError
does not operate by default on a particularScheduler
.
History: 2.1.11 - experimental
- Type Parameters:
R
- the result type of the innerMaybeSource
s- Parameters:
mapper
- the function called with the upstream item and should return aMaybeSource
to become the next source to be subscribed totillTheEnd
- Iftrue
, errors from thisFlowable
or any of the innerMaybeSource
s are delayed until all of them terminate. Iffalse
, an error from thisFlowable
is delayed until the current innerMaybeSource
terminates and only then is it emitted to the downstream.prefetch
- The number of upstream items to prefetch so that fresh items are ready to be mapped when a previousMaybeSource
terminates. The operator replenishes after half of the prefetch amount has been consumed and turned intoMaybeSource
s.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifprefetch
is non-positive- Since:
- 2.2
- See Also:
concatMapMaybe(Function, int)
-
concatMapSingle
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Flowable<R> concatMapSingle(@NonNull @NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper)
Maps the upstream items intoSingleSource
s and subscribes to them one after the other succeeds, emits their success values or terminates immediately if either thisFlowable
or the current innerSingleSource
fail.- Backpressure:
- The operator expects the upstream to support backpressure and honors
the backpressure from downstream. If this
Flowable
violates the rule, the operator will signal aMissingBackpressureException
. - Scheduler:
concatMapSingle
does not operate by default on a particularScheduler
.
History: 2.1.11 - experimental
- Type Parameters:
R
- the result type of the innerSingleSource
s- Parameters:
mapper
- the function called with the upstream item and should return aSingleSource
to become the next source to be subscribed to- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.2
- See Also:
concatMapSingleDelayError(Function)
,concatMapSingle(Function, int)
-
concatMapSingle
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final <@NonNull R> @NonNull Flowable<R> concatMapSingle(@NonNull @NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper, int prefetch)
Maps the upstream items intoSingleSource
s and subscribes to them one after the other succeeds, emits their success values or terminates immediately if either thisFlowable
or the current innerSingleSource
fail.- Backpressure:
- The operator expects the upstream to support backpressure and honors
the backpressure from downstream. If this
Flowable
violates the rule, the operator will signal aMissingBackpressureException
. - Scheduler:
concatMapSingle
does not operate by default on a particularScheduler
.
History: 2.1.11 - experimental
- Type Parameters:
R
- the result type of the innerSingleSource
s- Parameters:
mapper
- the function called with the upstream item and should return aSingleSource
to become the next source to be subscribed toprefetch
- The number of upstream items to prefetch so that fresh items are ready to be mapped when a previousSingleSource
terminates. The operator replenishes after half of the prefetch amount has been consumed and turned intoSingleSource
s.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifprefetch
is non-positive- Since:
- 2.2
- See Also:
concatMapSingle(Function)
,concatMapSingleDelayError(Function, boolean, int)
-
concatMapSingleDelayError
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Flowable<R> concatMapSingleDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper)
Maps the upstream items intoSingleSource
s and subscribes to them one after the other succeeds or fails, emits their success values and delays all errors till both thisFlowable
and all innerSingleSource
s terminate.- Backpressure:
- The operator expects the upstream to support backpressure and honors
the backpressure from downstream. If this
Flowable
violates the rule, the operator will signal aMissingBackpressureException
. - Scheduler:
concatMapSingleDelayError
does not operate by default on a particularScheduler
.
History: 2.1.11 - experimental
- Type Parameters:
R
- the result type of the innerSingleSource
s- Parameters:
mapper
- the function called with the upstream item and should return aSingleSource
to become the next source to be subscribed to- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.2
- See Also:
concatMapSingle(Function)
,concatMapSingleDelayError(Function, boolean)
-
concatMapSingleDelayError
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Flowable<R> concatMapSingleDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper, boolean tillTheEnd)
Maps the upstream items intoSingleSource
s and subscribes to them one after the other succeeds or fails, emits their success values and optionally delays all errors till both thisFlowable
and all innerSingleSource
s terminate.- Backpressure:
- The operator expects the upstream to support backpressure and honors
the backpressure from downstream. If this
Flowable
violates the rule, the operator will signal aMissingBackpressureException
. - Scheduler:
concatMapSingleDelayError
does not operate by default on a particularScheduler
.
History: 2.1.11 - experimental
- Type Parameters:
R
- the result type of the innerSingleSource
s- Parameters:
mapper
- the function called with the upstream item and should return aSingleSource
to become the next source to be subscribed totillTheEnd
- Iftrue
, errors from thisFlowable
or any of the innerSingleSource
s are delayed until all of them terminate. Iffalse
, an error from thisFlowable
is delayed until the current innerSingleSource
terminates and only then is it emitted to the downstream.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.2
- See Also:
concatMapSingle(Function, int)
,concatMapSingleDelayError(Function, boolean, int)
-
concatMapSingleDelayError
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final <@NonNull R> @NonNull Flowable<R> concatMapSingleDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper, boolean tillTheEnd, int prefetch)
Maps the upstream items intoSingleSource
s and subscribes to them one after the other succeeds or fails, emits their success values and optionally delays errors till both thisFlowable
and all innerSingleSource
s terminate.- Backpressure:
- The operator expects the upstream to support backpressure and honors
the backpressure from downstream. If this
Flowable
violates the rule, the operator will signal aMissingBackpressureException
. - Scheduler:
concatMapSingleDelayError
does not operate by default on a particularScheduler
.
History: 2.1.11 - experimental
- Type Parameters:
R
- the result type of the innerSingleSource
s- Parameters:
mapper
- the function called with the upstream item and should return aSingleSource
to become the next source to be subscribed totillTheEnd
- Iftrue
, errors from thisFlowable
or any of the innerSingleSource
s are delayed until all of them terminate. Iffalse
, an error from thisFlowable
is delayed until the current innerSingleSource
terminates and only then is it emitted to the downstream.prefetch
- The number of upstream items to prefetch so that fresh items are ready to be mapped when a previousSingleSource
terminates. The operator replenishes after half of the prefetch amount has been consumed and turned intoSingleSource
s.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifprefetch
is non-positive- Since:
- 2.2
- See Also:
concatMapSingle(Function, int)
-
concatWith
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final @NonNull Flowable<T> concatWith(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> other)
Returns aFlowable
that emits the items emitted from the currentFlowable
, then the next, one after the other, without interleaving them.- Backpressure:
- The operator honors backpressure from downstream. Both this and the
other
Publisher
s are expected to honor backpressure as well. If any of then violates this rule, it may throw anIllegalStateException
when the currentFlowable
completes. - Scheduler:
concatWith
does not operate by default on a particularScheduler
.
- Parameters:
other
- aPublisher
to be concatenated after the current- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifother
isnull
- See Also:
- ReactiveX operators documentation: Concat
-
concatWith
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> concatWith(@NonNull @NonNull SingleSource<? extends @NonNull T> other)
Returns aFlowable
that emits the items from thisFlowable
followed by the success item or error event of the otherSingleSource
.- Backpressure:
- The operator supports backpressure and makes sure the success item of the other
SingleSource
is only emitted when there is a demand for it. - Scheduler:
concatWith
does not operate by default on a particularScheduler
.
History: 2.1.10 - experimental
- Parameters:
other
- theSingleSource
whose signal should be emitted after thisFlowable
completes normally.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifother
isnull
- Since:
- 2.2
-
concatWith
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> concatWith(@NonNull @NonNull MaybeSource<? extends @NonNull T> other)
Returns aFlowable
that emits the items from thisFlowable
followed by the success item or terminal events of the otherMaybeSource
.- Backpressure:
- The operator supports backpressure and makes sure the success item of the other
MaybeSource
is only emitted when there is a demand for it. - Scheduler:
concatWith
does not operate by default on a particularScheduler
.
History: 2.1.10 - experimental
- Parameters:
other
- theMaybeSource
whose signal should be emitted after thisFlowable
completes normally.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifother
isnull
- Since:
- 2.2
-
concatWith
@CheckReturnValue @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> concatWith(@NonNull @NonNull CompletableSource other)
Returns aFlowable
that emits items from thisFlowable
and when it completes normally, the otherCompletableSource
is subscribed to and the returnedFlowable
emits its terminal events.- Backpressure:
- The operator does not interfere with backpressure between the current
Flowable
and the downstream consumer (i.e., acts as pass-through). When the operator switches to theCompletable
, backpressure is no longer present becauseCompletable
doesn't have items to apply backpressure to. - Scheduler:
concatWith
does not operate by default on a particularScheduler
.
History: 2.1.10 - experimental
- Parameters:
other
- theCompletableSource
to subscribe to once the currentFlowable
completes normally- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifother
isnull
- Since:
- 2.2
-
contains
@CheckReturnValue @NonNull @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") public final @NonNull Single<java.lang.Boolean> contains(@NonNull @NonNull java.lang.Object item)
Returns aSingle
that emits aBoolean
that indicates whether the currentFlowable
emitted a specified item.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., without applying backpressure). - Scheduler:
contains
does not operate by default on a particularScheduler
.
- Parameters:
item
- the item to search for in the emissions from the currentFlowable
- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifitem
isnull
- See Also:
- ReactiveX operators documentation: Contains
-
count
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final @NonNull Single<java.lang.Long> count()
Returns aSingle
that counts the total number of items emitted by the currentFlowable
and emits this count as a 64-bitLong
.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., without applying backpressure). - Scheduler:
count
does not operate by default on a particularScheduler
.
- Returns:
- the new
Single
instance - See Also:
- ReactiveX operators documentation: Count
-
debounce
@CheckReturnValue @NonNull @BackpressureSupport(ERROR) @SchedulerSupport("none") public final <@NonNull U> @NonNull Flowable<T> debounce(@NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<@NonNull U>> debounceIndicator)
Returns aFlowable
that mirrors the currentFlowable
, except that it drops items emitted by the currentFlowable
that are followed by another item within a computed debounce duration.The delivery of the item happens on the thread of the first
onNext
oronComplete
signal of the generatedPublisher
sequence, which if takes too long, a newer item may arrive from the upstream, causing the generated sequence to get cancelled, which may also interrupt any downstream blocking operation (yielding anInterruptedException
). It is recommended processing items that may take long time to be moved to another thread viaobserveOn(io.reactivex.rxjava3.core.Scheduler)
applied afterdebounce
itself.- Backpressure:
- This operator does not support backpressure as it uses the
debounceSelector
to mark boundaries. - Scheduler:
- This version of
debounce
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the debounce value type (ignored)- Parameters:
debounceIndicator
- function to retrieve a sequence that indicates the throttle duration for each item- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifdebounceIndicator
isnull
- See Also:
- ReactiveX operators documentation: Debounce, RxJava wiki: Backpressure
-
debounce
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Flowable<T> debounce(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that mirrors the currentFlowable
, except that it drops items emitted by the currentFlowable
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
Flowable
faster than the timeout then no items will be emitted by the resultingFlowable
.Delivery of the item after the grace period happens on the
computation
Scheduler
'sWorker
which if takes too long, a newer item may arrive from the upstream, causing theWorker
's task to get disposed, which may also interrupt any downstream blocking operation (yielding anInterruptedException
). It is recommended processing items that may take long time to be moved to another thread viaobserveOn(io.reactivex.rxjava3.core.Scheduler)
applied afterdebounce
itself.- Backpressure:
- This operator does not support backpressure as it uses time to control data flow.
- Scheduler:
debounce
operates by default on thecomputation
Scheduler
.
- Parameters:
timeout
- the length of the window of time that must pass after the emission of an item from the currentFlowable
in which it emits no items in order for the item to be emitted by the resultingFlowable
unit
- the unit of time for the specifiedtimeout
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Debounce,
RxJava wiki: Backpressure,
throttleWithTimeout(long, TimeUnit)
-
debounce
@CheckReturnValue @NonNull @BackpressureSupport(ERROR) @SchedulerSupport("custom") public final @NonNull Flowable<T> debounce(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns aFlowable
that mirrors the currentFlowable
, except that it drops items emitted by the currentFlowable
that are followed by newer items before a timeout value expires on a specifiedScheduler
. The timer resets on each emission.Note: If items keep being emitted by the current
Flowable
faster than the timeout then no items will be emitted by the resultingFlowable
.Delivery of the item after the grace period happens on the given
Scheduler
'sWorker
which if takes too long, a newer item may arrive from the upstream, causing theWorker
's task to get disposed, which may also interrupt any downstream blocking operation (yielding anInterruptedException
). It is recommended processing items that may take long time to be moved to another thread viaobserveOn(io.reactivex.rxjava3.core.Scheduler)
applied afterdebounce
itself.- Backpressure:
- This operator does not support backpressure as it uses time to control data flow.
- 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 currentFlowable
to ensure that it's not droppedunit
- the unit of time for the specifiedtimeout
scheduler
- theScheduler
to use internally to manage the timers that handle the timeout for each item- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Debounce,
RxJava wiki: Backpressure,
throttleWithTimeout(long, TimeUnit, Scheduler)
-
debounce
@CheckReturnValue @NonNull @BackpressureSupport(ERROR) @SchedulerSupport("custom") public final @NonNull Flowable<T> debounce(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, @NonNull @NonNull Consumer<? super @NonNull T> onDropped)
Returns aFlowable
that mirrors the currentFlowable
, except that it drops items emitted by the currentFlowable
that are followed by newer items before a timeout value expires on a specifiedScheduler
. The timer resets on each emission.Note: If items keep being emitted by the current
Flowable
faster than the timeout then no items will be emitted by the resultingFlowable
.Delivery of the item after the grace period happens on the given
Scheduler
'sWorker
which if takes too long, a newer item may arrive from the upstream, causing theWorker
's task to get disposed, which may also interrupt any downstream blocking operation (yielding anInterruptedException
). It is recommended processing items that may take long time to be moved to another thread viaobserveOn(io.reactivex.rxjava3.core.Scheduler)
applied afterdebounce
itself.- Backpressure:
- This operator does not support backpressure as it uses time to control data flow.
- 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 currentFlowable
to ensure that it's not droppedunit
- the unit of time for the specifiedtimeout
scheduler
- theScheduler
to use internally to manage the timers that handle the timeout for each itemonDropped
- called with the current entry when it has been replaced by a new one- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
oronDropped
isnull
- Since:
- 3.1.6 - Experimental
- See Also:
- ReactiveX operators documentation: Debounce,
RxJava wiki: Backpressure,
throttleWithTimeout(long, TimeUnit, Scheduler, Consumer)
-
defaultIfEmpty
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final @NonNull Flowable<T> defaultIfEmpty(@NonNull @NonNull T defaultItem)
Returns aFlowable
that emits the items emitted by the currentFlowable
or a specified default item if the currentFlowable
is empty.- Backpressure:
- If the current
Flowable
is empty, this operator is guaranteed to honor backpressure from downstream. If the currentFlowable
is non-empty, it is expected to honor backpressure as well; if the rule is violated, aMissingBackpressureException
may get signaled somewhere downstream. - Scheduler:
defaultIfEmpty
does not operate by default on a particularScheduler
.
- Parameters:
defaultItem
- the item to emit if the currentFlowable
emits no items- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifdefaultItem
isnull
- See Also:
- ReactiveX operators documentation: DefaultIfEmpty
-
delay
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final <@NonNull U> @NonNull Flowable<T> delay(@NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<@NonNull U>> itemDelayIndicator)
Returns aFlowable
that delays the emissions of the currentFlowable
via anotherPublisher
on a per-item basis.Note: the resulting
Flowable
will immediately propagate anyonError
notification from the currentFlowable
.- Backpressure:
- The operator doesn't interfere with the backpressure behavior which is determined by the current
Flowable
. All of the otherPublisher
s supplied by the function are consumed in an unbounded manner (i.e., no backpressure applied to them). - Scheduler:
- This version of
delay
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the item delay value type (ignored)- Parameters:
itemDelayIndicator
- a function that returns aPublisher
for each item emitted by the currentFlowable
, which is then used to delay the emission of that item by the resultingFlowable
until thePublisher
returned fromitemDelay
emits an item- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifitemDelayIndicator
isnull
- See Also:
- ReactiveX operators documentation: Delay
-
delay
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Flowable<T> delay(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits the items emitted by the currentFlowable
shifted forward in time by a specified delay. TheonError
notification from the currentFlowable
is not delayed.- Backpressure:
- The operator doesn't interfere with the backpressure behavior which is determined by the current
Flowable
. - Scheduler:
- This version of
delay
operates by default on thecomputation
Scheduler
.
- Parameters:
time
- the delay to shift the source byunit
- theTimeUnit
in whichperiod
is defined- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Delay
-
delay
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Flowable<T> delay(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, boolean delayError)
Returns aFlowable
that emits the items emitted by the currentFlowable
shifted forward in time by a specified delay. IfdelayError
istrue
, error notifications will also be delayed.- Backpressure:
- The operator doesn't interfere with the backpressure behavior which is determined by the current
Flowable
. - Scheduler:
- This version of
delay
operates by default on thecomputation
Scheduler
.
- Parameters:
time
- the delay to shift the source byunit
- theTimeUnit
in whichperiod
is defineddelayError
- iftrue
, the upstream exception is signaled with the given delay, after all preceding normal elements, iffalse
, the upstream exception is signaled immediately- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Delay
-
delay
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("custom") @NonNull public final @NonNull Flowable<T> delay(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns aFlowable
that emits the items emitted by the currentFlowable
shifted forward in time by a specified delay. TheonError
notification from the currentFlowable
is not delayed.- Backpressure:
- The operator doesn't interfere with the backpressure behavior which is determined by the current
Flowable
. - Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
time
- the delay to shift the source byunit
- the time unit ofdelay
scheduler
- theScheduler
to use for delaying- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Delay
-
delay
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("custom") public final @NonNull Flowable<T> delay(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, boolean delayError)
Returns aFlowable
that emits the items emitted by the currentFlowable
shifted forward in time by a specified delay. IfdelayError
istrue
, error notifications will also be delayed.- Backpressure:
- The operator doesn't interfere with the backpressure behavior which is determined by the current
Flowable
. - Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
time
- the delay to shift the source byunit
- the time unit ofdelay
scheduler
- theScheduler
to use for delayingdelayError
- iftrue
, the upstream exception is signaled with the given delay, after all preceding normal elements, iffalse
, the upstream exception is signaled immediately- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Delay
-
delay
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull U,@NonNull V> @NonNull Flowable<T> delay(@NonNull @NonNull org.reactivestreams.Publisher<@NonNull U> subscriptionIndicator, @NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<@NonNull V>> itemDelayIndicator)
Returns aFlowable
that delays the subscription to and emissions from the currentFlowable
via anotherPublisher
on a per-item basis.Note: the resulting
Flowable
will immediately propagate anyonError
notification from the currentFlowable
.- Backpressure:
- The operator doesn't interfere with the backpressure behavior which is determined by the current
Flowable
. All of the otherPublisher
s supplied by the functions are consumed in an unbounded manner (i.e., no backpressure applied to them). - Scheduler:
- This version of
delay
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the subscription delay value type (ignored)V
- the item delay value type (ignored)- Parameters:
subscriptionIndicator
- a function that returns aPublisher
that triggers the subscription to the currentFlowable
once it emits any itemitemDelayIndicator
- a function that returns aPublisher
for each item emitted by the currentFlowable
, which is then used to delay the emission of that item by the resultingFlowable
until thePublisher
returned fromitemDelay
emits an item- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsubscriptionIndicator
anditemDelayIndicator
isnull
- See Also:
- ReactiveX operators documentation: Delay
-
delaySubscription
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final <@NonNull U> @NonNull Flowable<T> delaySubscription(@NonNull @NonNull org.reactivestreams.Publisher<@NonNull U> subscriptionIndicator)
Returns aFlowable
that delays the subscription to thisPublisher
until the otherPublisher
emits an element or completes normally.- Backpressure:
- The operator forwards the backpressure requests to this
Publisher
once the subscription happens and requestsLong.MAX_VALUE
from the otherPublisher
- Scheduler:
- This method does not operate by default on a particular
Scheduler
.
- Type Parameters:
U
- the value type of the otherPublisher
, irrelevant- Parameters:
subscriptionIndicator
- the otherPublisher
that should trigger the subscription to thisPublisher
.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsubscriptionIndicator
isnull
- Since:
- 2.0
-
delaySubscription
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Flowable<T> delaySubscription(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that delays the subscription to the currentFlowable
by a given amount of time.- Backpressure:
- The operator doesn't interfere with the backpressure behavior which is determined by the current
Flowable
. - Scheduler:
- This version of
delaySubscription
operates by default on thecomputation
Scheduler
.
- Parameters:
time
- the time to delay the subscriptionunit
- the time unit ofdelay
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Delay
-
delaySubscription
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("custom") @NonNull public final @NonNull Flowable<T> delaySubscription(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns aFlowable
that delays the subscription to the currentFlowable
by a given amount of time, both waiting and subscribing on a givenScheduler
.- Backpressure:
- The operator doesn't interfere with the backpressure behavior which is determined by the current
Flowable
. - Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
time
- the time to delay the subscriptionunit
- the time unit ofdelay
scheduler
- theScheduler
on which the waiting and subscription will happen- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Delay
-
dematerialize
@CheckReturnValue @NonNull @SchedulerSupport("none") @BackpressureSupport(PASS_THROUGH) public final <@NonNull R> @NonNull Flowable<R> dematerialize(@NonNull @NonNull Function<? super @NonNull T,@NonNull Notification<@NonNull R>> selector)
Returns aFlowable
that reverses the effect ofmaterialize
by transforming theNotification
objects extracted from the source items via a selector function into their respectiveSubscriber
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 typeNotification<T>
. The Java language doesn't allow limiting instance methods to a certain generic argument shape, therefore, a function is used to ensure the conversion remains type safe.When the upstream signals an
onError
oronComplete
item, the returnedFlowable
cancels of the flow and terminates with that type of terminal event:
If the upstream signalsFlowable.just(createOnNext(1), createOnComplete(), createOnNext(2)) .doOnCancel(() -> System.out.println("Canceled!")); .dematerialize(notification -> notification) .test() .assertResult(1);
onError
oronComplete
directly, the flow is terminated with the same event.
If this behavior is not desired, the completion can be suppressed by applyingFlowable.just(createOnNext(1), createOnNext(2)) .dematerialize(notification -> notification) .test() .assertResult(1, 2);
concatWith(Publisher)
with anever()
source.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
dematerialize
does not operate by default on a particularScheduler
.
History: 2.2.4 - experimental
- Type Parameters:
R
- the output value type- Parameters:
selector
- function that returns the upstream item and should return aNotification
to signal the correspondingSubscriber
event to the downstream.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifselector
isnull
- Since:
- 3.0.0
- See Also:
- ReactiveX operators documentation: Dematerialize
-
distinct
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> distinct()
Returns aFlowable
that emits all items emitted by the currentFlowable
that are distinct based onObject.equals(Object)
comparison.It is recommended the elements' class
T
in the flow overrides the defaultObject.equals()
andObject.hashCode()
to provide a meaningful comparison between items as the default Java implementation only considers reference equivalence.By default,
distinct()
uses an internalHashSet
perSubscriber
to remember previously seen items and usesSet.add(Object)
returningfalse
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 toOutOfMemoryError
.Customizing the retention policy can happen only by providing a custom
Collection
implementation to thedistinct(Function, Supplier)
overload.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
distinct
does not operate by default on a particularScheduler
.
- Returns:
- the new
Flowable
instance - See Also:
- ReactiveX operators documentation: Distinct,
distinct(Function)
,distinct(Function, Supplier)
-
distinct
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull K> @NonNull Flowable<T> distinct(@NonNull @NonNull Function<? super @NonNull T,@NonNull K> keySelector)
Returns aFlowable
that emits all items emitted by the currentFlowable
that are distinct according to a key selector function and based onObject.equals(Object)
comparison of the objects returned by the key selector function.It is recommended the keys' class
K
overrides the defaultObject.equals()
andObject.hashCode()
to provide a meaningful comparison between the key objects as the default Java implementation only considers reference equivalence.By default,
distinct()
uses an internalHashSet
perSubscriber
to remember previously seen keys and usesSet.add(Object)
returningfalse
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 toOutOfMemoryError
.Customizing the retention policy can happen only by providing a custom
Collection
implementation to thedistinct(Function, Supplier)
overload.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
distinct
does not operate by default on a particularScheduler
.
- 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
Flowable
instance - Throws:
java.lang.NullPointerException
- ifkeySelector
isnull
- See Also:
- ReactiveX operators documentation: Distinct,
distinct(Function, Supplier)
-
distinct
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull K> @NonNull Flowable<T> distinct(@NonNull @NonNull Function<? super @NonNull T,@NonNull K> keySelector, @NonNull @NonNull Supplier<? extends java.util.Collection<? super @NonNull K>> collectionSupplier)
Returns aFlowable
that emits all items emitted by the currentFlowable
that are distinct according to a key selector function and based onObject.equals(Object)
comparison of the objects returned by the key selector function.It is recommended the keys' class
K
overrides the defaultObject.equals()
andObject.hashCode()
to provide a meaningful comparison between the key objects as the default Java implementation only considers reference equivalence.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
distinct
does not operate by default on a particularScheduler
.
- 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 notcollectionSupplier
- function called for each individualSubscriber
to return aCollection
subtype for holding the extracted keys and whose add() method's return indicates uniqueness.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifkeySelector
orcollectionSupplier
isnull
- See Also:
- ReactiveX operators documentation: Distinct
-
distinctUntilChanged
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> distinctUntilChanged()
Returns aFlowable
that emits all items emitted by the currentFlowable
that are distinct from their immediate predecessors based onObject.equals(Object)
comparison.It is recommended the elements' class
T
in the flow overrides the defaultObject.equals()
to provide a meaningful comparison between items as the default Java implementation only considers reference equivalence. Alternatively, use thedistinctUntilChanged(BiPredicate)
overload and provide a comparison function in case the classT
can't be overridden with customequals()
or the comparison itself should happen on different terms or properties of the classT
.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 mutableCharSequence
s orList
s where the objects will actually have the same references when they are modified anddistinctUntilChanged
will evaluate subsequent items as same. To avoid such situation, it is recommended that mutable data is converted to an immutable one, for example usingmap(CharSequence::toString)
ormap(list -> Collections.unmodifiableList(new ArrayList<>(list)))
.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
distinctUntilChanged
does not operate by default on a particularScheduler
.
- Returns:
- the new
Flowable
instance - See Also:
- ReactiveX operators documentation: Distinct,
distinctUntilChanged(BiPredicate)
-
distinctUntilChanged
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull K> @NonNull Flowable<T> distinctUntilChanged(@NonNull @NonNull Function<? super @NonNull T,@NonNull K> keySelector)
Returns aFlowable
that emits all items emitted by the currentFlowable
that are distinct from their immediate predecessors, according to a key selector function and based onObject.equals(Object)
comparison of those objects returned by the key selector function.It is recommended the keys' class
K
overrides the defaultObject.equals()
to provide a meaningful comparison between the key objects as the default Java implementation only considers reference equivalence. Alternatively, use thedistinctUntilChanged(BiPredicate)
overload and provide a comparison function in case the classK
can't be overridden with customequals()
or the comparison itself should happen on different terms or properties of the item classT
(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 mutableCharSequence
s orList
s where the objects will actually have the same references when they are modified anddistinctUntilChanged
will evaluate subsequent items as same. To avoid such situation, it is recommended that mutable data is converted to an immutable one, for example usingmap(CharSequence::toString)
ormap(list -> Collections.unmodifiableList(new ArrayList<>(list)))
.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
distinctUntilChanged
does not operate by default on a particularScheduler
.
- 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
Flowable
instance - Throws:
java.lang.NullPointerException
- ifkeySelector
isnull
- See Also:
- ReactiveX operators documentation: Distinct
-
distinctUntilChanged
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> distinctUntilChanged(@NonNull @NonNull BiPredicate<? super @NonNull T,? super @NonNull T> comparer)
Returns aFlowable
that emits all items emitted by the currentFlowable
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 mutableCharSequence
s orList
s where the objects will actually have the same references when they are modified anddistinctUntilChanged
will evaluate subsequent items as same. To avoid such situation, it is recommended that mutable data is converted to an immutable one, for example usingmap(CharSequence::toString)
ormap(list -> Collections.unmodifiableList(new ArrayList<>(list)))
.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
distinctUntilChanged
does not operate by default on a particularScheduler
.
- Parameters:
comparer
- the function that receives the previous item and the current item and is expected to returntrue
if the two are equal, thus skipping the current value.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifcomparer
isnull
- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: Distinct
-
doFinally
@CheckReturnValue @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> doFinally(@NonNull @NonNull Action onFinally)
Calls the specified action after thisFlowable
signalsonError
oronComplete
or gets canceled by the downstream.In case of a race between a terminal event and a cancellation, 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.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
doFinally
does not operate by default on a particularScheduler
.- Operator-fusion:
- This operator supports normal and conditional
Subscriber
s as well as boundary-limited synchronous or asynchronous queue-fusion.
History: 2.0.1 - experimental
- Parameters:
onFinally
- the action called when thisFlowable
terminates or gets canceled- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifonFinally
isnull
- Since:
- 2.1
-
doAfterNext
@CheckReturnValue @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<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.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
doAfterNext
does not operate by default on a particularScheduler
.- Operator-fusion:
- This operator supports normal and conditional
Subscriber
s as well as boundary-limited synchronous or asynchronous queue-fusion.
History: 2.0.1 - experimental
- Parameters:
onAfterNext
- theConsumer
that will be called after emitting an item from upstream to the downstream- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifonAfterNext
isnull
- Since:
- 2.1
-
doAfterTerminate
@CheckReturnValue @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> doAfterTerminate(@NonNull @NonNull Action onAfterTerminate)
Registers anAction
to be called when thisPublisher
invokes eitheronComplete
oronError
.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
doAfterTerminate
does not operate by default on a particularScheduler
.
- Parameters:
onAfterTerminate
- anAction
to be invoked when the currentFlowable
finishes- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifonAfterTerminate
isnull
- See Also:
- ReactiveX operators documentation: Do,
doOnTerminate(Action)
-
doOnCancel
@CheckReturnValue @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> doOnCancel(@NonNull @NonNull Action onCancel)
Calls the cancelAction
if the downstream cancels 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
onCancel()
call, sometimes as aCompositeException
if there were multiple exceptions along the way.- Backpressure:
doOnCancel
does not interact with backpressure requests or value delivery; backpressure behavior is preserved between its upstream and its downstream.- Scheduler:
doOnCancel
does not operate by default on a particularScheduler
.
- Parameters:
onCancel
- the action that gets called when the currentFlowable
'sSubscription
is canceled- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifonCancel
isnull
- See Also:
- ReactiveX operators documentation: Do
-
doOnComplete
@CheckReturnValue @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> doOnComplete(@NonNull @NonNull Action onComplete)
Invokes anAction
just before the currentFlowable
callsonComplete
.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
doOnComplete
does not operate by default on a particularScheduler
.
- Parameters:
onComplete
- the action to invoke when the currentFlowable
callsonComplete
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifonComplete
isnull
- See Also:
- ReactiveX operators documentation: Do
-
doOnEach
@CheckReturnValue @NonNull @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") private @NonNull Flowable<T> doOnEach(@NonNull @NonNull Consumer<? super @NonNull T> onNext, @NonNull @NonNull Consumer<? super java.lang.Throwable> onError, Action onComplete, Action onAfterTerminate)
Calls the appropriate onXXX consumer (shared between all subscribers) whenever a signal with the same type passes through, before forwarding them to downstream.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
doOnEach
does not operate by default on a particularScheduler
.
- Parameters:
onNext
- theConsumer
to invoke when the currentFlowable
callsonNext
onError
- theConsumer
to invoke when the currentFlowable
callsonError
onComplete
- theAction
to invoke when the currentFlowable
callsonComplete
onAfterTerminate
- theAction
to invoke when the currentFlowable
callsonAfterTerminate
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifonNext
,onError
,onComplete
oronAfterTerminate
isnull
- See Also:
- ReactiveX operators documentation: Do
-
doOnEach
@CheckReturnValue @NonNull @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") public final @NonNull Flowable<T> doOnEach(@NonNull @NonNull Consumer<? super Notification<@NonNull T>> onNotification)
Invokes aConsumer
with aNotification
instances matching the signals emitted by the currentFlowable
before they are forwarded to the downstream.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
doOnEach
does not operate by default on a particularScheduler
.
- Parameters:
onNotification
- the action to invoke for each item emitted by the currentFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifonNotification
isnull
- See Also:
- ReactiveX operators documentation: Do
-
doOnEach
@CheckReturnValue @NonNull @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") public final @NonNull Flowable<T> doOnEach(@NonNull @NonNull org.reactivestreams.Subscriber<? super @NonNull T> subscriber)
Calls the appropriate methods of the givenSubscriber
when the currentFlowable
signals events before forwarding it to the downstream.In case the
onError
of the suppliedSubscriber
throws, the downstream will receive a composite exception containing the original exception and the exception thrown byonError
. If either theonNext
or theonComplete
method of the suppliedSubscriber
throws, the downstream will be terminated and will receive this thrown exception.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
doOnEach
does not operate by default on a particularScheduler
.
- Parameters:
subscriber
- theSubscriber
to be notified aboutonNext
,onError
andonComplete
events on its respective methods before the actual downstreamSubscriber
gets notified.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsubscriber
isnull
- See Also:
- ReactiveX operators documentation: Do
-
doOnError
@CheckReturnValue @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> doOnError(@NonNull @NonNull Consumer<? super java.lang.Throwable> onError)
Calls the givenConsumer
with the errorThrowable
if the currentFlowable
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 byonError
.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
doOnError
does not operate by default on a particularScheduler
.
- Parameters:
onError
- the action to invoke if the currentFlowable
callsonError
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifonError
isnull
- See Also:
- ReactiveX operators documentation: Do
-
doOnLifecycle
@CheckReturnValue @NonNull @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") public final @NonNull Flowable<T> doOnLifecycle(@NonNull @NonNull Consumer<? super org.reactivestreams.Subscription> onSubscribe, @NonNull @NonNull LongConsumer onRequest, @NonNull @NonNull Action onCancel)
Calls the appropriateonXXX
method (shared between allSubscriber
s) for the lifecycle events of the sequence (subscription, cancellation, requesting).- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
doOnLifecycle
does not operate by default on a particularScheduler
.
- Parameters:
onSubscribe
- aConsumer
called with theSubscription
sent viaSubscriber.onSubscribe(Subscription)
onRequest
- aLongConsumer
called with the request amount sent viaSubscription.request(long)
onCancel
- called when the downstream cancels theSubscription
viaSubscription.cancel()
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifonSubscribe
,onRequest
oronCancel
isnull
- See Also:
- ReactiveX operators documentation: Do
-
doOnNext
@CheckReturnValue @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> doOnNext(@NonNull @NonNull Consumer<? super @NonNull T> onNext)
Calls the givenConsumer
with the value emitted by the currentFlowable
before forwarding it to the downstream.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
doOnNext
does not operate by default on a particularScheduler
.
- Parameters:
onNext
- the action to invoke when the currentFlowable
callsonNext
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifonNext
isnull
- See Also:
- ReactiveX operators documentation: Do,
doAfterNext(Consumer)
-
doOnRequest
@CheckReturnValue @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> doOnRequest(@NonNull @NonNull LongConsumer onRequest)
Calls the givenLongConsumer
with the request amount from the downstream before forwarding it to the currentFlowable
.Note: This operator is for tracing the internal behavior of back-pressure request patterns and generally intended for debugging use.
- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
doOnRequest
does not operate by default on a particularScheduler
.
- Parameters:
onRequest
- the action that gets called when aSubscriber
requests items from the currentFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifonRequest
isnull
- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: Do
-
doOnSubscribe
@CheckReturnValue @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> doOnSubscribe(@NonNull @NonNull Consumer<? super org.reactivestreams.Subscription> onSubscribe)
Calls the givenConsumer
with theSubscription
provided by the currentFlowable
upon subscription from the downstream before forwarding it to the subscriber'sonSubscribe
method.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
doOnSubscribe
does not operate by default on a particularScheduler
.
- Parameters:
onSubscribe
- theConsumer
that gets called when aSubscriber
subscribes to the currentFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifonSubscribe
isnull
- See Also:
- ReactiveX operators documentation: Do
-
doOnTerminate
@CheckReturnValue @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> doOnTerminate(@NonNull @NonNull Action onTerminate)
Calls the givenAction
when the currentFlowable
completes normally or with an error before those signals are forwarded to the downstream.This differs from
doAfterTerminate
in that this happens before theonComplete
oronError
notification.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
doOnTerminate
does not operate by default on a particularScheduler
.
- Parameters:
onTerminate
- the action to invoke when the currentFlowable
callsonComplete
oronError
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifonTerminate
isnull
- See Also:
- ReactiveX operators documentation: Do,
doAfterTerminate(Action)
-
elementAt
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull Maybe<T> elementAt(long index)
Returns aMaybe
that emits the single item at a specified index in a sequence of emissions from thisFlowable
or completes if thisFlowable
sequence has fewer elements than index.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in a bounded manner. - Scheduler:
elementAt
does not operate by default on a particularScheduler
.
- Parameters:
index
- the zero-based index of the item to retrieve- Returns:
- the new
Maybe
instance - Throws:
java.lang.IndexOutOfBoundsException
- ifindex
is negative- See Also:
- ReactiveX operators documentation: ElementAt
-
elementAt
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final @NonNull Single<T> elementAt(long index, @NonNull @NonNull T defaultItem)
Returns aSingle
that emits the item found at a specified index in a sequence of emissions from thisFlowable
, or a default item if that index is out of range.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in a bounded manner. - Scheduler:
elementAt
does not operate by default on a particularScheduler
.
- Parameters:
index
- the zero-based index of the item to retrievedefaultItem
- the default item- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifdefaultItem
isnull
java.lang.IndexOutOfBoundsException
- ifindex
is negative- See Also:
- ReactiveX operators documentation: ElementAt
-
elementAtOrError
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull Single<T> elementAtOrError(long index)
Returns aSingle
that emits the item found at a specified index in a sequence of emissions from thisFlowable
or signals aNoSuchElementException
if thisFlowable
has fewer elements than index.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in a bounded manner. - Scheduler:
elementAtOrError
does not operate by default on a particularScheduler
.
- Parameters:
index
- the zero-based index of the item to retrieve- Returns:
- the new
Single
instance - Throws:
java.lang.IndexOutOfBoundsException
- ifindex
is less than 0- See Also:
- ReactiveX operators documentation: ElementAt
-
filter
@CheckReturnValue @NonNull @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") public final @NonNull Flowable<T> filter(@NonNull @NonNull Predicate<? super @NonNull T> predicate)
Filters items emitted by the currentFlowable
by only emitting those that satisfy a specified predicate.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
filter
does not operate by default on a particularScheduler
.
- Parameters:
predicate
- a function that evaluates each item emitted by the currentFlowable
, returningtrue
if it passes the filter- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifpredicate
isnull
- See Also:
- ReactiveX operators documentation: Filter
-
firstElement
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull Maybe<T> firstElement()
Returns aMaybe
that emits only the very first item emitted by thisFlowable
or completes if thisFlowable
is empty.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in a bounded manner. - Scheduler:
firstElement
does not operate by default on a particularScheduler
.
- Returns:
- the new
Maybe
instance - See Also:
- ReactiveX operators documentation: First
-
first
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull Single<T> first(@NonNull @NonNull T defaultItem)
Returns aSingle
that emits only the very first item emitted by thisFlowable
, or a default item if thisFlowable
completes without emitting anything.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in a bounded manner. - Scheduler:
first
does not operate by default on a particularScheduler
.
- Parameters:
defaultItem
- the default item to emit if the currentFlowable
doesn't emit anything- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifdefaultItem
isnull
- See Also:
- ReactiveX operators documentation: First
-
firstOrError
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull Single<T> firstOrError()
Returns aSingle
that emits only the very first item emitted by thisFlowable
or signals aNoSuchElementException
if thisFlowable
is empty.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in a bounded manner. - Scheduler:
firstOrError
does not operate by default on a particularScheduler
.
- Returns:
- the new
Single
instance - See Also:
- ReactiveX operators documentation: First
-
flatMap
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Flowable<R> flatMap(@NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper)
Returns aFlowable
that emits items based on applying a function that you supply to each item emitted by the currentFlowable
, where that function returns aPublisher
, and then merging those resultingPublisher
s and emitting the results of this merger.- Backpressure:
- The operator honors backpressure from downstream. The upstream
Flowable
is consumed in a bounded manner (up tobufferSize()
outstanding request amount for items). The innerPublisher
s are expected to honor backpressure; if violated, the operator may signalMissingBackpressureException
. - Scheduler:
flatMap
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the value type of the innerPublisher
s and the output type- Parameters:
mapper
- a function that, when applied to an item emitted by the currentFlowable
, returns aPublisher
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMap
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Flowable<R> flatMap(@NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper, boolean delayErrors)
Returns aFlowable
that emits items based on applying a function that you supply to each item emitted by the currentFlowable
, where that function returns aPublisher
, and then merging those resultingPublisher
s and emitting the results of this merger.- Backpressure:
- The operator honors backpressure from downstream. The upstream
Flowable
is consumed in a bounded manner (up tobufferSize()
outstanding request amount for items). The innerPublisher
s are expected to honor backpressure; if violated, the operator may signalMissingBackpressureException
. - Scheduler:
flatMap
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the value type of the innerPublisher
s and the output type- Parameters:
mapper
- a function that, when applied to an item emitted by the currentFlowable
, returns aPublisher
delayErrors
- iftrue
, exceptions from the currentFlowable
and all innerPublisher
s are delayed until all of them terminate iffalse
, the first one signaling an exception will terminate the whole sequence immediately- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMap
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Flowable<R> flatMap(@NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper, int maxConcurrency)
Returns aFlowable
that emits items based on applying a function that you supply to each item emitted by the currentFlowable
, where that function returns aPublisher
, and then merging those resultingPublisher
s and emitting the results of this merger, while limiting the maximum number of concurrent subscriptions to thesePublisher
s.- Backpressure:
- The operator honors backpressure from downstream. The upstream
Flowable
is consumed in a bounded manner (up tomaxConcurrency
outstanding request amount for items). The innerPublisher
s are expected to honor backpressure; if violated, the operator may signalMissingBackpressureException
. - Scheduler:
flatMap
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the value type of the innerPublisher
s and the output type- Parameters:
mapper
- a function that, when applied to an item emitted by the currentFlowable
, returns aPublisher
maxConcurrency
- the maximum number ofPublisher
s that may be subscribed to concurrently- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
is non-positive- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMap
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Flowable<R> flatMap(@NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper, boolean delayErrors, int maxConcurrency)
Returns aFlowable
that emits items based on applying a function that you supply to each item emitted by the currentFlowable
, where that function returns aPublisher
, and then merging those resultingPublisher
s and emitting the results of this merger, while limiting the maximum number of concurrent subscriptions to thesePublisher
s.- Backpressure:
- The operator honors backpressure from downstream. The upstream
Flowable
is consumed in a bounded manner (up tomaxConcurrency
outstanding request amount for items). The innerPublisher
s are expected to honor backpressure; if violated, the operator may signalMissingBackpressureException
. - Scheduler:
flatMap
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the value type of the innerPublisher
s and the output type- Parameters:
mapper
- a function that, when applied to an item emitted by the currentFlowable
, returns aPublisher
maxConcurrency
- the maximum number ofPublisher
s that may be subscribed to concurrentlydelayErrors
- iftrue
, exceptions from the currentFlowable
and all innerPublisher
s are delayed until all of them terminate iffalse
, the first one signaling an exception will terminate the whole sequence immediately- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
is non-positive- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMap
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final <@NonNull R> @NonNull Flowable<R> flatMap(@NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper, boolean delayErrors, int maxConcurrency, int bufferSize)
Returns aFlowable
that emits items based on applying a function that you supply to each item emitted by the currentFlowable
, where that function returns aPublisher
, and then merging those resultingPublisher
s and emitting the results of this merger, while limiting the maximum number of concurrent subscriptions to thesePublisher
s.- Backpressure:
- The operator honors backpressure from downstream. The upstream
Flowable
is consumed in a bounded manner (up tomaxConcurrency
outstanding request amount for items). The innerPublisher
s are expected to honor backpressure; if violated, the operator may signalMissingBackpressureException
. - Scheduler:
flatMap
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the value type of the innerPublisher
s and the output type- Parameters:
mapper
- a function that, when applied to an item emitted by the currentFlowable
, returns aPublisher
maxConcurrency
- the maximum number ofPublisher
s that may be subscribed to concurrentlydelayErrors
- iftrue
, exceptions from the currentFlowable
and all innerPublisher
s are delayed until all of them terminate iffalse
, the first one signaling an exception will terminate the whole sequence immediatelybufferSize
- the number of elements to prefetch from each innerPublisher
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
orbufferSize
is non-positive- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMap
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final <@NonNull R> @NonNull Flowable<R> flatMap(@NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> onNextMapper, @NonNull @NonNull Function<? super java.lang.Throwable,? extends org.reactivestreams.Publisher<? extends @NonNull R>> onErrorMapper, @NonNull @NonNull Supplier<? extends org.reactivestreams.Publisher<? extends @NonNull R>> onCompleteSupplier)
Returns aFlowable
that applies a function to each item emitted or notification raised by the currentFlowable
and then flattens thePublisher
s returned from these functions and emits the resulting items.- Backpressure:
- The operator honors backpressure from downstream. The upstream
Flowable
is consumed in a bounded manner (up tobufferSize()
outstanding request amount for items). The innerPublisher
s are expected to honor backpressure; if violated, the operator may signalMissingBackpressureException
. - Scheduler:
flatMap
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the result type- Parameters:
onNextMapper
- a function that returns aPublisher
to merge for each item emitted by the currentFlowable
onErrorMapper
- a function that returns aPublisher
to merge for anonError
notification from the currentFlowable
onCompleteSupplier
- a function that returns aPublisher
to merge for anonComplete
notification from the currentFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifonNextMapper
,onErrorMapper
oronCompleteSupplier
isnull
- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMap
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final <@NonNull R> @NonNull Flowable<R> flatMap(@NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> onNextMapper, @NonNull @NonNull Function<java.lang.Throwable,? extends org.reactivestreams.Publisher<? extends @NonNull R>> onErrorMapper, @NonNull @NonNull Supplier<? extends org.reactivestreams.Publisher<? extends @NonNull R>> onCompleteSupplier, int maxConcurrency)
Returns aFlowable
that applies a function to each item emitted or notification raised by the currentFlowable
and then flattens thePublisher
s returned from these functions and emits the resulting items, while limiting the maximum number of concurrent subscriptions to thesePublisher
s.- Backpressure:
- The operator honors backpressure from downstream. The upstream
Flowable
is consumed in a bounded manner (up tomaxConcurrency
outstanding request amount for items). The innerPublisher
s are expected to honor backpressure; if violated, the operator may signalMissingBackpressureException
. - Scheduler:
flatMap
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the result type- Parameters:
onNextMapper
- a function that returns aPublisher
to merge for each item emitted by the currentFlowable
onErrorMapper
- a function that returns aPublisher
to merge for anonError
notification from the currentFlowable
onCompleteSupplier
- a function that returns aPublisher
to merge for anonComplete
notification from the currentFlowable
maxConcurrency
- the maximum number ofPublisher
s that may be subscribed to concurrently- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifonNextMapper
,onErrorMapper
oronCompleteSupplier
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
is non-positive- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMap
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull U,@NonNull R> @NonNull Flowable<R> flatMap(@NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull U>> mapper, @NonNull @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> combiner)
Returns aFlowable
that emits the results of a specified function to the pair of values emitted by the currentFlowable
and a specified collectionPublisher
.- Backpressure:
- The operator honors backpressure from downstream. The upstream
Flowable
is consumed in a bounded manner (up tomaxConcurrency
outstanding request amount for items). The innerPublisher
s are expected to honor backpressure; if violated, the operator may signalMissingBackpressureException
. - Scheduler:
flatMap
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the type of items emitted by the innerPublisher
sR
- the type of items emitted by the combiner function- Parameters:
mapper
- a function that returns aPublisher
for each item emitted by the currentFlowable
combiner
- a function that combines one item emitted by each of the source and collectionPublisher
s and returns an item to be emitted by the resultingFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
orcombiner
isnull
- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMap
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull U,@NonNull R> @NonNull Flowable<R> flatMap(@NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull U>> mapper, @NonNull @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> combiner, boolean delayErrors)
Returns aFlowable
that emits the results of a specified function to the pair of values emitted by the currentFlowable
and a specified innerPublisher
.- Backpressure:
- The operator honors backpressure from downstream. The upstream
Flowable
is consumed in a bounded manner (up tobufferSize()
outstanding request amount for items). The innerPublisher
s are expected to honor backpressure; if violated, the operator may signalMissingBackpressureException
. - Scheduler:
flatMap
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the type of items emitted by the innerPublisher
sR
- the type of items emitted by the combiner functions- Parameters:
mapper
- a function that returns aPublisher
for each item emitted by the currentFlowable
combiner
- a function that combines one item emitted by each of the source and collectionPublisher
s and returns an item to be emitted by the resultingFlowable
delayErrors
- iftrue
, exceptions from the currentFlowable
and all innerPublisher
s are delayed until all of them terminate iffalse
, the first one signaling an exception will terminate the whole sequence immediately- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
orcombiner
isnull
- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMap
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull U,@NonNull R> @NonNull Flowable<R> flatMap(@NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull U>> mapper, @NonNull @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> combiner, boolean delayErrors, int maxConcurrency)
Returns aFlowable
that emits the results of a specified function to the pair of values emitted by the currentFlowable
and a specified collectionPublisher
, while limiting the maximum number of concurrent subscriptions to thesePublisher
s.- Backpressure:
- The operator honors backpressure from downstream. The upstream
Flowable
is consumed in a bounded manner (up tomaxConcurrency
outstanding request amount for items). The innerPublisher
s are expected to honor backpressure; if violated, the operator may signalMissingBackpressureException
. - Scheduler:
flatMap
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the type of items emitted by the innerPublisher
sR
- the type of items emitted by the combiner function- Parameters:
mapper
- a function that returns aPublisher
for each item emitted by the currentFlowable
combiner
- a function that combines one item emitted by each of the source and collectionPublisher
s and returns an item to be emitted by the resultingFlowable
maxConcurrency
- the maximum number ofPublisher
s that may be subscribed to concurrentlydelayErrors
- iftrue
, exceptions from the currentFlowable
and all innerPublisher
s are delayed until all of them terminate iffalse
, the first one signaling an exception will terminate the whole sequence immediately- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
orcombiner
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
is non-positive- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMap
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final <@NonNull U,@NonNull R> @NonNull Flowable<R> flatMap(@NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull U>> mapper, @NonNull @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> combiner, boolean delayErrors, int maxConcurrency, int bufferSize)
Returns aFlowable
that emits the results of a specified function to the pair of values emitted by the currentFlowable
and a specified collectionPublisher
, while limiting the maximum number of concurrent subscriptions to thesePublisher
s.- Backpressure:
- The operator honors backpressure from downstream. The upstream
Flowable
is consumed in a bounded manner (up tomaxConcurrency
outstanding request amount for items). The innerPublisher
s are expected to honor backpressure; if violated, the operator may signalMissingBackpressureException
. - Scheduler:
flatMap
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the type of items emitted by the innerPublisher
sR
- the type of items emitted by the combiner function- Parameters:
mapper
- a function that returns aPublisher
for each item emitted by the currentFlowable
combiner
- a function that combines one item emitted by each of the source and collectionPublisher
s and returns an item to be emitted by the resultingFlowable
maxConcurrency
- the maximum number ofPublisher
s that may be subscribed to concurrentlydelayErrors
- iftrue
, exceptions from the currentFlowable
and all innerPublisher
s are delayed until all of them terminate iffalse
, the first one signaling an exception will terminate the whole sequence immediatelybufferSize
- the number of elements to prefetch from the innerPublisher
s.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
orcombiner
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
orbufferSize
is non-positive- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMap
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull U,@NonNull R> @NonNull Flowable<R> flatMap(@NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull U>> mapper, @NonNull @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> combiner, int maxConcurrency)
Returns aFlowable
that emits the results of a specified function to the pair of values emitted by the currentFlowable
and a specified collectionPublisher
, while limiting the maximum number of concurrent subscriptions to thesePublisher
s.- Backpressure:
- The operator honors backpressure from downstream. The upstream
Flowable
is consumed in a bounded manner (up tobufferSize()
outstanding request amount for items). The innerPublisher
s are expected to honor backpressure; if violated, the operator may signalMissingBackpressureException
. - Scheduler:
flatMap
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the type of items emitted by the innerPublisher
sR
- the type of items emitted by the combiner function- Parameters:
mapper
- a function that returns aPublisher
for each item emitted by the currentFlowable
combiner
- a function that combines one item emitted by each of the source and collectionPublisher
s and returns an item to be emitted by the resultingFlowable
maxConcurrency
- the maximum number ofPublisher
s that may be subscribed to concurrently- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
orcombiner
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
is non-positive- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMapCompletable
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final @NonNull Completable flatMapCompletable(@NonNull @NonNull Function<? super @NonNull T,? extends CompletableSource> mapper)
Maps each element of the upstreamFlowable
intoCompletableSource
s, subscribes to them and waits until the upstream and allCompletableSource
s complete.- Backpressure:
- The operator consumes the upstream in an unbounded manner.
- Scheduler:
flatMapCompletable
does not operate by default on a particularScheduler
.
- Parameters:
mapper
- the function that received each source value and transforms them intoCompletableSource
s.- Returns:
- the new
Completable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
-
flatMapCompletable
@CheckReturnValue @NonNull @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") public final @NonNull Completable flatMapCompletable(@NonNull @NonNull Function<? super @NonNull T,? extends CompletableSource> mapper, boolean delayErrors, int maxConcurrency)
Maps each element of the upstreamFlowable
intoCompletableSource
s, subscribes to them and waits until the upstream and allCompletableSource
s complete, optionally delaying all errors.- Backpressure:
- If
maxConcurrency ==
Integer.MAX_VALUE
the operator consumes the upstream in an unbounded manner. Otherwise, the operator expects the upstream to honor backpressure. If the upstream doesn't support backpressure the operator behaves as ifmaxConcurrency ==
Integer.MAX_VALUE
was used. - Scheduler:
flatMapCompletable
does not operate by default on a particularScheduler
.
- Parameters:
mapper
- the function that received each source value and transforms them intoCompletableSource
s.delayErrors
- iftrue
, errors from the upstream and innerCompletableSource
s are delayed until each of them terminates.maxConcurrency
- the maximum number of active subscriptions to theCompletableSource
s.- Returns:
- the new
Completable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
is non-positive
-
flatMapIterable
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull U> @NonNull Flowable<U> flatMapIterable(@NonNull @NonNull Function<? super @NonNull T,? extends java.lang.Iterable<? extends @NonNull U>> mapper)
MergesIterable
s generated by a mapperFunction
for each individual item emitted by the currentFlowable
into a singleFlowable
sequence.- Backpressure:
- The operator honors backpressure from downstream. The current
Flowable
s is expected to honor backpressure as well. If the currentFlowable
violates the rule, the operator will signal aMissingBackpressureException
. - Scheduler:
flatMapIterable
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the output type and the element type of theIterable
s- Parameters:
mapper
- a function that returns anIterable
sequence of values for when given an item emitted by the currentFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMapIterable
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final <@NonNull U> @NonNull Flowable<U> flatMapIterable(@NonNull @NonNull Function<? super @NonNull T,? extends java.lang.Iterable<? extends @NonNull U>> mapper, int bufferSize)
MergesIterable
s generated by a mapperFunction
for each individual item emitted by the currentFlowable
into a singleFlowable
sequence.- Backpressure:
- The operator honors backpressure from downstream. The current
Flowable
s is expected to honor backpressure as well. If the currentFlowable
violates the rule, the operator will signal aMissingBackpressureException
. - Scheduler:
flatMapIterable
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the type of item emitted by the resultingIterable
- Parameters:
mapper
- a function that returns anIterable
sequence of values for when given an item emitted by the currentFlowable
bufferSize
- the number of elements to prefetch from the currentFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMapIterable
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final <@NonNull U,@NonNull V> @NonNull Flowable<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)
MergesIterable
s generated by a mapperFunction
for each individual item emitted by the currentFlowable
into a singleFlowable
sequence where the resulting items will be the combination of the original item and each inner item of the respectiveIterable
as returned by theresultSelector
BiFunction
.- Backpressure:
- The operator honors backpressure from downstream and the current
Flowable
s is consumed in a bounded manner (requestingbufferSize()
items upfront, then 75% of it after 75% received). - Scheduler:
flatMapIterable
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the element type of theIterable
sV
- the output type as determined by theresultSelector
function- Parameters:
mapper
- a function that returns anIterable
sequence of values for each item emitted by the currentFlowable
combiner
- a function that returns an item based on the item emitted by the currentFlowable
and theIterable
returned for that item by thecollectionSelector
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
orcombiner
isnull
- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMapIterable
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final <@NonNull U,@NonNull V> @NonNull Flowable<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, int prefetch)
MergesIterable
s generated by a mapperFunction
for each individual item emitted by the currentFlowable
into a singleFlowable
sequence where the resulting items will be the combination of the original item and each inner item of the respectiveIterable
as returned by theresultSelector
BiFunction
.- Backpressure:
- The operator honors backpressure from downstream. The current
Flowable
s is expected to honor backpressure as well. If the currentFlowable
violates the rule, the operator will signal aMissingBackpressureException
. - Scheduler:
flatMapIterable
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the element type of the innerIterable
sequencesV
- the type of item emitted by the resultingFlowable
- Parameters:
mapper
- a function that returns anIterable
sequence of values for when given an item emitted by the currentFlowable
combiner
- a function that returns an item based on the item emitted by the currentFlowable
and theIterable
returned for that item by thecollectionSelector
prefetch
- the number of elements to prefetch from the currentFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
orcombiner
isnull
java.lang.IllegalArgumentException
- ifprefetch
is non-positive- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: FlatMap
-
flatMapMaybe
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Flowable<R> flatMapMaybe(@NonNull @NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper)
Maps each element of the upstreamFlowable
intoMaybeSource
s, subscribes to all of them and merges theironSuccess
values, in no particular order, into a singleFlowable
sequence.- Backpressure:
- The operator consumes the upstream in an unbounded manner.
- Scheduler:
flatMapMaybe
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the result value type- Parameters:
mapper
- the function that received each source value and transforms them intoMaybeSource
s.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
-
flatMapMaybe
@CheckReturnValue @NonNull @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") public final <@NonNull R> @NonNull Flowable<R> flatMapMaybe(@NonNull @NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper, boolean delayErrors, int maxConcurrency)
Maps each element of the upstreamFlowable
intoMaybeSource
s, subscribes to at mostmaxConcurrency
MaybeSource
s at a time and merges theironSuccess
values, in no particular order, into a singleFlowable
sequence, optionally delaying all errors.- Backpressure:
- If
maxConcurrency ==
Integer.MAX_VALUE
the operator consumes the upstream in an unbounded manner. Otherwise, the operator expects the upstream to honor backpressure. If the upstream doesn't support backpressure the operator behaves as ifmaxConcurrency ==
Integer.MAX_VALUE
was used. - Scheduler:
flatMapMaybe
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the result value type- Parameters:
mapper
- the function that received each source value and transforms them intoMaybeSource
s.delayErrors
- iftrue
, errors from the upstream and innerMaybeSource
s are delayed until each of them terminates.maxConcurrency
- the maximum number of active subscriptions to theMaybeSource
s.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
is non-positive
-
flatMapSingle
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Flowable<R> flatMapSingle(@NonNull @NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper)
Maps each element of the upstreamFlowable
intoSingleSource
s, subscribes to all of them and merges theironSuccess
values, in no particular order, into a singleFlowable
sequence.- Backpressure:
- The operator consumes the upstream in an unbounded manner.
- Scheduler:
flatMapSingle
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the result value type- Parameters:
mapper
- the function that received each source value and transforms them intoSingleSource
s.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
-
flatMapSingle
@CheckReturnValue @NonNull @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") public final <@NonNull R> @NonNull Flowable<R> flatMapSingle(@NonNull @NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper, boolean delayErrors, int maxConcurrency)
Maps each element of the upstreamFlowable
intoSingleSource
s, subscribes to at mostmaxConcurrency
SingleSource
s at a time and merges theironSuccess
values, in no particular order, into a singleFlowable
sequence, optionally delaying all errors.- Backpressure:
- If
maxConcurrency ==
Integer.MAX_VALUE
the operator consumes the upstream in an unbounded manner. Otherwise, the operator expects the upstream to honor backpressure. If the upstream doesn't support backpressure the operator behaves as ifmaxConcurrency ==
Integer.MAX_VALUE
was used. - Scheduler:
flatMapSingle
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the result value type- Parameters:
mapper
- the function that received each source value and transforms them intoSingleSource
s.delayErrors
- iftrue
, errors from the upstream and innerSingleSources
are delayed until each of them terminates.maxConcurrency
- the maximum number of active subscriptions to theSingleSource
s.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifmaxConcurrency
is non-positive
-
forEach
@CheckReturnValue @BackpressureSupport(NONE) @SchedulerSupport("none") @NonNull public final @NonNull Disposable forEach(@NonNull @NonNull Consumer<? super @NonNull T> onNext)
Subscribes to the currentFlowable
and receives notifications for each element.Alias to
subscribe(Consumer)
- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner (i.e., no backpressure is applied to it). - Scheduler:
forEach
does not operate by default on a particularScheduler
.
- Parameters:
onNext
-Consumer
to execute for each item.- Returns:
- a
Disposable
that allows canceling an asynchronous sequence - Throws:
java.lang.NullPointerException
- ifonNext
isnull
- See Also:
- ReactiveX operators documentation: Subscribe
-
forEachWhile
@CheckReturnValue @BackpressureSupport(NONE) @SchedulerSupport("none") @NonNull public final @NonNull Disposable forEachWhile(@NonNull @NonNull Predicate<? super @NonNull T> onNext)
Subscribes to the currentFlowable
and receives notifications for each element until theonNext
Predicate returnsfalse
.If the
Flowable
emits an error, it is wrapped into anOnErrorNotImplementedException
and routed to theRxJavaPlugins.onError(Throwable)
handler.- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner (i.e., no backpressure is applied to it). - Scheduler:
forEachWhile
does not operate by default on a particularScheduler
.
- Parameters:
onNext
-Predicate
to execute for each item.- Returns:
- a
Disposable
that allows canceling an asynchronous sequence - Throws:
java.lang.NullPointerException
- ifonNext
isnull
- See Also:
- ReactiveX operators documentation: Subscribe
-
forEachWhile
@CheckReturnValue @BackpressureSupport(NONE) @SchedulerSupport("none") @NonNull public final @NonNull Disposable forEachWhile(@NonNull @NonNull Predicate<? super @NonNull T> onNext, @NonNull @NonNull Consumer<? super java.lang.Throwable> onError)
Subscribes to the currentFlowable
and receives notifications for each element and error events until theonNext
Predicate returnsfalse
.- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner (i.e., no backpressure is applied to it). - Scheduler:
forEachWhile
does not operate by default on a particularScheduler
.
- Parameters:
onNext
-Predicate
to execute for each item.onError
-Consumer
to execute when an error is emitted.- Returns:
- a
Disposable
that allows canceling an asynchronous sequence - Throws:
java.lang.NullPointerException
- ifonNext
oronError
isnull
- See Also:
- ReactiveX operators documentation: Subscribe
-
forEachWhile
@CheckReturnValue @NonNull @BackpressureSupport(NONE) @SchedulerSupport("none") public final @NonNull Disposable forEachWhile(@NonNull @NonNull Predicate<? super @NonNull T> onNext, @NonNull @NonNull Consumer<? super java.lang.Throwable> onError, @NonNull @NonNull Action onComplete)
Subscribes to the currentFlowable
and receives notifications for each element and the terminal events until theonNext
Predicate returnsfalse
.- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner (i.e., no backpressure is applied to it). - Scheduler:
forEachWhile
does not operate by default on a particularScheduler
.
- Parameters:
onNext
-Predicate
to execute for each item.onError
-Consumer
to execute when an error is emitted.onComplete
-Action
to execute when completion is signaled.- Returns:
- a
Disposable
that allows canceling an asynchronous sequence - Throws:
java.lang.NullPointerException
- ifonNext
,onError
oronComplete
isnull
- See Also:
- ReactiveX operators documentation: Subscribe
-
groupBy
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("none") @NonNull public final <@NonNull K> @NonNull Flowable<GroupedFlowable<K,T>> groupBy(@NonNull @NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector)
Groups the items emitted by the currentFlowable
according to a specified criterion, and emits these grouped items asGroupedFlowable
s. The emittedGroupedFlowable
allows only a singleSubscriber
during its lifetime and if thisSubscriber
cancels before the source terminates, the next emission by the source having the same key will trigger a newGroupedFlowable
emission.Note: A
GroupedFlowable
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 thoseGroupedFlowable
s that do not concern you. Instead, you can signal to them that they may discard their buffers by applying an operator likeignoreElements()
to them.Note that the
GroupedFlowable
s should be subscribed to as soon as possible, otherwise, the unconsumed groups may starve other groups due to the internal backpressure coordination of thegroupBy
operator. Such hangs can be usually avoided by usingflatMap(Function, int)
orconcatMapEager(Function, int, int)
and overriding the default maximum concurrency value to be greater or equal to the expected number of groups, possibly usingInteger.MAX_VALUE
if the number of expected groups is unknown.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.
- Backpressure:
- The consumer of the returned
Flowable
has to be ready to receive newGroupedFlowable
s or else this operator will signalMissingBackpressureException
. To avoid this exception, make sure a combining operator (such asflatMap
) has adequate amount of buffering/prefetch configured. The innerGroupedFlowable
s honor backpressure but due to the single-source multiple consumer nature of this operator, each group must be consumed so the whole operator can make progress and not hang. - Scheduler:
groupBy
does not operate by default on a particularScheduler
.- Error handling:
- If the upstream signals or the callback(s) throw an exception, the returned
Flowable
and all active innerGroupedFlowable
s will signal the same exception.
- Type Parameters:
K
- the key type- Parameters:
keySelector
- a function that extracts the key for each item- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifkeySelector
isnull
- See Also:
- ReactiveX operators documentation: GroupBy,
groupBy(Function, boolean)
,groupBy(Function, Function)
-
groupBy
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("none") @NonNull public final <@NonNull K> @NonNull Flowable<GroupedFlowable<K,T>> groupBy(@NonNull @NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector, boolean delayError)
Groups the items emitted by the currentFlowable
according to a specified criterion, and emits these grouped items asGroupedFlowable
s. The emittedGroupedFlowable
allows only a singleSubscriber
during its lifetime and if thisSubscriber
cancels before the source terminates, the next emission by the source having the same key will trigger a newGroupedFlowable
emission.Note: A
GroupedFlowable
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 thoseGroupedFlowable
s that do not concern you. Instead, you can signal to them that they may discard their buffers by applying an operator likeignoreElements()
to them.Note that the
GroupedFlowable
s should be subscribed to as soon as possible, otherwise, the unconsumed groups may starve other groups due to the internal backpressure coordination of thegroupBy
operator. Such hangs can be usually avoided by usingflatMap(Function, int)
orconcatMapEager(Function, int, int)
and overriding the default maximum concurrency value to be greater or equal to the expected number of groups, possibly usingInteger.MAX_VALUE
if the number of expected groups is unknown.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.
- Backpressure:
- The consumer of the returned
Flowable
has to be ready to receive newGroupedFlowable
s or else this operator will signalMissingBackpressureException
. To avoid this exception, make sure a combining operator (such asflatMap
) has adequate amount of buffering/prefetch configured. The innerGroupedFlowable
s honor backpressure but due to the single-source multiple consumer nature of this operator, each group must be consumed so the whole operator can make progress and not hang. - Scheduler:
groupBy
does not operate by default on a particularScheduler
.- Error handling:
- If the upstream signals or the callback(s) throw an exception, the returned
Flowable
and all active innerGroupedFlowable
s will signal the same exception.
- Type Parameters:
K
- the key type- Parameters:
keySelector
- a function that extracts the key for each itemdelayError
- iftrue
, the exception from the currentFlowable
is delayed in each group until that specific group emitted the normal values; iffalse
, the exception bypasses values in the groups and is reported immediately.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifkeySelector
isnull
- See Also:
- ReactiveX operators documentation: GroupBy
-
groupBy
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("none") @NonNull public final <@NonNull K,@NonNull V> @NonNull Flowable<GroupedFlowable<K,V>> groupBy(@NonNull @NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector, @NonNull @NonNull Function<? super @NonNull T,? extends @NonNull V> valueSelector)
Groups the items emitted by the currentFlowable
according to a specified criterion, and emits these grouped items asGroupedFlowable
s. The emittedGroupedFlowable
allows only a singleSubscriber
during its lifetime and if thisSubscriber
cancels before the source terminates, the next emission by the source having the same key will trigger a newGroupedFlowable
emission.Note: A
GroupedFlowable
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 thoseGroupedFlowable
s that do not concern you. Instead, you can signal to them that they may discard their buffers by applying an operator likeignoreElements()
to them.Note that the
GroupedFlowable
s should be subscribed to as soon as possible, otherwise, the unconsumed groups may starve other groups due to the internal backpressure coordination of thegroupBy
operator. Such hangs can be usually avoided by usingflatMap(Function, int)
orconcatMapEager(Function, int, int)
and overriding the default maximum concurrency value to be greater or equal to the expected number of groups, possibly usingInteger.MAX_VALUE
if the number of expected groups is unknown.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.
- Backpressure:
- The consumer of the returned
Flowable
has to be ready to receive newGroupedFlowable
s or else this operator will signalMissingBackpressureException
. To avoid this exception, make sure a combining operator (such asflatMap
) has adequate amount of buffering/prefetch configured. The innerGroupedFlowable
s honor backpressure but due to the single-source multiple consumer nature of this operator, each group must be consumed so the whole operator can make progress and not hang. - Scheduler:
groupBy
does not operate by default on a particularScheduler
.- Error handling:
- If the upstream signals or the callback(s) throw an exception, the returned
Flowable
and all active innerGroupedFlowable
s will signal the same exception.
- Type Parameters:
K
- the key typeV
- the element type- Parameters:
keySelector
- a function that extracts the key for each itemvalueSelector
- a function that extracts the return element for each item- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifkeySelector
orvalueSelector
isnull
- See Also:
- ReactiveX operators documentation: GroupBy,
groupBy(Function, Function, boolean)
,groupBy(Function, Function, boolean, int)
,groupBy(Function, Function, boolean, int, Function)
-
groupBy
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("none") @NonNull public final <@NonNull K,@NonNull V> @NonNull Flowable<GroupedFlowable<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 currentFlowable
according to a specified criterion, and emits these grouped items asGroupedFlowable
s. The emittedGroupedFlowable
allows only a singleSubscriber
during its lifetime and if thisSubscriber
cancels before the source terminates, the next emission by the source having the same key will trigger a newGroupedFlowable
emission.Note: A
GroupedFlowable
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 thoseGroupedFlowable
s that do not concern you. Instead, you can signal to them that they may discard their buffers by applying an operator likeignoreElements()
to them.Note that the
GroupedFlowable
s should be subscribed to as soon as possible, otherwise, the unconsumed groups may starve other groups due to the internal backpressure coordination of thegroupBy
operator. Such hangs can be usually avoided by usingflatMap(Function, int)
orconcatMapEager(Function, int, int)
and overriding the default maximum concurrency value to be greater or equal to the expected number of groups, possibly usingInteger.MAX_VALUE
if the number of expected groups is unknown.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.
- Backpressure:
- The consumer of the returned
Flowable
has to be ready to receive newGroupedFlowable
s or else this operator will signalMissingBackpressureException
. To avoid this exception, make sure a combining operator (such asflatMap
) has adequate amount of buffering/prefetch configured. The innerGroupedFlowable
s honor backpressure but due to the single-source multiple consumer nature of this operator, each group must be consumed so the whole operator can make progress and not hang. - Scheduler:
groupBy
does not operate by default on a particularScheduler
.- Error handling:
- If the upstream signals or the callback(s) throw an exception, the returned
Flowable
and all active innerGroupedFlowable
s will signal the same exception.
- Type Parameters:
K
- the key typeV
- the element type- Parameters:
keySelector
- a function that extracts the key for each itemvalueSelector
- a function that extracts the return element for each itemdelayError
- iftrue
, the exception from the currentFlowable
is delayed in each group until that specific group emitted the normal values; iffalse
, the exception bypasses values in the groups and is reported immediately.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifkeySelector
orvalueSelector
isnull
- See Also:
- ReactiveX operators documentation: GroupBy,
groupBy(Function, Function, boolean, int)
-
groupBy
@CheckReturnValue @NonNull @BackpressureSupport(SPECIAL) @SchedulerSupport("none") public final <@NonNull K,@NonNull V> @NonNull Flowable<GroupedFlowable<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 currentFlowable
according to a specified criterion, and emits these grouped items asGroupedFlowable
s. The emittedGroupedFlowable
allows only a singleSubscriber
during its lifetime and if thisSubscriber
cancels before the source terminates, the next emission by the source having the same key will trigger a newGroupedFlowable
emission.Note: A
GroupedFlowable
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 thoseGroupedFlowable
s that do not concern you. Instead, you can signal to them that they may discard their buffers by applying an operator likeignoreElements()
to them.Note that the
GroupedFlowable
s should be subscribed to as soon as possible, otherwise, the unconsumed groups may starve other groups due to the internal backpressure coordination of thegroupBy
operator. Such hangs can be usually avoided by usingflatMap(Function, int)
orconcatMapEager(Function, int, int)
and overriding the default maximum concurrency value to be greater or equal to the expected number of groups, possibly usingInteger.MAX_VALUE
if the number of expected groups is unknown.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.
- Backpressure:
- The consumer of the returned
Flowable
has to be ready to receive newGroupedFlowable
s or else this operator will signalMissingBackpressureException
. To avoid this exception, make sure a combining operator (such asflatMap
) has adequate amount of buffering/prefetch configured. The innerGroupedFlowable
s honor backpressure but due to the single-source multiple consumer nature of this operator, each group must be consumed so the whole operator can make progress and not hang. - Scheduler:
groupBy
does not operate by default on a particularScheduler
.- Error handling:
- If the upstream signals or the callback(s) throw an exception, the returned
Flowable
and all active innerGroupedFlowable
s will signal the same exception.
- Type Parameters:
K
- the key typeV
- the element type- Parameters:
keySelector
- a function that extracts the key for each itemvalueSelector
- a function that extracts the return element for each itemdelayError
- iftrue
, the exception from the currentFlowable
is delayed in each group until that specific group emitted the normal values; iffalse
, the exception bypasses values in the groups and is reported immediately.bufferSize
- the hint for how manyGroupedFlowable
s and element in eachGroupedFlowable
should be buffered- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifkeySelector
orvalueSelector
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: GroupBy
-
groupBy
@CheckReturnValue @NonNull @BackpressureSupport(SPECIAL) @SchedulerSupport("none") public final <@NonNull K,@NonNull V> @NonNull Flowable<GroupedFlowable<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, @NonNull @NonNull Function<? super Consumer<java.lang.Object>,? extends java.util.Map<@NonNull K,java.lang.Object>> evictingMapFactory)
Groups the items emitted by the currentFlowable
according to a specified criterion, and emits these grouped items asGroupedFlowable
s. The emittedGroupedFlowable
allows only a singleSubscriber
during its lifetime and if thisSubscriber
cancels before the source terminates, the next emission by the source having the same key will trigger a newGroupedFlowable
emission. TheevictingMapFactory
is used to create a map that will be used to hold theGroupedFlowable
s by key. The evicting map created by this factory must notify the providedConsumer<Object>
with the entry value (not the key!) when an entry in this map has been evicted. The next source emission will bring about the completion of the evictedGroupedFlowable
s and the arrival of an item with the same key as a completedGroupedFlowable
will prompt the creation and emission of a newGroupedFlowable
with that key.A use case for specifying an
evictingMapFactory
is where the source is infinite and fast and over time the number of keys grows enough to be a concern in terms of the memory footprint of the internal hash map containing theGroupedFlowable
s.The map created by an
evictingMapFactory
must be thread-safe.An example of an
evictingMapFactory
using CacheBuilder from the Guava library is below:Function<Consumer<Object>, Map<Integer, Object>> evictingMapFactory = notify -> CacheBuilder .newBuilder() .maximumSize(3) .removalListener(entry -> { try { // emit the value not the key! notify.accept(entry.getValue()); } catch (Exception e) { throw new RuntimeException(e); } }) .<Integer, Object> build() .asMap(); // Emit 1000 items but ensure that the // internal map never has more than 3 items in it Flowable .range(1, 1000) // note that number of keys is 10 .groupBy(x -> x % 10, x -> x, true, 16, evictingMapFactory) .flatMap(g -> g) .forEach(System.out::println);
Note: A
GroupedFlowable
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 thoseGroupedFlowable
s that do not concern you. Instead, you can signal to them that they may discard their buffers by applying an operator likeignoreElements()
to them.Note that the
GroupedFlowable
s should be subscribed to as soon as possible, otherwise, the unconsumed groups may starve other groups due to the internal backpressure coordination of thegroupBy
operator. Such hangs can be usually avoided by usingflatMap(Function, int)
orconcatMapEager(Function, int, int)
and overriding the default maximum concurrency value to be greater or equal to the expected number of groups, possibly usingInteger.MAX_VALUE
if the number of expected groups is unknown.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.
- Backpressure:
- The consumer of the returned
Flowable
has to be ready to receive newGroupedFlowable
s or else this operator will signalMissingBackpressureException
. To avoid this exception, make sure a combining operator (such asflatMap
) has adequate amount of buffering/prefetch configured. The innerGroupedFlowable
s honor backpressure but due to the single-source multiple consumer nature of this operator, each group must be consumed so the whole operator can make progress and not hang. - Scheduler:
groupBy
does not operate by default on a particularScheduler
.- Error handling:
- If the upstream signals or the callback(s) throw an exception, the returned
Flowable
and all active innerGroupedFlowable
s will signal the same exception.
History: 2.1.10 - beta
- Type Parameters:
K
- the key typeV
- the element type- Parameters:
keySelector
- a function that extracts the key for each itemvalueSelector
- a function that extracts the return element for each itemdelayError
- iftrue
, the exception from the currentFlowable
is delayed in each group until that specific group emitted the normal values; iffalse
, the exception bypasses values in the groups and is reported immediately.bufferSize
- the hint for how manyGroupedFlowable
s and element in eachGroupedFlowable
should be bufferedevictingMapFactory
- The factory used to create a map that will be used by the implementation to hold theGroupedFlowable
s. The evicting map created by this factory must notify the providedConsumer<Object>
with the entry value (not the key!) when an entry in this map has been evicted. The next source emission will bring about the completion of the evictedGroupedFlowable
s. See example above.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifkeySelector
,valueSelector
orevictingMapFactory
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- Since:
- 2.2
- See Also:
- ReactiveX operators documentation: GroupBy
-
groupJoin
@CheckReturnValue @NonNull @BackpressureSupport(ERROR) @SchedulerSupport("none") public final <@NonNull TRight,@NonNull TLeftEnd,@NonNull TRightEnd,@NonNull R> @NonNull Flowable<R> groupJoin(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull TRight> other, @NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<@NonNull TLeftEnd>> leftEnd, @NonNull @NonNull Function<? super @NonNull TRight,? extends org.reactivestreams.Publisher<@NonNull TRightEnd>> rightEnd, @NonNull @NonNull BiFunction<? super @NonNull T,? super Flowable<@NonNull TRight>,? extends @NonNull R> resultSelector)
Returns aFlowable
that correlates twoPublisher
s 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
Publisher
s overlap.- Backpressure:
- The operator doesn't support backpressure and consumes all participating
Publisher
s in an unbounded mode (i.e., not applying any backpressure to them). - Scheduler:
groupJoin
does not operate by default on a particularScheduler
.
- Type Parameters:
TRight
- the value type of the rightPublisher
sourceTLeftEnd
- the element type of the left durationPublisher
sTRightEnd
- the element type of the right durationPublisher
sR
- the result type- Parameters:
other
- the otherPublisher
to correlate items from the currentFlowable
withleftEnd
- a function that returns aPublisher
whose emissions indicate the duration of the values of the currentFlowable
rightEnd
- a function that returns aPublisher
whose emissions indicate the duration of the values of theright
Publisher
resultSelector
- a function that takes an item emitted by eachPublisher
and returns the value to be emitted by the resultingFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifother
,leftEnd
,rightEnd
orresultSelector
isnull
- See Also:
- ReactiveX operators documentation: Join
-
hide
@CheckReturnValue @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> hide()
Hides the identity of thisFlowable
and itsSubscription
.Allows hiding extra features such as
Processor
'sSubscriber
methods or preventing certain identity-based optimizations (fusion).- Backpressure:
- The operator is a pass-through for backpressure, the behavior is determined by the upstream's backpressure behavior.
- Scheduler:
hide
does not operate by default on a particularScheduler
.
- Returns:
- the new
Flowable
instance - Since:
- 2.0
-
ignoreElements
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final @NonNull Completable ignoreElements()
Ignores all items emitted by the currentFlowable
and only callsonComplete
oronError
.- Backpressure:
- This operator ignores backpressure as it doesn't emit any elements and consumes the current
Flowable
in an unbounded manner (i.e., no backpressure is applied to it). - Scheduler:
ignoreElements
does not operate by default on a particularScheduler
.
- Returns:
- the new
Completable
instance - See Also:
- ReactiveX operators documentation: IgnoreElements
-
isEmpty
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final @NonNull Single<java.lang.Boolean> isEmpty()
Returns aSingle
that emitstrue
if the currentFlowable
is empty, otherwisefalse
.In Rx.Net this is negated as the
any
Subscriber
but we renamed this in RxJava to better match Java naming idioms.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., without applying backpressure). - Scheduler:
isEmpty
does not operate by default on a particularScheduler
.
- Returns:
- the new
Single
instance - See Also:
- ReactiveX operators documentation: Contains
-
join
@CheckReturnValue @NonNull @BackpressureSupport(ERROR) @SchedulerSupport("none") public final <@NonNull TRight,@NonNull TLeftEnd,@NonNull TRightEnd,@NonNull R> @NonNull Flowable<R> join(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull TRight> other, @NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<@NonNull TLeftEnd>> leftEnd, @NonNull @NonNull Function<? super @NonNull TRight,? extends org.reactivestreams.Publisher<@NonNull TRightEnd>> rightEnd, @NonNull @NonNull BiFunction<? super @NonNull T,? super @NonNull TRight,? extends @NonNull R> resultSelector)
Correlates the items emitted by twoPublisher
s based on overlapping durations.There are no guarantees in what order the items get combined when multiple items from one or both source
Publisher
s overlap.- Backpressure:
- The operator doesn't support backpressure and consumes all participating
Publisher
s in an unbounded mode (i.e., not applying any backpressure to them). - Scheduler:
join
does not operate by default on a particularScheduler
.
- Type Parameters:
TRight
- the value type of the rightPublisher
sourceTLeftEnd
- the element type of the left durationPublisher
sTRightEnd
- the element type of the right durationPublisher
sR
- the result type- Parameters:
other
- the secondPublisher
to join items fromleftEnd
- a function to select a duration for each item emitted by the currentFlowable
, used to determine overlaprightEnd
- a function to select a duration for each item emitted by theright
Publisher
, used to determine overlapresultSelector
- a function that computes an item to be emitted by the resultingFlowable
for any two overlapping items emitted by the twoPublisher
s- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifother
,leftEnd
,rightEnd
orresultSelector
isnull
- See Also:
- ReactiveX operators documentation: Join
-
lastElement
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final @NonNull Maybe<T> lastElement()
Returns aMaybe
that emits the last item emitted by thisFlowable
or completes if thisFlowable
is empty.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., without applying backpressure). - Scheduler:
lastElement
does not operate by default on a particularScheduler
.
- Returns:
- the new
Maybe
instance - See Also:
- ReactiveX operators documentation: Last
-
last
@CheckReturnValue @NonNull @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") public final @NonNull Single<T> last(@NonNull @NonNull T defaultItem)
Returns aSingle
that emits only the last item emitted by thisFlowable
, or a default item if thisFlowable
completes without emitting any items.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., without applying backpressure). - Scheduler:
last
does not operate by default on a particularScheduler
.
- Parameters:
defaultItem
- the default item to emit if the currentFlowable
is empty- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifdefaultItem
isnull
- See Also:
- ReactiveX operators documentation: Last
-
lastOrError
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final @NonNull Single<T> lastOrError()
Returns aSingle
that emits only the last item emitted by thisFlowable
or signals aNoSuchElementException
if thisFlowable
is empty.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., without applying backpressure). - Scheduler:
lastOrError
does not operate by default on a particularScheduler
.
- Returns:
- the new
Single
instance - See Also:
- ReactiveX operators documentation: Last
-
lift
@CheckReturnValue @NonNull @BackpressureSupport(SPECIAL) @SchedulerSupport("none") public final <@NonNull R> @NonNull Flowable<R> lift(@NonNull @NonNull FlowableOperator<? extends @NonNull R,? super @NonNull T> lifter)
This method requires advanced knowledge about building operators, please consider other standard composition methods first; Returns aFlowable
which, when subscribed to, invokes theapply(Subscriber)
method of the providedFlowableOperator
for each individual downstreamSubscriber
and allows the insertion of a custom operator by accessing the downstream'sSubscriber
during this subscription phase and providing a newSubscriber
, containing the custom operator's intended business logic, that will be used in the subscription process going further upstream.Generally, such a new
Subscriber
will wrap the downstream'sSubscriber
and forwards theonNext
,onError
andonComplete
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 ofcancel
andrequest
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 FlowableOperator.apply(): public final class CustomSubscriber<T> implements FlowableSubscriber<T>, Subscription { // The downstream's Subscriber that will receive the onXXX events final Subscriber<? super String> downstream; // The connection to the upstream source that will call this class' onXXX methods Subscription upstream; // The constructor takes the downstream subscriber and usually any other parameters public CustomSubscriber(Subscriber<? super String> downstream) { this.downstream = downstream; } // In the subscription phase, the upstream sends a Subscription to this class // and subsequently this class has to send a Subscription to the downstream. // Note that relaying the upstream's Subscription instance directly is not allowed in RxJava @Override public void onSubscribe(Subscription s) { if (upstream != null) { s.cancel(); } else { upstream = s; 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); } else { upstream.request(1); } } // 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 have to intercept the downstream's request calls to trigger // the emission of queued items while others can simply forward the request // amount as is. @Override public void request(long n) { upstream.request(n); } // Some operators may use their own resources which should be cleaned up if // the downstream cancels the flow before it completed. Operators without // resources can simply forward the cancellation to the upstream. // In some cases, a canceled flag may be set by this method so that other parts // of this class may detect the cancellation and stop sending events // to the downstream. @Override public void cancel() { upstream.cancel(); } } // Step 2: Create a class that implements the FlowableOperator 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 FlowableOperator<String> { @Override public Subscriber<? super String> apply(Subscriber<? super T> upstream) { return new CustomSubscriber<T>(upstream); } } // Step 3: Apply the custom operator via lift() in a flow by creating an instance of it // or reusing an existing one. Flowable.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 abstractFlowable
class and creating aFlowableTransformer
with it is recommended.Note also that it is not possible to stop the subscription phase in
lift()
as theapply()
method requires a non-null
Subscriber
instance to be returned, which is then unconditionally subscribed to the upstreamFlowable
. 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 aSubscriber
that should immediately cancel the upstream'sSubscription
in itsonSubscribe
method. Again, using aFlowableTransformer
and extending theFlowable
is a better option assubscribeActual(org.reactivestreams.Subscriber<? super T>)
can decide to not subscribe to its upstream after all.- Backpressure:
- The
Subscriber
instance returned by theFlowableOperator
is responsible to be backpressure-aware or document the fact that the consumer of the returnedPublisher
has to apply one of theonBackpressureXXX
operators. - Scheduler:
lift
does not operate by default on a particularScheduler
, however, theFlowableOperator
may use aScheduler
to support its own asynchronous behavior.
- Type Parameters:
R
- the output value type- Parameters:
lifter
- theFlowableOperator
that receives the downstream'sSubscriber
and should return aSubscriber
with custom behavior to be used as the consumer for the currentFlowable
.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- iflifter
isnull
- See Also:
- RxJava wiki: Writing operators,
compose(FlowableTransformer)
-
map
@CheckReturnValue @NonNull @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") public final <@NonNull R> @NonNull Flowable<R> map(@NonNull @NonNull Function<? super @NonNull T,? extends @NonNull R> mapper)
Returns aFlowable
that applies a specified function to each item emitted by the currentFlowable
and emits the results of these function applications.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
map
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the output type- Parameters:
mapper
- a function to apply to each item emitted by the currentFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- See Also:
- ReactiveX operators documentation: Map,
mapOptional(Function)
-
materialize
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<Notification<T>> materialize()
Returns aFlowable
that represents all of the emissions and notifications from the currentFlowable
into emissions marked with their original types withinNotification
objects.- Backpressure:
- The operator honors backpressure from downstream and expects it from the current
Flowable
. If this expectation is violated, the operator may throw anIllegalStateException
. - Scheduler:
materialize
does not operate by default on a particularScheduler
.
- Returns:
- the new
Flowable
instance - See Also:
- ReactiveX operators documentation: Materialize,
dematerialize(Function)
-
mergeWith
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final @NonNull Flowable<T> mergeWith(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> other)
Flattens this and anotherPublisher
into a singlePublisher
, without any transformation.You can combine items emitted by multiple
Publisher
s so that they appear as a singlePublisher
, by using themergeWith
method.- Backpressure:
- The operator honors backpressure from downstream. This and the other
Publisher
s are expected to honor backpressure; if violated, the operator may signalMissingBackpressureException
. - Scheduler:
mergeWith
does not operate by default on a particularScheduler
.
- Parameters:
other
- aPublisher
to be merged- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifother
isnull
- See Also:
- ReactiveX operators documentation: Merge
-
mergeWith
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final @NonNull Flowable<T> mergeWith(@NonNull @NonNull SingleSource<? extends @NonNull T> other)
Merges the sequence of items of thisFlowable
with the success value of the otherSingleSource
.The success value of the other
SingleSource
can get interleaved at any point of thisFlowable
sequence.- Backpressure:
- The operator honors backpressure from downstream and ensures the success item from the
SingleSource
is emitted only when there is a downstream demand. - Scheduler:
mergeWith
does not operate by default on a particularScheduler
.
History: 2.1.10 - experimental
- Parameters:
other
- theSingleSource
whose success value to merge with- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifother
isnull
- Since:
- 2.2
-
mergeWith
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final @NonNull Flowable<T> mergeWith(@NonNull @NonNull MaybeSource<? extends @NonNull T> other)
Merges the sequence of items of thisFlowable
with the success value of the otherMaybeSource
or waits for both to complete normally if theMaybeSource
is empty.The success value of the other
MaybeSource
can get interleaved at any point of thisFlowable
sequence.- Backpressure:
- The operator honors backpressure from downstream and ensures the success item from the
MaybeSource
is emitted only when there is a downstream demand. - Scheduler:
mergeWith
does not operate by default on a particularScheduler
.
History: 2.1.10 - experimental
- Parameters:
other
- theMaybeSource
which provides a success value to merge with or completes- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifother
isnull
- Since:
- 2.2
-
mergeWith
@CheckReturnValue @NonNull @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") public final @NonNull Flowable<T> mergeWith(@NonNull @NonNull CompletableSource other)
Relays the items of thisFlowable
and completes only when the otherCompletableSource
completes as well.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
mergeWith
does not operate by default on a particularScheduler
.
History: 2.1.10 - experimental
- Parameters:
other
- theCompletableSource
to await for completion- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifother
isnull
- Since:
- 2.2
-
observeOn
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("custom") @NonNull public final @NonNull Flowable<T> observeOn(@NonNull @NonNull Scheduler scheduler)
Signals the items and terminal signals of the currentFlowable
on the specifiedScheduler
, asynchronously with a bounded buffer ofbufferSize()
slots.Note that
onError
notifications will cut ahead ofonNext
notifications on the emission thread ifScheduler
is truly asynchronous. If strict event ordering is required, consider using theobserveOn(Scheduler, boolean)
overload.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.- Backpressure:
- This operator honors backpressure from downstream and expects it from the current
Flowable
. Violating this expectation will lead toMissingBackpressureException
. This is the most common operator where the exception pops up; look for sources up the chain that don't support backpressure, such asinterval(long, TimeUnit)
,timer(long, TimeUnit)
,PublishProcessor
orBehaviorProcessor
and apply any of theonBackpressureXXX
operators before applyingobserveOn
itself. Note also that request amounts are not preserved between the immediate downstream and the immediate upstream. The operator always requests the defaultbufferSize()
amount first, then after every 75% of that amount delivered, another 75% of this default value. If preserving the request amounts is to be preferred over potential excess scheduler infrastructure use, consider applyingdelay(long, TimeUnit, Scheduler)
with zero time instead. - Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
scheduler
- theScheduler
to notifySubscriber
s on- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifscheduler
isnull
- See Also:
- ReactiveX operators documentation: ObserveOn,
RxJava Threading Examples,
subscribeOn(io.reactivex.rxjava3.core.Scheduler)
,observeOn(Scheduler, boolean)
,observeOn(Scheduler, boolean, int)
,delay(long, TimeUnit, Scheduler)
-
observeOn
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("custom") @NonNull public final @NonNull Flowable<T> observeOn(@NonNull @NonNull Scheduler scheduler, boolean delayError)
Signals the items and terminal signals of the currentFlowable
on the specifiedScheduler
, asynchronously with a bounded buffer and optionally delaysonError
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.- Backpressure:
- This operator honors backpressure from downstream and expects it from the current
Flowable
. Violating this expectation will lead toMissingBackpressureException
. This is the most common operator where the exception pops up; look for sources up the chain that don't support backpressure, such asinterval(long, TimeUnit)
,timer(long, TimeUnit)
,PublishProcessor
orBehaviorProcessor
and apply any of theonBackpressureXXX
operators before applyingobserveOn
itself. Note also that request amounts are not preserved between the immediate downstream and the immediate upstream. The operator always requests the defaultbufferSize()
amount first, then after every 75% of that amount delivered, another 75% of this default value. If preserving the request amounts is to be preferred over potential excess scheduler infrastructure use, consider applyingdelay(long, TimeUnit, Scheduler, boolean)
with zero time instead. - Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
scheduler
- theScheduler
to notifySubscriber
s ondelayError
- indicates if theonError
notification may not cut ahead ofonNext
notification on the other side of the scheduling boundary. Iftrue
, a sequence ending inonError
will be replayed in the same order as was received from upstream- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifscheduler
isnull
- 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 @NonNull @BackpressureSupport(FULL) @SchedulerSupport("custom") public final @NonNull Flowable<T> observeOn(@NonNull @NonNull Scheduler scheduler, boolean delayError, int bufferSize)
Signals the items and terminal signals of the currentFlowable
on the specifiedScheduler
, asynchronously with a bounded buffer of configurable size and optionally delaysonError
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.- Backpressure:
- This operator honors backpressure from downstream and expects it from the current
Flowable
. Violating this expectation will lead toMissingBackpressureException
. This is the most common operator where the exception pops up; look for sources up the chain that don't support backpressure, such asinterval(long, TimeUnit)
,timer(long, TimeUnit)
,PublishProcessor
orBehaviorProcessor
and apply any of theonBackpressureXXX
operators before applyingobserveOn
itself. Note also that request amounts are not preserved between the immediate downstream and the immediate upstream. The operator always requests the specifiedbufferSize
amount first, then after every 75% of that amount delivered, another 75% of this specified value. If preserving the request amounts is to be preferred over potential excess scheduler infrastructure use, consider applyingdelay(long, TimeUnit, Scheduler, boolean)
with zero time instead. - Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
scheduler
- theScheduler
to notifySubscriber
s ondelayError
- indicates if theonError
notification may not cut ahead ofonNext
notification on the other side of the scheduling boundary. Iftrue
, a sequence ending inonError
will be replayed in the same order as was received from upstreambufferSize
- the size of the buffer.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifscheduler
isnull
java.lang.IllegalArgumentException
- ifbufferSize
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)
-
ofType
@CheckReturnValue @NonNull @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") public final <@NonNull U> @NonNull Flowable<U> ofType(@NonNull @NonNull java.lang.Class<@NonNull U> clazz)
Filters the items emitted by the currentFlowable
, only emitting those of the specified type.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
ofType
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the output type- Parameters:
clazz
- the class type to filter the items emitted by the currentFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifclazz
isnull
- See Also:
- ReactiveX operators documentation: Filter
-
onBackpressureBuffer
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> onBackpressureBuffer()
Buffers an unlimited number of items from the currentFlowable
and allows it to emit as fast it can while allowing the downstream to consume the items at its own place.An error from the current
Flowable
will cut ahead of any unconsumed item. UseonBackpressureBuffer(boolean)
to have the operator keep the original signal order.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., not applying backpressure to it). - Scheduler:
onBackpressureBuffer
does not operate by default on a particularScheduler
.
- Returns:
- the new
Flowable
instance - See Also:
- ReactiveX operators documentation: backpressure operators,
onBackpressureBuffer(boolean)
-
onBackpressureBuffer
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> onBackpressureBuffer(boolean delayError)
Buffers an unlimited number of items from the currentFlowable
and allows it to emit as fast it can while allowing the downstream to consume the items at its own place, optionally delaying an error until all buffered items have been consumed.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., not applying backpressure to it). - Scheduler:
onBackpressureBuffer
does not operate by default on a particularScheduler
.
- Parameters:
delayError
- iftrue
, an exception from the currentFlowable
is delayed until all buffered elements have been consumed by the downstream; iffalse
, an exception is immediately signaled to the downstream, skipping any buffered element- Returns:
- the new
Flowable
instance - See Also:
- ReactiveX operators documentation: backpressure operators
-
onBackpressureBuffer
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> onBackpressureBuffer(int capacity)
Buffers an limited number of items from the currentFlowable
and allows it to emit as fast it can while allowing the downstream to consume the items at its own place, however, the resultingFlowable
will signal aMissingBackpressureException
viaonError
as soon as the buffer's capacity is exceeded, dropping all undelivered items, and canceling the flow.An error from the current
Flowable
will cut ahead of any unconsumed item. UseonBackpressureBuffer(int, boolean)
to have the operator keep the original signal order.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., not applying backpressure to it). - Scheduler:
onBackpressureBuffer
does not operate by default on a particularScheduler
.
- Parameters:
capacity
- number of slots available in the buffer.- Returns:
- the new
Flowable
instance - Throws:
java.lang.IllegalArgumentException
- ifcapacity
is non-positive- Since:
- 1.1.0
- See Also:
- ReactiveX operators documentation: backpressure operators,
onBackpressureBuffer(long, Action, BackpressureOverflowStrategy)
-
onBackpressureBuffer
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> onBackpressureBuffer(int capacity, boolean delayError)
Buffers an limited number of items from the currentFlowable
and allows it to emit as fast it can while allowing the downstream to consume the items at its own place, however, the resultingFlowable
will signal aMissingBackpressureException
viaonError
as soon as the buffer's capacity is exceeded, dropping all undelivered items, and canceling the flow.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., not applying backpressure to it). - Scheduler:
onBackpressureBuffer
does not operate by default on a particularScheduler
.
- Parameters:
capacity
- number of slots available in the buffer.delayError
- iftrue
, an exception from the currentFlowable
is delayed until all buffered elements have been consumed by the downstream; iffalse
, an exception is immediately signaled to the downstream, skipping any buffered element- Returns:
- the new
Flowable
instance - Throws:
java.lang.IllegalArgumentException
- ifcapacity
is non-positive- Since:
- 1.1.0
- See Also:
- ReactiveX operators documentation: backpressure operators
-
onBackpressureBuffer
@CheckReturnValue @BackpressureSupport(SPECIAL) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> onBackpressureBuffer(int capacity, boolean delayError, boolean unbounded)
Buffers an optionally unlimited number of items from the currentFlowable
and allows it to emit as fast it can while allowing the downstream to consume the items at its own place. Ifunbounded
istrue
, the resultingFlowable
will signal aMissingBackpressureException
viaonError
as soon as the buffer's capacity is exceeded, dropping all undelivered items, and canceling the flow.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., not applying backpressure to it). - Scheduler:
onBackpressureBuffer
does not operate by default on a particularScheduler
.
- Parameters:
capacity
- number of slots available in the buffer.delayError
- iftrue
, an exception from the currentFlowable
is delayed until all buffered elements have been consumed by the downstream; iffalse
, an exception is immediately signaled to the downstream, skipping any buffered elementunbounded
- iftrue
, the capacity value is interpreted as the internal "island" size of the unbounded buffer- Returns:
- the new
Flowable
instance - Throws:
java.lang.IllegalArgumentException
- ifcapacity
is non-positive- Since:
- 1.1.0
- See Also:
- ReactiveX operators documentation: backpressure operators
-
onBackpressureBuffer
@CheckReturnValue @NonNull @BackpressureSupport(SPECIAL) @SchedulerSupport("none") public final @NonNull Flowable<T> onBackpressureBuffer(int capacity, boolean delayError, boolean unbounded, @NonNull @NonNull Action onOverflow)
Buffers an optionally unlimited number of items from the currentFlowable
and allows it to emit as fast it can while allowing the downstream to consume the items at its own place. Ifunbounded
istrue
, the resultingFlowable
will signal aMissingBackpressureException
viaonError
as soon as the buffer's capacity is exceeded, dropping all undelivered items, canceling the flow and calling theonOverflow
action.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., not applying backpressure to it). - Scheduler:
onBackpressureBuffer
does not operate by default on a particularScheduler
.
- Parameters:
capacity
- number of slots available in the buffer.delayError
- iftrue
, an exception from the currentFlowable
is delayed until all buffered elements have been consumed by the downstream; iffalse
, an exception is immediately signaled to the downstream, skipping any buffered elementunbounded
- iftrue
, the capacity value is interpreted as the internal "island" size of the unbounded bufferonOverflow
- action to execute if an item needs to be buffered, but there are no available slots.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifonOverflow
isnull
java.lang.IllegalArgumentException
- ifcapacity
is non-positive- Since:
- 1.1.0
- See Also:
- ReactiveX operators documentation: backpressure operators,
onBackpressureBuffer(int, boolean, boolean, Action, Consumer)
-
onBackpressureBuffer
@CheckReturnValue @NonNull @BackpressureSupport(SPECIAL) @SchedulerSupport("none") public final @NonNull Flowable<T> onBackpressureBuffer(int capacity, boolean delayError, boolean unbounded, @NonNull @NonNull Action onOverflow, @NonNull @NonNull Consumer<? super @NonNull T> onDropped)
Buffers an optionally unlimited number of items from the currentFlowable
and allows it to emit as fast it can while allowing the downstream to consume the items at its own place. Ifunbounded
istrue
, the resultingFlowable
will signal aMissingBackpressureException
viaonError
as soon as the buffer's capacity is exceeded, dropping all undelivered items, canceling the flow and calling theonOverflow
action.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., not applying backpressure to it). - Scheduler:
onBackpressureBuffer
does not operate by default on a particularScheduler
.
- Parameters:
capacity
- number of slots available in the buffer.delayError
- iftrue
, an exception from the currentFlowable
is delayed until all buffered elements have been consumed by the downstream; iffalse
, an exception is immediately signaled to the downstream, skipping any buffered elementunbounded
- iftrue
, the capacity value is interpreted as the internal "island" size of the unbounded bufferonOverflow
- action to execute if an item needs to be buffered, but there are no available slots.onDropped
- theConsumer
to be called with the item that could not be buffered due to capacity constraints.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifonOverflow
oronDropped
isnull
java.lang.IllegalArgumentException
- ifcapacity
is non-positive- Since:
- 3.1.7
- See Also:
- ReactiveX operators documentation: backpressure operators
-
onBackpressureBuffer
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> onBackpressureBuffer(int capacity, @NonNull @NonNull Action onOverflow)
Buffers an limited number of items from the currentFlowable
and allows it to emit as fast it can while allowing the downstream to consume the items at its own place, however, the resultingFlowable
will signal aMissingBackpressureException
viaonError
as soon as the buffer's capacity is exceeded, dropping all undelivered items, canceling the flow and calling theonOverflow
action.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., not applying backpressure to it). - Scheduler:
onBackpressureBuffer
does not operate by default on a particularScheduler
.
- Parameters:
capacity
- number of slots available in the buffer.onOverflow
- action to execute if an item needs to be buffered, but there are no available slots. Null is allowed.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifonOverflow
isnull
java.lang.IllegalArgumentException
- ifcapacity
is non-positive- Since:
- 1.1.0
- See Also:
- ReactiveX operators documentation: backpressure operators
-
onBackpressureBuffer
@CheckReturnValue @NonNull @BackpressureSupport(SPECIAL) @SchedulerSupport("none") public final @NonNull Flowable<T> onBackpressureBuffer(long capacity, @Nullable @Nullable Action onOverflow, @NonNull @NonNull BackpressureOverflowStrategy overflowStrategy)
Buffers an optionally unlimited number of items from the currentFlowable
and allows it to emit as fast it can while allowing the downstream to consume the items at its own place. The resultingFlowable
will behave as determined byoverflowStrategy
if the buffer capacity is exceeded:BackpressureOverflowStrategy.ERROR
(default) will callonError
dropping all undelivered items, canceling the source, and notifying the producer withonOverflow
.BackpressureOverflowStrategy.DROP_LATEST
will drop any new items emitted by the producer while the buffer is full, without generating anyonError
. Each drop will, however, invokeonOverflow
to signal the overflow to the producer.BackpressureOverflowStrategy.DROP_OLDEST
will drop the oldest items in the buffer in order to make room for newly emitted ones. Overflow will not generate anonError
, but each drop will invokeonOverflow
to signal the overflow to the producer.
- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., not applying backpressure to it). - Scheduler:
onBackpressureBuffer
does not operate by default on a particularScheduler
.
- Parameters:
capacity
- number of slots available in the buffer.onOverflow
- action to execute if an item needs to be buffered, but there are no available slots,null
is allowed.overflowStrategy
- how should the resultingFlowable
react to buffer overflows,null
is not allowed.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifonOverflow
oroverflowStrategy
isnull
java.lang.IllegalArgumentException
- ifcapacity
is non-positive- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: backpressure operators,
onBackpressureBuffer(long, Action, BackpressureOverflowStrategy)
-
onBackpressureBuffer
@CheckReturnValue @NonNull @BackpressureSupport(SPECIAL) @SchedulerSupport("none") public final @NonNull Flowable<T> onBackpressureBuffer(long capacity, @Nullable @Nullable Action onOverflow, @NonNull @NonNull BackpressureOverflowStrategy overflowStrategy, @NonNull @NonNull Consumer<? super @NonNull T> onDropped)
Buffers an optionally unlimited number of items from the currentFlowable
and allows it to emit as fast it can while allowing the downstream to consume the items at its own place. The resultingFlowable
will behave as determined byoverflowStrategy
if the buffer capacity is exceeded:BackpressureOverflowStrategy.ERROR
(default) will callonError
dropping all undelivered items, canceling the source, and notifying the producer withonOverflow
.BackpressureOverflowStrategy.DROP_LATEST
will drop any new items emitted by the producer while the buffer is full, without generating anyonError
. Each drop will, however, invokeonOverflow
to signal the overflow to the producer.BackpressureOverflowStrategy.DROP_OLDEST
will drop the oldest items in the buffer in order to make room for newly emitted ones. Overflow will not generate anonError
, but each drop will invokeonOverflow
to signal the overflow to the producer.
- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., not applying backpressure to it). - Scheduler:
onBackpressureBuffer
does not operate by default on a particularScheduler
.
- Parameters:
capacity
- number of slots available in the buffer.onOverflow
- action to execute if an item needs to be buffered, but there are no available slots,null
is allowed.overflowStrategy
- how should the resultingFlowable
react to buffer overflows,null
is not allowed.onDropped
- theConsumer
to be called with the item that could not be buffered due to capacity constraints.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifonOverflow
,overflowStrategy
oronDropped
isnull
java.lang.IllegalArgumentException
- ifcapacity
is non-positive- Since:
- 3.1.7
- See Also:
- ReactiveX operators documentation: backpressure operators
-
onBackpressureDrop
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> onBackpressureDrop()
Drops items from the currentFlowable
if the downstream is not ready to receive new items (indicated by a lack ofSubscription.request(long)
calls from it).If the downstream request count hits 0 then the resulting
Flowable
will refrain from callingonNext
until theSubscriber
invokesrequest(n)
again to increase the request count.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., not applying backpressure to it). - Scheduler:
onBackpressureDrop
does not operate by default on a particularScheduler
.
- Returns:
- the new
Flowable
instance - See Also:
- ReactiveX operators documentation: backpressure operators
-
onBackpressureDrop
@CheckReturnValue @NonNull @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") public final @NonNull Flowable<T> onBackpressureDrop(@NonNull @NonNull Consumer<? super @NonNull T> onDrop)
Drops items from the currentFlowable
if the downstream is not ready to receive new items (indicated by a lack ofSubscription.request(long)
calls from it) and calls the givenConsumer
with such dropped items.If the downstream request count hits 0 then the resulting
Flowable
will refrain from callingonNext
until theSubscriber
invokesrequest(n)
again to increase the request count.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., not applying backpressure to it). - Scheduler:
onBackpressureDrop
does not operate by default on a particularScheduler
.
- Parameters:
onDrop
- the action to invoke for each item dropped, should be fast and should never block.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifonDrop
isnull
- Since:
- 1.1.0
- See Also:
- ReactiveX operators documentation: backpressure operators
-
onBackpressureLatest
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> onBackpressureLatest()
Drops all but the latest item emitted by the currentFlowable
if the downstream is not ready to receive new items (indicated by a lack ofSubscription.request(long)
calls from it) and emits this latest item when the downstream becomes ready.Its behavior is logically equivalent to
blockingLatest()
with the exception that the downstream is not blocking while requesting more values.Note that if the current
Flowable
does support backpressure, this operator ignores that capability and doesn't propagate any backpressure requests from downstream.Note that due to the nature of how backpressure requests are propagated through subscribeOn/observeOn, requesting more than 1 from downstream doesn't guarantee a continuous delivery of
onNext
events.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., not applying backpressure to it). - Scheduler:
onBackpressureLatest
does not operate by default on a particularScheduler
.
- Returns:
- the new
Flowable
instance - Since:
- 1.1.0
-
onBackpressureLatest
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> onBackpressureLatest(@NonNull @NonNull Consumer<? super @NonNull T> onDropped)
Drops all but the latest item emitted by the currentFlowable
if the downstream is not ready to receive new items (indicated by a lack ofSubscription.request(long)
calls from it) and emits this latest item when the downstream becomes ready.Its behavior is logically equivalent to
blockingLatest()
with the exception that the downstream is not blocking while requesting more values.Note that if the current
Flowable
does support backpressure, this operator ignores that capability and doesn't propagate any backpressure requests from downstream.Note that due to the nature of how backpressure requests are propagated through subscribeOn/observeOn, requesting more than 1 from downstream doesn't guarantee a continuous delivery of
onNext
events.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., not applying backpressure to it). - Scheduler:
onBackpressureLatest
does not operate by default on a particularScheduler
.
- Parameters:
onDropped
- called with the current entry when it has been replaced by a new one- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifonDropped
isnull
- Since:
- 3.1.7
-
onBackpressureReduce
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> onBackpressureReduce(@NonNull @NonNull BiFunction<@NonNull T,@NonNull T,@NonNull T> reducer)
Reduces a sequence of two not emitted values via a function into a single value if the downstream is not ready to receive new items (indicated by a lack ofSubscription.request(long)
calls from it) and emits this latest item when the downstream becomes ready.Note that if the current
Flowable
does support backpressure, this operator ignores that capability and doesn't propagate any backpressure requests from downstream.Note that due to the nature of how backpressure requests are propagated through subscribeOn/observeOn, requesting more than 1 from downstream doesn't guarantee a continuous delivery of
onNext
events.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., not applying backpressure to it). - Scheduler:
onBackpressureReduce
does not operate by default on a particularScheduler
.
History: 3.0.9 - experimental
- Parameters:
reducer
- the bi-function to call when there is more than one non-emitted value to downstream, the first argument of the bi-function is previous item and the second one is currently emitting from upstream- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifreducer
isnull
- Since:
- 3.1.0
- See Also:
onBackpressureReduce(Supplier, BiFunction)
-
onBackpressureReduce
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Flowable<R> onBackpressureReduce(@NonNull @NonNull Supplier<@NonNull R> supplier, @NonNull @NonNull BiFunction<@NonNull R,? super @NonNull T,@NonNull R> reducer)
Reduces upstream values into an aggregate value, provided by a supplier and combined via a reducer function, while the downstream is not ready to receive items, then emits this aggregate value when the downstream becomes ready.Note that even if the downstream is ready to receive an item, the upstream item will always be aggregated into the output type, calling both the supplier and the reducer to produce the output value.
Note that if the current
Flowable
does support backpressure, this operator ignores that capability and doesn't propagate any backpressure requests from downstream.Note that due to the nature of how backpressure requests are propagated through subscribeOn/observeOn, requesting more than 1 from downstream doesn't guarantee a continuous delivery of
onNext
events.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., not applying backpressure to it). - Scheduler:
onBackpressureReduce
does not operate by default on a particularScheduler
.
History: 3.0.9 - experimental
- Type Parameters:
R
- the aggregate type emitted when the downstream requests more items- Parameters:
supplier
- the factory to call to create new item of type R to pass it as the first argument toreducer
. It is called when previous returned value byreducer
already sent to downstream or the very first update from upstream received.reducer
- the bi-function to call to reduce excessive updates which downstream is not ready to receive. The first argument of type R is the object returned bysupplier
or result of previousreducer
invocation. The second argument of type T is the current update from upstream.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsupplier
orreducer
isnull
- Since:
- 3.1.0
- See Also:
onBackpressureReduce(BiFunction)
-
onErrorComplete
@CheckReturnValue @SchedulerSupport("none") @BackpressureSupport(PASS_THROUGH) @NonNull public final @NonNull Flowable<T> onErrorComplete()
Returns aFlowable
instance that if the currentFlowable
emits an error, it will emit anonComplete
and swallow the throwable.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
onErrorComplete
does not operate by default on a particularScheduler
.
- Returns:
- the new
Flowable
instance - Since:
- 3.0.0
-
onErrorComplete
@CheckReturnValue @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> onErrorComplete(@NonNull @NonNull Predicate<? super java.lang.Throwable> predicate)
Returns aFlowable
instance that if the currentFlowable
emits an error and the predicate returnstrue
, it will emit anonComplete
and swallow the throwable.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
onErrorComplete
does not operate by default on a particularScheduler
.
- Parameters:
predicate
- the predicate to call when anThrowable
is emitted which should returntrue
if theThrowable
should be swallowed and replaced with anonComplete
.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifpredicate
isnull
- Since:
- 3.0.0
-
onErrorResumeNext
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final @NonNull Flowable<T> onErrorResumeNext(@NonNull @NonNull Function<? super java.lang.Throwable,? extends org.reactivestreams.Publisher<? extends @NonNull T>> fallbackSupplier)
Resumes the flow with aPublisher
returned for the failureThrowable
of the currentFlowable
by a function instead of signaling the error viaonError
.By default, when a
Publisher
encounters an error that prevents it from emitting the expected item to itsSubscriber
, thePublisher
invokes itsSubscriber
'sonError
method, and then quits without invoking any more of itsSubscriber
's methods. TheonErrorResumeNext
method changes this behavior. If you pass a function that returns aPublisher
(resumeFunction
) toonErrorResumeNext
, if the originalPublisher
encounters an error, instead of invoking itsSubscriber
'sonError
method, it will instead relinquish control to thePublisher
returned fromresumeFunction
, which will invoke theSubscriber
'sonNext
method if it is able to do so. In such a case, because noPublisher
necessarily invokesonError
, theSubscriber
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.
- Backpressure:
- The operator honors backpressure from downstream. This and the resuming
Publisher
s are expected to honor backpressure as well. If any of them violate this expectation, the operator may throw anIllegalStateException
when the currentFlowable
completes or aMissingBackpressureException
is signaled somewhere downstream. - Scheduler:
onErrorResumeNext
does not operate by default on a particularScheduler
.
- Parameters:
fallbackSupplier
- a function that returns aPublisher
that will take over if the currentFlowable
encounters an error- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- iffallbackSupplier
isnull
- See Also:
- ReactiveX operators documentation: Catch
-
onErrorResumeWith
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final @NonNull Flowable<T> onErrorResumeWith(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> fallback)
Resumes the flow with the givenPublisher
when the currentFlowable
fails instead of signaling the error viaonError
.By default, when a
Publisher
encounters an error that prevents it from emitting the expected item to itsSubscriber
, thePublisher
invokes itsSubscriber
'sonError
method, and then quits without invoking any more of itsSubscriber
's methods. TheonErrorResumeWith
method changes this behavior. If you pass anotherPublisher
(resumeSequence
) to aPublisher
'sonErrorResumeWith
method, if the originalPublisher
encounters an error, instead of invoking itsSubscriber
'sonError
method, it will instead relinquish control toresumeSequence
which will invoke theSubscriber
'sonNext
method if it is able to do so. In such a case, because noPublisher
necessarily invokesonError
, theSubscriber
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.
- Backpressure:
- The operator honors backpressure from downstream. This and the resuming
Publisher
s are expected to honor backpressure as well. If any of them violate this expectation, the operator may throw anIllegalStateException
when the currentFlowable
completes orMissingBackpressureException
is signaled somewhere downstream. - Scheduler:
onErrorResumeWith
does not operate by default on a particularScheduler
.
- Parameters:
fallback
- the nextPublisher
source that will take over if the currentFlowable
encounters an error- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- iffallback
isnull
- See Also:
- ReactiveX operators documentation: Catch
-
onErrorReturn
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final @NonNull Flowable<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 theThrowable
error signaled by the currentFlowable
instead of signaling the error viaonError
.By default, when a
Publisher
encounters an error that prevents it from emitting the expected item to itsSubscriber
, thePublisher
invokes itsSubscriber
'sonError
method, and then quits without invoking any more of itsSubscriber
's methods. TheonErrorReturn
method changes this behavior. If you pass a function (resumeFunction
) to aPublisher
'sonErrorReturn
method, if the originalPublisher
encounters an error, instead of invoking itsSubscriber
'sonError
method, it will instead emit the return value ofresumeFunction
.You can use this to prevent errors from propagating or to supply fallback data should errors be encountered.
- Backpressure:
- The operator honors backpressure from downstream. The current
Flowable
is expected to honor backpressure as well. If it this expectation is violated, the operator may throwIllegalStateException
when the currentFlowable
completes orMissingBackpressureException
is signaled somewhere downstream. - Scheduler:
onErrorReturn
does not operate by default on a particularScheduler
.
- Parameters:
itemSupplier
- a function that returns a single value that will be emitted along with a regularonComplete
in case the currentFlowable
signals anonError
event- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifitemSupplier
isnull
- See Also:
- ReactiveX operators documentation: Catch
-
onErrorReturnItem
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final @NonNull Flowable<T> onErrorReturnItem(@NonNull @NonNull T item)
Ends the flow with the given last item when the currentFlowable
fails instead of signaling the error viaonError
.By default, when a
Publisher
encounters an error that prevents it from emitting the expected item to itsSubscriber
, thePublisher
invokes itsSubscriber
'sonError
method, and then quits without invoking any more of itsSubscriber
's methods. TheonErrorReturn
method changes this behavior. If you pass a function (resumeFunction
) to aPublisher
'sonErrorReturn
method, if the originalPublisher
encounters an error, instead of invoking itsSubscriber
'sonError
method, it will instead emit the return value ofresumeFunction
.You can use this to prevent errors from propagating or to supply fallback data should errors be encountered.
- Backpressure:
- The operator honors backpressure from downstream. The current
Flowable
is expected to honor backpressure as well. If it this expectation is violated, the operator may throwIllegalStateException
when the currentFlowable
completes orMissingBackpressureException
is signaled somewhere downstream. - Scheduler:
onErrorReturnItem
does not operate by default on a particularScheduler
.
- Parameters:
item
- the value that is emitted along with a regularonComplete
in case the currentFlowable
signals an exception- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifitem
isnull
- See Also:
- ReactiveX operators documentation: Catch
-
onTerminateDetach
@CheckReturnValue @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> onTerminateDetach()
Nulls out references to the upstream producer and downstreamSubscriber
if the sequence is terminated or downstream cancels.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
onTerminateDetach
does not operate by default on a particularScheduler
.
- Returns:
- the new
Flowable
instance the sequence is terminated or downstream cancels - Since:
- 2.0
-
parallel
@BackpressureSupport(FULL) @SchedulerSupport("none") @CheckReturnValue @NonNull public final @NonNull ParallelFlowable<T> parallel()
Parallelizes the flow by creating multiple 'rails' (equal to the number of CPUs) and dispatches the upstream items to them in a round-robin fashion.Note that the rails don't execute in parallel on their own and one needs to apply
ParallelFlowable.runOn(Scheduler)
to specify theScheduler
where each rail will execute.To merge the parallel 'rails' back into a single sequence, use
ParallelFlowable.sequential()
.- Backpressure:
- The operator requires the upstream to honor backpressure and each 'rail' honors backpressure as well.
- Scheduler:
parallel
does not operate by default on a particularScheduler
.
History: 2.0.5 - experimental; 2.1 - beta
- Returns:
- the new
ParallelFlowable
instance - Since:
- 2.2
-
parallel
@BackpressureSupport(FULL) @SchedulerSupport("none") @CheckReturnValue @NonNull public final @NonNull ParallelFlowable<T> parallel(int parallelism)
Parallelizes the flow by creating the specified number of 'rails' and dispatches the upstream items to them in a round-robin fashion.Note that the rails don't execute in parallel on their own and one needs to apply
ParallelFlowable.runOn(Scheduler)
to specify theScheduler
where each rail will execute.To merge the parallel 'rails' back into a single sequence, use
ParallelFlowable.sequential()
.- Backpressure:
- The operator requires the upstream to honor backpressure and each 'rail' honors backpressure as well.
- Scheduler:
parallel
does not operate by default on a particularScheduler
.
History: 2.0.5 - experimental; 2.1 - beta
- Parameters:
parallelism
- the number of 'rails' to use- Returns:
- the new
ParallelFlowable
instance - Throws:
java.lang.IllegalArgumentException
- ifparallelism
is non-positive- Since:
- 2.2
-
parallel
@BackpressureSupport(FULL) @SchedulerSupport("none") @CheckReturnValue @NonNull public final @NonNull ParallelFlowable<T> parallel(int parallelism, int prefetch)
Parallelizes the flow by creating the specified number of 'rails' and dispatches the upstream items to them in a round-robin fashion and uses the defined per-'rail' prefetch amount.Note that the rails don't execute in parallel on their own and one needs to apply
ParallelFlowable.runOn(Scheduler)
to specify theScheduler
where each rail will execute.To merge the parallel 'rails' back into a single sequence, use
ParallelFlowable.sequential()
.- Backpressure:
- The operator requires the upstream to honor backpressure and each 'rail' honors backpressure as well.
- Scheduler:
parallel
does not operate by default on a particularScheduler
.
History: 2.0.5 - experimental; 2.1 - beta
- Parameters:
parallelism
- the number of 'rails' to useprefetch
- the number of items each 'rail' should prefetch- Returns:
- the new
ParallelFlowable
instance - Throws:
java.lang.IllegalArgumentException
- ifparallelism
orprefetch
is non-positive- Since:
- 2.2
-
publish
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull ConnectableFlowable<T> publish()
Returns aConnectableFlowable
, which is a variety ofPublisher
that waits until itsconnect
method is called before it begins emitting items to thoseSubscriber
s that have subscribed to it.- Backpressure:
- The returned
ConnectableFlowable
honors backpressure for each of itsSubscriber
s and expects the currentFlowable
to honor backpressure as well. If this expectation is violated, the operator will signal aMissingBackpressureException
to itsSubscriber
s and disconnect. - Scheduler:
publish
does not operate by default on a particularScheduler
.
- Returns:
- the new
ConnectableFlowable
instance - See Also:
- ReactiveX operators documentation: Publish
-
publish
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Flowable<R> publish(@NonNull @NonNull Function<? super Flowable<@NonNull T>,? extends org.reactivestreams.Publisher<@NonNull R>> selector)
Returns aFlowable
that emits the results of invoking a specified selector on items emitted by aConnectableFlowable
that shares a single subscription to the underlying sequence.- Backpressure:
- The operator expects the current
Flowable
to honor backpressure and if this expectation is violated, the operator will signal aMissingBackpressureException
through theFlowable
provided to the function. Since thePublisher
returned by theselector
may be independent of the providedFlowable
to the function, the output's backpressure behavior is determined by this returnedPublisher
. - Scheduler:
publish
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the type of items emitted by the resultingFlowable
- Parameters:
selector
- a function that can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence.Subscriber
s to the given source will receive all notifications of the source from the time of the subscription forward.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifselector
isnull
- See Also:
- ReactiveX operators documentation: Publish
-
publish
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final <@NonNull R> @NonNull Flowable<R> publish(@NonNull @NonNull Function<? super Flowable<@NonNull T>,? extends org.reactivestreams.Publisher<? extends @NonNull R>> selector, int prefetch)
Returns aFlowable
that emits the results of invoking a specified selector on items emitted by aConnectableFlowable
that shares a single subscription to the underlying sequence.- Backpressure:
- The operator expects the current
Flowable
to honor backpressure and if this expectation is violated, the operator will signal aMissingBackpressureException
through theFlowable
provided to the function. Since thePublisher
returned by theselector
may be independent of the providedFlowable
to the function, the output's backpressure behavior is determined by this returnedPublisher
. - Scheduler:
publish
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the type of items emitted by the resultingFlowable
- Parameters:
selector
- a function that can use the multicasted source sequence as many times as needed, without causing multiple subscriptions to the source sequence.Subscriber
s to the given source will receive all notifications of the source from the time of the subscription forward.prefetch
- the number of elements to prefetch from the currentFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifselector
isnull
java.lang.IllegalArgumentException
- ifprefetch
is non-positive- See Also:
- ReactiveX operators documentation: Publish
-
publish
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull ConnectableFlowable<T> publish(int bufferSize)
Returns aConnectableFlowable
, which is a variety ofPublisher
that waits until itsconnect
method is called before it begins emitting items to thoseSubscriber
s that have subscribed to it.- Backpressure:
- The returned
ConnectableFlowable
honors backpressure for each of itsSubscriber
s and expects the currentFlowable
to honor backpressure as well. If this expectation is violated, the operator will signal aMissingBackpressureException
to itsSubscriber
s and disconnect. - Scheduler:
publish
does not operate by default on a particularScheduler
.
- Parameters:
bufferSize
- the number of elements to prefetch from the currentFlowable
- Returns:
- the new
ConnectableFlowable
instance - Throws:
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Publish
-
rebatchRequests
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> rebatchRequests(int n)
Requestsn
initially from the upstream and then 75% ofn
subsequently after 75% ofn
values have been emitted to the downstream.This operator allows preventing the downstream to trigger unbounded mode via
request(
Long.MAX_VALUE
)
or compensate for the per-item overhead of small and frequent requests.- Backpressure:
- The operator expects backpressure from upstream and honors backpressure from downstream.
- Scheduler:
rebatchRequests
does not operate by default on a particularScheduler
.
- Parameters:
n
- the initial request amount, further request will happen after 75% of this value- Returns:
- the new
Flowable
instance - Throws:
java.lang.IllegalArgumentException
- ifn
is non-positive- Since:
- 2.0
-
reduce
@CheckReturnValue @NonNull @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") public final @NonNull Maybe<T> reduce(@NonNull @NonNull BiFunction<@NonNull T,@NonNull T,@NonNull T> reducer)
Returns aMaybe
that applies a specified accumulator function to the first item emitted by the currentFlowable
, then feeds the result of that function along with the second item emitted by the currentFlowable
into the same function, and so on until all items have been emitted by the current and finiteFlowable
, 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 fatalOutOfMemoryError
.- Backpressure:
- The operator honors backpressure of its downstream consumer and consumes the upstream source in unbounded mode.
- Scheduler:
reduce
does not operate by default on a particularScheduler
.
- Parameters:
reducer
- an accumulator function to be invoked on each item emitted by the currentFlowable
, whose result will be used in the next accumulator call- Returns:
- the new
Maybe
instance - Throws:
java.lang.NullPointerException
- ifreducer
isnull
- See Also:
- ReactiveX operators documentation: Reduce, Wikipedia: Fold (higher-order function)
-
reduce
@CheckReturnValue @NonNull @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") public final <@NonNull R> @NonNull Single<R> reduce(@NonNull R seed, @NonNull @NonNull BiFunction<@NonNull R,? super @NonNull T,@NonNull R> reducer)
Returns aSingle
that applies a specified accumulator function to the first item emitted by the currentFlowable
and a specified seed value, then feeds the result of that function along with the second item emitted by the currentFlowable
into the same function, and so on until all items have been emitted by the current and finiteFlowable
, 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 resultingFlowable
and may cause problems if it is mutable. To make sure each subscriber gets its own value, defer the application of this operator viadefer(Supplier)
:Flowable<T> source = ... Single.defer(() -> source.reduce(new ArrayList<>(), (list, item) -> list.add(item))); // alternatively, by using compose to stay fluent source.compose(o -> Flowable.defer(() -> o.reduce(new ArrayList<>(), (list, item) -> list.add(item)).toFlowable()) ).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 fatalOutOfMemoryError
.- Backpressure:
- The operator honors backpressure of its downstream consumer and consumes the upstream source in unbounded mode.
- Scheduler:
reduce
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the accumulator and output value type- Parameters:
seed
- the initial (seed) accumulator valuereducer
- an accumulator function to be invoked on each item emitted by the currentFlowable
, the result of which will be used in the next accumulator call- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifseed
orreducer
isnull
- See Also:
- ReactiveX operators documentation: Reduce,
Wikipedia: Fold (higher-order function),
reduceWith(Supplier, BiFunction)
-
reduceWith
@CheckReturnValue @NonNull @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") 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 aSingle
that applies a specified accumulator function to the first item emitted by the currentFlowable
and a seed value derived from calling a specifiedseedSupplier
, then feeds the result of that function along with the second item emitted by the currentFlowable
into the same function, and so on until all items have been emitted by the current and finiteFlowable
, 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 fatalOutOfMemoryError
.- Backpressure:
- The operator honors backpressure of its downstream consumer and consumes the upstream source in unbounded mode.
- Scheduler:
reduceWith
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the accumulator and output value type- Parameters:
seedSupplier
- theSupplier
that provides the initial (seed) accumulator value for each individualSubscriber
reducer
- an accumulator function to be invoked on each item emitted by the currentFlowable
, the result of which will be used in the next accumulator call- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifseedSupplier
orreducer
isnull
- See Also:
- ReactiveX operators documentation: Reduce, Wikipedia: Fold (higher-order function)
-
repeat
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> repeat()
Returns aFlowable
that repeats the sequence of items emitted by the currentFlowable
indefinitely.- Backpressure:
- The operator honors downstream backpressure and expects the current
Flowable
to honor backpressure as well. If this expectation is violated, the operator may throw anIllegalStateException
. - Scheduler:
repeat
does not operate by default on a particularScheduler
.
- Returns:
- the new
Flowable
instance - See Also:
- ReactiveX operators documentation: Repeat
-
repeat
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> repeat(long times)
Returns aFlowable
that repeats the sequence of items emitted by the currentFlowable
at mostcount
times.- Backpressure:
- The operator honors downstream backpressure and expects the current
Flowable
to honor backpressure as well. If this expectation is violated, the operator may throw anIllegalStateException
. - Scheduler:
repeat
does not operate by default on a particularScheduler
.
- Parameters:
times
- the number of times the currentFlowable
items are repeated, a count of 0 will yield an empty sequence- Returns:
- the new
Flowable
instance - Throws:
java.lang.IllegalArgumentException
- iftimes
is less than zero- See Also:
- ReactiveX operators documentation: Repeat
-
repeatUntil
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final @NonNull Flowable<T> repeatUntil(@NonNull @NonNull BooleanSupplier stop)
Returns aFlowable
that repeats the sequence of items emitted by the currentFlowable
until the provided stop function returnstrue
.- Backpressure:
- The operator honors downstream backpressure and expects the current
Flowable
to honor backpressure as well. If this expectation is violated, the operator may throw anIllegalStateException
. - Scheduler:
repeatUntil
does not operate by default on a particularScheduler
.
- Parameters:
stop
- a boolean supplier that is called when the currentFlowable
completes and unless it returnsfalse
, the currentFlowable
is resubscribed- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifstop
isnull
- See Also:
- ReactiveX operators documentation: Repeat
-
repeatWhen
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final @NonNull Flowable<T> repeatWhen(@NonNull @NonNull Function<? super Flowable<java.lang.Object>,? extends org.reactivestreams.Publisher<?>> handler)
Returns aFlowable
that emits the same values as the currentFlowable
with the exception of anonComplete
. AnonComplete
notification from the source will result in the emission of avoid
item to theFlowable
provided as an argument to thenotificationHandler
function. If thatPublisher
callsonComplete
oronError
thenrepeatWhen
will callonComplete
oronError
on the child subscription. Otherwise, thisPublisher
will resubscribe to the currentFlowable
.- Backpressure:
- The operator honors downstream backpressure and expects the current
Flowable
to honor backpressure as well. If this expectation is violated, the operator may throw anIllegalStateException
. - Scheduler:
repeatWhen
does not operate by default on a particularScheduler
.
- Parameters:
handler
- receives aPublisher
of notifications with which a user can complete or error, aborting the repeat.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifhandler
isnull
- See Also:
- ReactiveX operators documentation: Repeat
-
replay
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull ConnectableFlowable<T> replay()
Returns aConnectableFlowable
that shares a single subscription to the underlyingPublisher
that will replay all of its items and notifications to any futureSubscriber
. A connectableFlowable
resembles an ordinaryFlowable
, except that it does not begin emitting items when it is subscribed to, but only when itsconnect
method is called.- Backpressure:
- This operator supports backpressure. Note that the upstream requests are determined by the child
Subscriber
which requests the largest amount: i.e., two childSubscriber
s with requests of 10 and 100 will request 100 elements from the currentFlowable
sequence. - Scheduler:
- This version of
replay
does not operate by default on a particularScheduler
.
- Returns:
- the new
ConnectableFlowable
instance - See Also:
- ReactiveX operators documentation: Replay
-
replay
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final <@NonNull R> @NonNull Flowable<R> replay(@NonNull @NonNull Function<? super Flowable<@NonNull T>,? extends org.reactivestreams.Publisher<@NonNull R>> selector)
Returns aFlowable
that emits items that are the results of invoking a specified selector on the items emitted by aConnectableFlowable
that shares a single subscription to the currentFlowable
.- Backpressure:
- This operator supports backpressure. Note that the upstream requests are determined by the child
Subscriber
which requests the largest amount: i.e., two childSubscriber
s with requests of 10 and 100 will request 100 elements from the currentFlowable
sequence. - Scheduler:
- This version of
replay
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the type of items emitted by the resultingFlowable
- Parameters:
selector
- the selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the currentFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifselector
isnull
- See Also:
- ReactiveX operators documentation: Replay
-
replay
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final <@NonNull R> @NonNull Flowable<R> replay(@NonNull @NonNull Function<? super Flowable<@NonNull T>,? extends org.reactivestreams.Publisher<@NonNull R>> selector, int bufferSize)
Returns aFlowable
that emits items that are the results of invoking a specified selector on items emitted by aConnectableFlowable
that shares a single subscription to the currentFlowable
, replayingbufferSize
notifications.Note that due to concurrency requirements,
replay(bufferSize)
may hold strong references to more thanbufferSize
source emissions.- Backpressure:
- This operator supports backpressure. Note that the upstream requests are determined by the child
Subscriber
which requests the largest amount: i.e., two childSubscriber
s with requests of 10 and 100 will request 100 elements from the currentFlowable
sequence. - Scheduler:
- This version of
replay
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the type of items emitted by the resultingFlowable
- Parameters:
selector
- the selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the currentFlowable
bufferSize
- the buffer size that limits the number of items the operator can replay- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifselector
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Replay,
replay(Function, int, boolean)
-
replay
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final <@NonNull R> @NonNull Flowable<R> replay(@NonNull @NonNull Function<? super Flowable<@NonNull T>,? extends org.reactivestreams.Publisher<@NonNull R>> selector, int bufferSize, boolean eagerTruncate)
Returns aFlowable
that emits items that are the results of invoking a specified selector on items emitted by aConnectableFlowable
that shares a single subscription to the currentFlowable
, replayingbufferSize
notifications.Note that due to concurrency requirements,
replay(bufferSize)
may hold strong references to more thanbufferSize
source emissions.- Backpressure:
- This operator supports backpressure. Note that the upstream requests are determined by the child
Subscriber
which requests the largest amount: i.e., two childSubscriber
s with requests of 10 and 100 will request 100 elements from the currentFlowable
sequence. - Scheduler:
- This version of
replay
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the type of items emitted by the resultingFlowable
- Parameters:
selector
- the selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the currentFlowable
bufferSize
- the buffer size that limits the number of items the operator can replayeagerTruncate
- iftrue
, whenever the internal buffer is truncated to the given bufferSize, the oldest item will be guaranteed dereferenced, thus avoiding unexpected retention- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifselector
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Replay
-
replay
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("io.reactivex:computation") @NonNull public final <@NonNull R> @NonNull Flowable<R> replay(@NonNull @NonNull Function<? super Flowable<@NonNull T>,? extends org.reactivestreams.Publisher<@NonNull R>> selector, int bufferSize, long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits items that are the results of invoking a specified selector on items emitted by aConnectableFlowable
that shares a single subscription to the currentFlowable
, replaying no more thanbufferSize
items that were emitted within a specified time window.Note that due to concurrency requirements,
replay(bufferSize)
may hold strong references to more thanbufferSize
source emissions.- Backpressure:
- This operator supports backpressure. Note that the upstream requests are determined by the child
Subscriber
which requests the largest amount: i.e., two childSubscriber
s with requests of 10 and 100 will request 100 elements from the currentFlowable
sequence. - Scheduler:
- This version of
replay
operates by default on thecomputation
Scheduler
.
- Type Parameters:
R
- the type of items emitted by the resultingFlowable
- Parameters:
selector
- a selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the currentFlowable
bufferSize
- the buffer size that limits the number of items the operator can replaytime
- the duration of the window in which the replayed items must have been emittedunit
- the time unit oftime
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifselector
orunit
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Replay
-
replay
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("custom") public final <@NonNull R> @NonNull Flowable<R> replay(@NonNull @NonNull Function<? super Flowable<@NonNull T>,? extends org.reactivestreams.Publisher<@NonNull R>> selector, int bufferSize, long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns aFlowable
that emits items that are the results of invoking a specified selector on items emitted by aConnectableFlowable
that shares a single subscription to the currentFlowable
, replaying no more thanbufferSize
items that were emitted within a specified time window.Note that due to concurrency requirements,
replay(bufferSize)
may hold strong references to more thanbufferSize
source emissions.- Backpressure:
- This operator supports backpressure. Note that the upstream requests are determined by the child
Subscriber
which requests the largest amount: i.e., two childSubscriber
s with requests of 10 and 100 will request 100 elements from the currentFlowable
sequence. - Scheduler:
- You specify which
Scheduler
this operator will use.
- Type Parameters:
R
- the type of items emitted by the resultingFlowable
- Parameters:
selector
- a selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the currentFlowable
bufferSize
- the buffer size that limits the number of items the operator can replaytime
- the duration of the window in which the replayed items must have been emittedunit
- the time unit oftime
scheduler
- theScheduler
that is the time source for the window- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifselector
,unit
orscheduler
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Replay,
replay(Function, int, long, TimeUnit, Scheduler, boolean)
-
replay
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("custom") public final <@NonNull R> @NonNull Flowable<R> replay(@NonNull @NonNull Function<? super Flowable<@NonNull T>,? extends org.reactivestreams.Publisher<@NonNull R>> selector, int bufferSize, long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, boolean eagerTruncate)
Returns aFlowable
that emits items that are the results of invoking a specified selector on items emitted by aConnectableFlowable
that shares a single subscription to the currentFlowable
, replaying no more thanbufferSize
items that were emitted within a specified time window.Note that due to concurrency requirements,
replay(bufferSize)
may hold strong references to more thanbufferSize
source emissions.- Backpressure:
- This operator supports backpressure. Note that the upstream requests are determined by the child
Subscriber
which requests the largest amount: i.e., two childSubscriber
s with requests of 10 and 100 will request 100 elements from the currentFlowable
sequence. - Scheduler:
- You specify which
Scheduler
this operator will use.
- Type Parameters:
R
- the type of items emitted by the resultingFlowable
- Parameters:
selector
- a selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the currentFlowable
bufferSize
- the buffer size that limits the number of items the operator can replaytime
- the duration of the window in which the replayed items must have been emittedunit
- the time unit oftime
scheduler
- theScheduler
that is the time source for the windoweagerTruncate
- iftrue
, 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
Flowable
instance - Throws:
java.lang.NullPointerException
- ifselector
,unit
orscheduler
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is less than zero- See Also:
- ReactiveX operators documentation: Replay
-
replay
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("io.reactivex:computation") @NonNull public final <@NonNull R> @NonNull Flowable<R> replay(@NonNull @NonNull Function<? super Flowable<@NonNull T>,? extends org.reactivestreams.Publisher<@NonNull R>> selector, long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits items that are the results of invoking a specified selector on items emitted by aConnectableFlowable
that shares a single subscription to the currentFlowable
, replaying all items that were emitted within a specified time window.- Backpressure:
- This operator supports backpressure. Note that the upstream requests are determined by the child
Subscriber
which requests the largest amount: i.e., two childSubscriber
s with requests of 10 and 100 will request 100 elements from the currentFlowable
sequence. - Scheduler:
- This version of
replay
operates by default on thecomputation
Scheduler
.
- Type Parameters:
R
- the type of items emitted by the resultingFlowable
- Parameters:
selector
- a selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the currentFlowable
time
- the duration of the window in which the replayed items must have been emittedunit
- the time unit oftime
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifselector
orunit
isnull
- See Also:
- ReactiveX operators documentation: Replay
-
replay
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("custom") public final <@NonNull R> @NonNull Flowable<R> replay(@NonNull @NonNull Function<? super Flowable<@NonNull T>,? extends org.reactivestreams.Publisher<@NonNull R>> selector, long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns aFlowable
that emits items that are the results of invoking a specified selector on items emitted by aConnectableFlowable
that shares a single subscription to the currentFlowable
, replaying all items that were emitted within a specified time window.- Backpressure:
- This operator supports backpressure. Note that the upstream requests are determined by the child
Subscriber
which requests the largest amount: i.e., two childSubscriber
s with requests of 10 and 100 will request 100 elements from the currentFlowable
sequence. - Scheduler:
- You specify which
Scheduler
this operator will use.
- Type Parameters:
R
- the type of items emitted by the resultingFlowable
- Parameters:
selector
- a selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the currentFlowable
time
- the duration of the window in which the replayed items must have been emittedunit
- the time unit oftime
scheduler
- the scheduler that is the time source for the window- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifselector
,unit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Replay,
replay(Function, long, TimeUnit, Scheduler, boolean)
-
replay
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("custom") public final <@NonNull R> @NonNull Flowable<R> replay(@NonNull @NonNull Function<? super Flowable<@NonNull T>,? extends org.reactivestreams.Publisher<@NonNull R>> selector, long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, boolean eagerTruncate)
Returns aFlowable
that emits items that are the results of invoking a specified selector on items emitted by aConnectableFlowable
that shares a single subscription to the currentFlowable
, replaying all items that were emitted within a specified time window.- Backpressure:
- This operator supports backpressure. Note that the upstream requests are determined by the child
Subscriber
which requests the largest amount: i.e., two childSubscriber
s with requests of 10 and 100 will request 100 elements from the currentFlowable
sequence. - Scheduler:
- You specify which
Scheduler
this operator will use.
- Type Parameters:
R
- the type of items emitted by the resultingFlowable
- Parameters:
selector
- a selector function, which can use the multicasted sequence as many times as needed, without causing multiple subscriptions to the currentFlowable
time
- the duration of the window in which the replayed items must have been emittedunit
- the time unit oftime
scheduler
- the scheduler that is the time source for the windoweagerTruncate
- iftrue
, whenever the internal buffer is truncated to the given age, the oldest item will be guaranteed dereferenced, thus avoiding unexpected retention- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifselector
,unit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Replay
-
replay
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull ConnectableFlowable<T> replay(int bufferSize)
Returns aConnectableFlowable
that shares a single subscription to the currentFlowable
and replays at mostbufferSize
items to lateSubscriber
s. A ConnectableFlowable
resembles an ordinaryFlowable
, except that it does not begin emitting items when it is subscribed to, but only when itsconnect
method is called.Note that due to concurrency requirements,
replay(bufferSize)
may hold strong references to more thanbufferSize
source emissions. To ensure no beyond-bufferSize items are referenced, use thereplay(int, boolean)
overload witheagerTruncate = true
.- Backpressure:
- This operator supports backpressure. Note that the upstream requests are determined by the child
Subscriber
which requests the largest amount: i.e., two childSubscriber
s with requests of 10 and 100 will request 100 elements from the currentFlowable
sequence. - Scheduler:
- This version of
replay
does not operate by default on a particularScheduler
.
- Parameters:
bufferSize
- the buffer size that limits the number of items that can be replayed- Returns:
- the new
ConnectableFlowable
instance - Throws:
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Replay,
replay(int, boolean)
-
replay
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull ConnectableFlowable<T> replay(int bufferSize, boolean eagerTruncate)
Returns aConnectableFlowable
that shares a single subscription to the currentFlowable
and replays at mostbufferSize
items to lateSubscriber
s. A connectableFlowable
resembles an ordinaryFlowable
, except that it does not begin emitting items when it is subscribed to, but only when itsconnect
method is called.Note that due to concurrency requirements,
replay(bufferSize)
may hold strong references to more thanbufferSize
source emissions. To ensure no beyond-bufferSize items are referenced, seteagerTruncate = true
.- Backpressure:
- This operator supports backpressure. Note that the upstream requests are determined by the child
Subscriber
which requests the largest amount: i.e., two childSubscriber
s with requests of 10 and 100 will request 100 elements from the currentFlowable
sequence. - Scheduler:
- This version of
replay
does not operate by default on a particularScheduler
.
- Parameters:
bufferSize
- the buffer size that limits the number of items that can be replayedeagerTruncate
- iftrue
, whenever the internal buffer is truncated to the given bufferSize, the oldest item will be guaranteed dereferenced, thus avoiding unexpected retention- Returns:
- the new
ConnectableFlowable
instance - Throws:
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- Since:
- 3.0.0
- See Also:
- ReactiveX operators documentation: Replay
-
replay
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull ConnectableFlowable<T> replay(int bufferSize, long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns aConnectableFlowable
that shares a single subscription to the currentFlowable
and replays at mostbufferSize
items that were emitted during a specified time window. A connectableFlowable
resembles an ordinaryFlowable
, except that it does not begin emitting items when it is subscribed to, but only when itsconnect
method is called.Note that due to concurrency requirements,
replay(bufferSize)
may hold strong references to more thanbufferSize
source emissions. To ensure no out-of-date or beyond-bufferSize items are referenced, use thereplay(int, long, TimeUnit, Scheduler, boolean)
overload witheagerTruncate = true
.- Backpressure:
- This operator supports backpressure. Note that the upstream requests are determined by the child
Subscriber
which requests the largest amount: i.e., two childSubscriber
s with requests of 10 and 100 will request 100 elements from the currentFlowable
sequence. - Scheduler:
- This version of
replay
operates by default on thecomputation
Scheduler
.
- Parameters:
bufferSize
- the buffer size that limits the number of items that can be replayedtime
- the duration of the window in which the replayed items must have been emittedunit
- the time unit oftime
- Returns:
- the new
ConnectableFlowable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Replay,
replay(int, long, TimeUnit, Scheduler, boolean)
-
replay
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("custom") @NonNull public final @NonNull ConnectableFlowable<T> replay(int bufferSize, long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns aConnectableFlowable
that shares a single subscription to the currentFlowable
and replays a maximum ofbufferSize
items that are emitted within a specified time window to lateSubscriber
s. A connectableFlowable
resembles an ordinaryFlowable
, except that it does not begin emitting items when it is subscribed to, but only when itsconnect
method is called.Note that due to concurrency requirements,
replay(bufferSize)
may hold strong references to more thanbufferSize
source emissions. To ensure no out-of-date or beyond-bufferSize items are referenced, use thereplay(int, long, TimeUnit, Scheduler, boolean)
overload witheagerTruncate = true
.- Backpressure:
- This operator supports backpressure. Note that the upstream requests are determined by the child
Subscriber
which requests the largest amount: i.e., two childSubscriber
s with requests of 10 and 100 will request 100 elements from the currentFlowable
sequence. - Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
bufferSize
- the buffer size that limits the number of items that can be replayedtime
- the duration of the window in which the replayed items must have been emittedunit
- the time unit oftime
scheduler
- the scheduler that is used as a time source for the window- Returns:
- the new
ConnectableFlowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Replay,
replay(int, long, TimeUnit, Scheduler, boolean)
-
replay
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("custom") @NonNull public final @NonNull ConnectableFlowable<T> replay(int bufferSize, long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, boolean eagerTruncate)
Returns aConnectableFlowable
that shares a single subscription to the currentFlowable
and replays a maximum ofbufferSize
items that are emitted within a specified time window to lateSubscriber
s. A connectableFlowable
resembles an ordinaryFlowable
, except that it does not begin emitting items when it is subscribed to, but only when itsconnect
method is called.Note that due to concurrency requirements,
replay(bufferSize)
may hold strong references to more thanbufferSize
source emissions. To ensure no out-of-date or beyond-bufferSize items are referenced, seteagerTruncate = true
.- Backpressure:
- This operator supports backpressure. Note that the upstream requests are determined by the child
Subscriber
which requests the largest amount: i.e., two childSubscriber
s with requests of 10 and 100 will request 100 elements from the currentFlowable
sequence. - Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
bufferSize
- the buffer size that limits the number of items that can be replayedtime
- the duration of the window in which the replayed items must have been emittedunit
- the time unit oftime
scheduler
- the scheduler that is used as a time source for the windoweagerTruncate
- iftrue
, 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
ConnectableFlowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- Since:
- 3.0.0
- See Also:
- ReactiveX operators documentation: Replay
-
replay
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull ConnectableFlowable<T> replay(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns aConnectableFlowable
that shares a single subscription to the currentFlowable
and replays all items emitted by it within a specified time window to lateSubscriber
s. A connectableFlowable
resembles an ordinaryFlowable
, except that it does not begin emitting items when it is subscribed to, but only when itsconnect
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, use the
replay(long, TimeUnit, Scheduler, boolean)
overload witheagerTruncate = true
.- Backpressure:
- This operator supports backpressure. Note that the upstream requests are determined by the child
Subscriber
which requests the largest amount: i.e., two childSubscriber
s with requests of 10 and 100 will request 100 elements from the currentFlowable
sequence. - Scheduler:
- This version of
replay
operates by default on thecomputation
Scheduler
.
- Parameters:
time
- the duration of the window in which the replayed items must have been emittedunit
- the time unit oftime
- Returns:
- the new
ConnectableFlowable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Replay
-
replay
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("custom") @NonNull public final @NonNull ConnectableFlowable<T> replay(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns aConnectableFlowable
that shares a single subscription to the currentFlowable
and replays all items emitted by it within a specified time window to lateSubscriber
s. A connectableFlowable
resembles an ordinaryFlowable
, except that it does not begin emitting items when it is subscribed to, but only when itsconnect
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, use the
replay(long, TimeUnit, Scheduler, boolean)
overload witheagerTruncate = true
.- Backpressure:
- This operator supports backpressure. Note that the upstream requests are determined by the child
Subscriber
which requests the largest amount: i.e., two childSubscriber
s with requests of 10 and 100 will request 100 elements from the currentFlowable
sequence. - Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
time
- the duration of the window in which the replayed items must have been emittedunit
- the time unit oftime
scheduler
- theScheduler
that is the time source for the window- Returns:
- the new
ConnectableFlowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Replay,
replay(long, TimeUnit, Scheduler, boolean)
-
replay
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("custom") @NonNull public final @NonNull ConnectableFlowable<T> replay(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, boolean eagerTruncate)
Returns aConnectableFlowable
that shares a single subscription to the currentFlowable
and replays all items emitted by it within a specified time window to lateSubscriber
s. A connectableFlowable
resembles an ordinaryFlowable
, except that it does not begin emitting items when it is subscribed to, but only when itsconnect
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
.- Backpressure:
- This operator supports backpressure. Note that the upstream requests are determined by the child
Subscriber
which requests the largest amount: i.e., two childSubscriber
s with requests of 10 and 100 will request 100 elements from the currentFlowable
sequence. - Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
time
- the duration of the window in which the replayed items must have been emittedunit
- the time unit oftime
scheduler
- theScheduler
that is the time source for the windoweagerTruncate
- iftrue
, 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
ConnectableFlowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Replay
-
retry
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> retry()
Returns aFlowable
that mirrors the currentFlowable
, resubscribing to it if it callsonError
(infinite retry count).If the current
Flowable
callsSubscriber.onError(java.lang.Throwable)
, this method will resubscribe to the currentFlowable
rather than propagating theonError
call.Any and all items emitted by the current
Flowable
will be emitted by the resultingFlowable
, even those emitted during failed subscriptions. For example, if the currentFlowable
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]
.- Backpressure:
- The operator honors downstream backpressure and expects the current
Flowable
to honor backpressure as well. If this expectation is violated, the operator may throw anIllegalStateException
. - Scheduler:
retry
does not operate by default on a particularScheduler
.
- Returns:
- the new
Flowable
instance - See Also:
- ReactiveX operators documentation: Retry
-
retry
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final @NonNull Flowable<T> retry(@NonNull @NonNull BiPredicate<? super java.lang.Integer,? super java.lang.Throwable> predicate)
Returns aFlowable
that mirrors the currentFlowable
, resubscribing to it if it callsonError
and the predicate returnstrue
for that specific exception and retry count.- Backpressure:
- The operator honors downstream backpressure and expects the current
Flowable
to honor backpressure as well. If this expectation is violated, the operator may throw anIllegalStateException
. - Scheduler:
retry
does not operate by default on a particularScheduler
.
- Parameters:
predicate
- the predicate that determines if a resubscription may happen in case of a specific exception and retry count- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifpredicate
isnull
- See Also:
retry()
, ReactiveX operators documentation: Retry
-
retry
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> retry(long times)
Returns aFlowable
that mirrors the currentFlowable
, resubscribing to it if it callsonError
up to a specified number of retries.If the current
Flowable
callsSubscriber.onError(java.lang.Throwable)
, this method will resubscribe to the currentFlowable
for a maximum ofcount
resubscriptions rather than propagating theonError
call.Any and all items emitted by the current
Flowable
will be emitted by the resultingFlowable
, even those emitted during failed subscriptions. For example, if the currentFlowable
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]
.- Backpressure:
- The operator honors downstream backpressure and expects the current
Flowable
to honor backpressure as well. If this expectation is violated, the operator may throw anIllegalStateException
. - Scheduler:
retry
does not operate by default on a particularScheduler
.
- Parameters:
times
- the number of times to resubscribe if the currentFlowable
fails- Returns:
- the new
Flowable
instance - Throws:
java.lang.IllegalArgumentException
- iftimes
is negative- See Also:
- ReactiveX operators documentation: Retry
-
retry
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final @NonNull Flowable<T> retry(long times, @NonNull @NonNull Predicate<? super java.lang.Throwable> predicate)
Retries at most times or until the predicate returnsfalse
, whichever happens first.- Backpressure:
- The operator honors downstream backpressure and expects the current
Flowable
to honor backpressure as well. If this expectation is violated, the operator may throw anIllegalStateException
. - Scheduler:
retry
does not operate by default on a particularScheduler
.
- Parameters:
times
- the number of times to resubscribe if the currentFlowable
failspredicate
- the predicate called with the failureThrowable
and should returntrue
to trigger a retry.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifpredicate
isnull
java.lang.IllegalArgumentException
- iftimes
is negative
-
retry
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> retry(@NonNull @NonNull Predicate<? super java.lang.Throwable> predicate)
Retries the currentFlowable
if the predicate returnstrue
.- Backpressure:
- The operator honors downstream backpressure and expects the current
Flowable
to honor backpressure as well. If this expectation is violated, the operator may throw anIllegalStateException
. - Scheduler:
retry
does not operate by default on a particularScheduler
.
- Parameters:
predicate
- the predicate that receives the failureThrowable
and should returntrue
to trigger a retry.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifpredicate
isnull
-
retryUntil
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final @NonNull Flowable<T> retryUntil(@NonNull @NonNull BooleanSupplier stop)
Retries until the given stop function returnstrue
.- Backpressure:
- The operator honors downstream backpressure and expects the current
Flowable
to honor backpressure as well. If this expectation is violated, the operator may throw anIllegalStateException
. - Scheduler:
retryUntil
does not operate by default on a particularScheduler
.
- Parameters:
stop
- the function that should returntrue
to stop retrying- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifstop
isnull
-
retryWhen
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final @NonNull Flowable<T> retryWhen(@NonNull @NonNull Function<? super Flowable<java.lang.Throwable>,? extends org.reactivestreams.Publisher<?>> handler)
Returns aFlowable
that emits the same values as the currentFlowable
with the exception of anonError
. AnonError
notification from the source will result in the emission of aThrowable
item to theFlowable
provided as an argument to thenotificationHandler
function. If thatPublisher
callsonComplete
oronError
thenretry
will callonComplete
oronError
on the child subscription. Otherwise, thisPublisher
will resubscribe to the currentFlowable
.Example: This retries 3 times, each time incrementing the number of seconds it waits.
Output is:Flowable.create((FlowableEmitter<? super String> s) -> { System.out.println("subscribing"); s.onError(new RuntimeException("always fails")); }, BackpressureStrategy.BUFFER).retryWhen(attempts -> { return attempts.zipWith(Flowable.range(1, 3), (n, i) -> i).flatMap(i -> { System.out.println("delay retry by " + i + " second(s)"); return Flowable.timer(i, TimeUnit.SECONDS); }); }).blockingForEach(System.out::println);
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
Publisher
returned by the handler function should signal eitheronNext
,onError
oronComplete
in response to the receivedThrowable
to indicate the operator should retry or terminate. If the upstream to the operator is asynchronous, signalingonNext
followed byonComplete
immediately may result in the sequence to be completed immediately. Similarly, if this innerPublisher
signalsonError
oronComplete
while the upstream is active, the sequence is terminated with the same signal immediately.The following example demonstrates how to retry an asynchronous source with a delay:
Flowable.timer(1, TimeUnit.SECONDS) .doOnSubscribe(s -> System.out.println("subscribing")) .map(v -> { throw new RuntimeException(); }) .retryWhen(errors -> { AtomicInteger counter = new AtomicInteger(); return errors .takeWhile(e -> counter.getAndIncrement() != 3) .flatMap(e -> { System.out.println("delay retry by " + counter.get() + " second(s)"); return Flowable.timer(counter.get(), TimeUnit.SECONDS); }); }) .blockingSubscribe(System.out::println, System.out::println);
- Backpressure:
- The operator honors downstream backpressure and expects both the source
and inner
Publisher
s to honor backpressure as well. If this expectation is violated, the operator may throw anIllegalStateException
. - Scheduler:
retryWhen
does not operate by default on a particularScheduler
.
- Parameters:
handler
- receives aPublisher
of notifications with which a user can complete or error, aborting the retry- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifhandler
isnull
- See Also:
- ReactiveX operators documentation: Retry
-
safeSubscribe
@BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") public final void safeSubscribe(@NonNull @NonNull org.reactivestreams.Subscriber<? super @NonNull T> subscriber)
Subscribes to the currentFlowable
and wraps the givenSubscriber
into aSafeSubscriber
(if not already aSafeSubscriber
) that deals with exceptions thrown by a misbehavingSubscriber
(that doesn't follow the Reactive Streams specification).- Backpressure:
- This operator leaves the reactive world and the backpressure behavior depends on the
Subscriber
's behavior. - Scheduler:
safeSubscribe
does not operate by default on a particularScheduler
.
- Parameters:
subscriber
- the incomingSubscriber
instance- Throws:
java.lang.NullPointerException
- ifsubscriber
isnull
-
sample
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Flowable<T> sample(long period, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits the most recently emitted item (if any) emitted by the currentFlowable
within periodic time intervals.- Backpressure:
- This operator does not support backpressure as it uses time to control data flow.
- Scheduler:
sample
operates by default on thecomputation
Scheduler
.
- Parameters:
period
- the sampling rateunit
- theTimeUnit
in whichperiod
is defined- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Sample,
RxJava wiki: Backpressure,
throttleLast(long, TimeUnit)
-
sample
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Flowable<T> sample(long period, @NonNull @NonNull java.util.concurrent.TimeUnit unit, boolean emitLast)
Returns aFlowable
that emits the most recently emitted item (if any) emitted by the currentFlowable
within periodic time intervals and optionally emit the very last upstream item when the upstream completes.- Backpressure:
- This operator does not support backpressure as it uses time to control data flow.
- Scheduler:
sample
operates by default on thecomputation
Scheduler
.
History: 2.0.5 - experimental
- Parameters:
period
- the sampling rateunit
- theTimeUnit
in whichperiod
is definedemitLast
- iftrue
, and the upstream completes while there is still an unsampled item available, that item is emitted to downstream before completion iffalse
, an unsampled last item is ignored.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- Since:
- 2.1
- See Also:
- ReactiveX operators documentation: Sample,
RxJava wiki: Backpressure,
throttleLast(long, TimeUnit)
-
sample
@CheckReturnValue @NonNull @BackpressureSupport(ERROR) @SchedulerSupport("custom") public final @NonNull Flowable<T> sample(long period, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns aFlowable
that emits the most recently emitted item (if any) emitted by the currentFlowable
within periodic time intervals, where the intervals are defined on a particularScheduler
.- Backpressure:
- This operator does not support backpressure as it uses time to control data flow.
- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
period
- the sampling rateunit
- theTimeUnit
in whichperiod
is definedscheduler
- theScheduler
to use when sampling- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Sample,
RxJava wiki: Backpressure,
throttleLast(long, TimeUnit, Scheduler)
-
sample
@CheckReturnValue @NonNull @BackpressureSupport(ERROR) @SchedulerSupport("custom") public final @NonNull Flowable<T> sample(long period, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, boolean emitLast)
Returns aFlowable
that emits the most recently emitted item (if any) emitted by the currentFlowable
within periodic time intervals, where the intervals are defined on a particularScheduler
and optionally emit the very last upstream item when the upstream completes.- Backpressure:
- This operator does not support backpressure as it uses time to control data flow.
- Scheduler:
- You specify which
Scheduler
this operator will use.
History: 2.0.5 - experimental
- Parameters:
period
- the sampling rateunit
- theTimeUnit
in whichperiod
is definedscheduler
- theScheduler
to use when samplingemitLast
- iftrue
and the upstream completes while there is still an unsampled item available, that item is emitted to downstream before completion iffalse
, an unsampled last item is ignored.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- Since:
- 2.1
- See Also:
- ReactiveX operators documentation: Sample,
RxJava wiki: Backpressure,
throttleLast(long, TimeUnit, Scheduler)
-
sample
@CheckReturnValue @NonNull @BackpressureSupport(ERROR) @SchedulerSupport("custom") public final @NonNull Flowable<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 aFlowable
that emits the most recently emitted item (if any) emitted by the currentFlowable
within periodic time intervals, where the intervals are defined on a particularScheduler
and optionally emit the very last upstream item when the upstream completes.- Backpressure:
- This operator does not support backpressure as it uses time to control data flow.
- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
period
- the sampling rateunit
- theTimeUnit
in whichperiod
is definedscheduler
- theScheduler
to use when samplingemitLast
- iftrue
and the upstream completes while there is still an unsampled item available, that item is emitted to downstream before completion iffalse
, an unsampled last item is ignored.onDropped
- called with the current entry when it has been replaced by a new one- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
oronDropped
isnull
- Since:
- 3.1.6 - Experimental
- See Also:
- ReactiveX operators documentation: Sample,
RxJava wiki: Backpressure,
throttleLast(long, TimeUnit, Scheduler)
-
sample
@CheckReturnValue @NonNull @BackpressureSupport(ERROR) @SchedulerSupport("none") public final <@NonNull U> @NonNull Flowable<T> sample(@NonNull @NonNull org.reactivestreams.Publisher<@NonNull U> sampler)
Returns aFlowable
that, when the specifiedsampler
Publisher
emits an item or completes, emits the most recently emitted item (if any) emitted by the currentFlowable
since the previous emission from thesampler
Publisher
.- Backpressure:
- This operator does not support backpressure as it uses the emissions of the
sampler
Publisher
to control data flow. - Scheduler:
- This version of
sample
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the element type of the samplerPublisher
- Parameters:
sampler
- thePublisher
to use for sampling the currentFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsampler
isnull
- See Also:
- ReactiveX operators documentation: Sample, RxJava wiki: Backpressure
-
sample
@CheckReturnValue @NonNull @BackpressureSupport(ERROR) @SchedulerSupport("none") public final <@NonNull U> @NonNull Flowable<T> sample(@NonNull @NonNull org.reactivestreams.Publisher<@NonNull U> sampler, boolean emitLast)
Returns aFlowable
that, when the specifiedsampler
Publisher
emits an item or completes, emits the most recently emitted item (if any) emitted by the currentFlowable
since the previous emission from thesampler
Publisher
and optionally emit the very last upstream item when the upstream or otherPublisher
complete.- Backpressure:
- This operator does not support backpressure as it uses the emissions of the
sampler
Publisher
to control data flow. - Scheduler:
- This version of
sample
does not operate by default on a particularScheduler
.
History: 2.0.5 - experimental
- Type Parameters:
U
- the element type of the samplerPublisher
- Parameters:
sampler
- thePublisher
to use for sampling the currentFlowable
emitLast
- iftrue
and the upstream completes while there is still an unsampled item available, that item is emitted to downstream before completion iffalse
, an unsampled last item is ignored.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsampler
isnull
- Since:
- 2.1
- See Also:
- ReactiveX operators documentation: Sample, RxJava wiki: Backpressure
-
scan
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final @NonNull Flowable<T> scan(@NonNull @NonNull BiFunction<@NonNull T,@NonNull T,@NonNull T> accumulator)
Returns aFlowable
that emits the first value emitted by the currentFlowable
, then emits one value for each subsequent value emitted by the currentFlowable
. Each emission after the first is the result of applying the specified accumulator function to the previous emission and the corresponding value from the currentFlowable
.This sort of function is sometimes called an accumulator.
- Backpressure:
- The operator honors downstream backpressure and expects the current
Flowable
to honor backpressure as well. Violating this expectation, aMissingBackpressureException
may get signaled somewhere downstream. - Scheduler:
scan
does not operate by default on a particularScheduler
.
- Parameters:
accumulator
- an accumulator function to be invoked on each item emitted by the currentFlowable
, whose result will be emitted toSubscriber
s viaonNext
and used in the next accumulator call- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifaccumulator
isnull
- See Also:
- ReactiveX operators documentation: Scan
-
scan
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final <@NonNull R> @NonNull Flowable<R> scan(@NonNull R initialValue, @NonNull @NonNull BiFunction<@NonNull R,? super @NonNull T,@NonNull R> accumulator)
Returns aFlowable
that emits the provided initial (seed) value, then emits one value for each value emitted by the currentFlowable
. Each emission after the first is the result of applying the specified accumulator function to the previous emission and the corresponding value from the currentFlowable
.This sort of function is sometimes called an accumulator.
Note that the
Flowable
that results from this method will emitinitialValue
as its first emitted item.Note that the
initialValue
is shared among all subscribers to the resultingFlowable
and may cause problems if it is mutable. To make sure each subscriber gets its own value, defer the application of this operator viadefer(Supplier)
:Publisher<T> source = ... Flowable.defer(() -> source.scan(new ArrayList<>(), (list, item) -> list.add(item))); // alternatively, by using compose to stay fluent source.compose(o -> Flowable.defer(() -> o.scan(new ArrayList<>(), (list, item) -> list.add(item))) );
- Backpressure:
- The operator honors downstream backpressure and expects the current
Flowable
to honor backpressure as well. Violating this expectation, aMissingBackpressureException
may get signaled somewhere downstream. The downstream request pattern is not preserved across this operator. The upstream is requestedbufferSize()
- 1 upfront and 75% ofbufferSize()
thereafter. - Scheduler:
scan
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the initial, accumulator and result type- Parameters:
initialValue
- the initial (seed) accumulator itemaccumulator
- an accumulator function to be invoked on each item emitted by the currentFlowable
, whose result will be emitted toSubscriber
s viaonNext
and used in the next accumulator call- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifinitialValue
oraccumulator
isnull
- See Also:
- ReactiveX operators documentation: Scan
-
scanWith
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final <@NonNull R> @NonNull Flowable<R> scanWith(@NonNull @NonNull Supplier<@NonNull R> seedSupplier, @NonNull @NonNull BiFunction<@NonNull R,? super @NonNull T,@NonNull R> accumulator)
Returns aFlowable
that emits the provided initial (seed) value, then emits one value for each value emitted by the currentFlowable
. Each emission after the first is the result of applying the specified accumulator function to the previous emission and the corresponding value from the currentFlowable
.This sort of function is sometimes called an accumulator.
Note that the
Flowable
that results from this method will emit the value returned by theseedSupplier
as its first item.- Backpressure:
- The operator honors downstream backpressure and expects the current
Flowable
to honor backpressure as well. Violating this expectation, aMissingBackpressureException
may get signaled somewhere downstream. The downstream request pattern is not preserved across this operator. The upstream is requestedbufferSize()
- 1 upfront and 75% ofbufferSize()
thereafter. - Scheduler:
scanWith
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the initial, accumulator and result type- Parameters:
seedSupplier
- aSupplier
that returns the initial (seed) accumulator item for each individualSubscriber
accumulator
- an accumulator function to be invoked on each item emitted by the currentFlowable
, whose result will be emitted toSubscriber
s viaonNext
and used in the next accumulator call- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifseedSupplier
oraccumulator
isnull
- See Also:
- ReactiveX operators documentation: Scan
-
serialize
@CheckReturnValue @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> serialize()
Forces the currentFlowable
's emissions and notifications to be serialized and for it to obey thePublisher
contract in other ways.It is possible for a
Publisher
to invoke itsSubscriber
s' methods asynchronously, perhaps from different threads. This could make such aPublisher
poorly-behaved, in that it might try to invokeonComplete
oronError
before one of itsonNext
invocations, or it might callonNext
from two different threads concurrently. You can force such aPublisher
to be well-behaved and sequential by applying theserialize
method to it.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
serialize
does not operate by default on a particularScheduler
.
- Returns:
- the new
Flowable
instance - See Also:
- ReactiveX operators documentation: Serialize
-
share
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> share()
Returns a newFlowable
that multicasts (and shares a single subscription to) the currentFlowable
. As long as there is at least oneSubscriber
, the currentFlowable
will be subscribed and emitting data. When all subscribers have canceled it will cancel the currentFlowable
.This is an alias for
publish()
.refCount()
.- Backpressure:
- The operator honors backpressure and expects the current
Flowable
to honor backpressure as well. If this expectation is violated, the operator will signal aMissingBackpressureException
to itsSubscriber
s. - Scheduler:
share
does not operate by default on a particularScheduler
.
- Returns:
- the new
Flowable
instance - See Also:
- ReactiveX operators documentation: RefCount
-
singleElement
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final @NonNull Maybe<T> singleElement()
Returns aMaybe
that completes if thisFlowable
is empty, signals one item if thisFlowable
signals exactly one item or signals anIllegalArgumentException
if thisFlowable
signals more than one item.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., without applying backpressure). - Scheduler:
singleElement
does not operate by default on a particularScheduler
.
- Returns:
- the new
Maybe
instance - See Also:
- ReactiveX operators documentation: First
-
single
@CheckReturnValue @NonNull @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") public final @NonNull Single<T> single(@NonNull @NonNull T defaultItem)
Returns aSingle
that emits the single item emitted by the currentFlowable
if it emits only a single item, or a default item if the currentFlowable
emits no items. If the currentFlowable
emits more than one item, anIllegalArgumentException
is signaled instead.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., without applying backpressure). - Scheduler:
single
does not operate by default on a particularScheduler
.
- Parameters:
defaultItem
- a default value to emit if the currentFlowable
emits no item- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifdefaultItem
isnull
- See Also:
- ReactiveX operators documentation: First
-
singleOrError
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final @NonNull Single<T> singleOrError()
Returns aSingle
that emits the single item emitted by thisFlowable
, if thisFlowable
emits only a single item, otherwise if thisFlowable
completes without emitting any items aNoSuchElementException
will be signaled and if thisFlowable
emits more than one item, anIllegalArgumentException
will be signaled.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., without applying backpressure). - Scheduler:
singleOrError
does not operate by default on a particularScheduler
.
- Returns:
- the new
Single
instance - See Also:
- ReactiveX operators documentation: First
-
skip
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> skip(long count)
Returns aFlowable
that skips the firstcount
items emitted by the currentFlowable
and emits the remainder.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
- This version of
skip
does not operate by default on a particularScheduler
.
- Parameters:
count
- the number of items to skip- Returns:
- the new
Flowable
instance - Throws:
java.lang.IllegalArgumentException
- ifcount
is negative- See Also:
- ReactiveX operators documentation: Skip
-
skip
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> skip(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that skips values emitted by the currentFlowable
before a specified time window elapses.- Backpressure:
- The operator doesn't support backpressure as it uses time to skip an arbitrary number of elements and
thus has to consume the current
Flowable
in an unbounded manner (i.e., no backpressure applied to it). - Scheduler:
skip
does not operate on any particular scheduler but uses the current time from thecomputation
Scheduler
.
- Parameters:
time
- the length of the time window to skipunit
- the time unit oftime
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Skip
-
skip
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("custom") @NonNull public final @NonNull Flowable<T> skip(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns aFlowable
that skips values emitted by the currentFlowable
before a specified time window on a specifiedScheduler
elapses.- Backpressure:
- The operator doesn't support backpressure as it uses time to skip an arbitrary number of elements and
thus has to consume the current
Flowable
in an unbounded manner (i.e., no backpressure applied to it). - Scheduler:
- You specify which
Scheduler
this operator will use for the timed skipping
- Parameters:
time
- the length of the time window to skipunit
- the time unit oftime
scheduler
- theScheduler
on which the timed wait happens- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Skip
-
skipLast
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> skipLast(int count)
Returns aFlowable
that drops a specified number of items from the end of the sequence emitted by the currentFlowable
.This
Subscriber
accumulates a queue long enough to store the firstcount
items. As more items are received, items are taken from the front of the queue and emitted by the resultingFlowable
. This causes such items to be delayed.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
- This version of
skipLast
does not operate by default on a particularScheduler
.
- Parameters:
count
- number of items to drop from the end of the source sequence- Returns:
- the new
Flowable
instance - Throws:
java.lang.IllegalArgumentException
- ifcount
is less than zero- See Also:
- ReactiveX operators documentation: SkipLast
-
skipLast
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> skipLast(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that drops items emitted by the currentFlowable
during a specified time window before the source completes.Note: this action will cache the latest items arriving in the specified time window.
- Backpressure:
- The operator doesn't support backpressure as it uses time to skip an arbitrary number of elements and
thus has to consume the current
Flowable
in an unbounded manner (i.e., no backpressure applied to it). - Scheduler:
skipLast
does not operate on any particular scheduler but uses the current time from thecomputation
Scheduler
.
- Parameters:
time
- the length of the time windowunit
- the time unit oftime
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: SkipLast
-
skipLast
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> skipLast(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, boolean delayError)
Returns aFlowable
that drops items emitted by the currentFlowable
during a specified time window before the source completes.Note: this action will cache the latest items arriving in the specified time window.
- Backpressure:
- The operator doesn't support backpressure as it uses time to skip an arbitrary number of elements and
thus has to consume the current
Flowable
in an unbounded manner (i.e., no backpressure applied to it). - Scheduler:
skipLast
does not operate on any particular scheduler but uses the current time from thecomputation
Scheduler
.
- Parameters:
time
- the length of the time windowunit
- the time unit oftime
delayError
- iftrue
, an exception signaled by the currentFlowable
is delayed until the regular elements are consumed by the downstream; iffalse
, an exception is immediately signaled and all regular elements dropped- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: SkipLast
-
skipLast
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("custom") @NonNull public final @NonNull Flowable<T> skipLast(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns aFlowable
that drops items emitted by the currentFlowable
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.
- Backpressure:
- The operator doesn't support backpressure as it uses time to skip an arbitrary number of elements and
thus has to consume the current
Flowable
in an unbounded manner (i.e., no backpressure applied to it). - Scheduler:
- You specify which
Scheduler
this operator will use for tracking the current time
- Parameters:
time
- the length of the time windowunit
- the time unit oftime
scheduler
- the scheduler used as the time source- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: SkipLast
-
skipLast
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("custom") @NonNull public final @NonNull Flowable<T> skipLast(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, boolean delayError)
Returns aFlowable
that drops items emitted by the currentFlowable
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.
- Backpressure:
- The operator doesn't support backpressure as it uses time to skip an arbitrary number of elements and
thus has to consume the current
Flowable
in an unbounded manner (i.e., no backpressure applied to it). - Scheduler:
- You specify which
Scheduler
this operator will use to track the current time
- Parameters:
time
- the length of the time windowunit
- the time unit oftime
scheduler
- the scheduler used as the time sourcedelayError
- iftrue
, an exception signaled by the currentFlowable
is delayed until the regular elements are consumed by the downstream; iffalse
, an exception is immediately signaled and all regular elements dropped- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: SkipLast
-
skipLast
@CheckReturnValue @NonNull @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("custom") public final @NonNull Flowable<T> skipLast(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, boolean delayError, int bufferSize)
Returns aFlowable
that drops items emitted by the currentFlowable
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.
- Backpressure:
- The operator doesn't support backpressure as it uses time to skip an arbitrary number of elements and
thus has to consume the current
Flowable
in an unbounded manner (i.e., no backpressure applied to it). - Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
time
- the length of the time windowunit
- the time unit oftime
scheduler
- the scheduler used as the time sourcedelayError
- iftrue
, an exception signaled by the currentFlowable
is delayed until the regular elements are consumed by the downstream; iffalse
, an exception is immediately signaled and all regular elements droppedbufferSize
- the hint about how many elements to expect to be skipped- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: SkipLast
-
skipUntil
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final <@NonNull U> @NonNull Flowable<T> skipUntil(@NonNull @NonNull org.reactivestreams.Publisher<@NonNull U> other)
Returns aFlowable
that skips items emitted by the currentFlowable
until a secondPublisher
emits an item.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
skipUntil
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the element type of the otherPublisher
- Parameters:
other
- the secondPublisher
that has to emit an item before the currentFlowable
's elements begin to be mirrored by the resultingFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifother
isnull
- See Also:
- ReactiveX operators documentation: SkipUntil
-
skipWhile
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final @NonNull Flowable<T> skipWhile(@NonNull @NonNull Predicate<? super @NonNull T> predicate)
Returns aFlowable
that skips all items emitted by the currentFlowable
as long as a specified condition holdstrue
, but emits all further source items as soon as the condition becomesfalse
.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
skipWhile
does not operate by default on a particularScheduler
.
- Parameters:
predicate
- a function to test each item emitted from the currentFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifpredicate
isnull
- See Also:
- ReactiveX operators documentation: SkipWhile
-
sorted
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> sorted()
Returns aFlowable
that emits the events emitted by sourcePublisher
, in a sorted order. Each item emitted by thePublisher
must implementComparable
with respect to all other items in the sequence.If any item emitted by this
Flowable
does not implementComparable
with respect to all other items emitted by thisFlowable
, no items will be emitted and the sequence is terminated with aClassCastException
.Note that calling
sorted
with long, non-terminating or infinite sources might causeOutOfMemoryError
- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., without applying backpressure to it). - Scheduler:
sorted
does not operate by default on a particularScheduler
.
- Returns:
- the new
Flowable
instance
-
sorted
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final @NonNull Flowable<T> sorted(@NonNull @NonNull java.util.Comparator<? super @NonNull T> comparator)
Returns aFlowable
that emits the events emitted by sourcePublisher
, in a sorted order based on a specified comparison function.Note that calling
sorted
with long, non-terminating or infinite sources might causeOutOfMemoryError
- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., without applying backpressure to it). - Scheduler:
sorted
does not operate by default on a particularScheduler
.
- Parameters:
comparator
- a function that compares two items emitted by the currentFlowable
and returns anInteger
that indicates their sort order- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifcomparator
isnull
-
startWithIterable
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> startWithIterable(@NonNull @NonNull java.lang.Iterable<? extends @NonNull T> items)
Returns aFlowable
that emits the items in a specifiedIterable
before it begins to emit items emitted by the currentFlowable
.- Backpressure:
- The operator honors backpressure from downstream. The Current
Flowable
is expected to honor backpressure as well. If it violates this rule, it may throw anIllegalStateException
when the currentFlowable
completes. - Scheduler:
startWithIterable
does not operate by default on a particularScheduler
.
- Parameters:
items
- anIterable
that contains the items you want the resultingFlowable
to emit first- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifitems
isnull
- Since:
- 3.0.0
- See Also:
- ReactiveX operators documentation: StartWith,
startWithArray(Object...)
,startWithItem(Object)
-
startWith
@CheckReturnValue @NonNull @SchedulerSupport("none") @BackpressureSupport(FULL) public final @NonNull Flowable<T> startWith(@NonNull @NonNull CompletableSource other)
Returns aFlowable
which first runs the otherCompletableSource
then the currentFlowable
if the other completed normally.- Backpressure:
- The returned
Flowable
honors the backpressure of the downstream consumer. - Scheduler:
startWith
does not operate by default on a particularScheduler
.
- Parameters:
other
- the otherCompletableSource
to run first- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifother
isnull
- Since:
- 3.0.0
-
startWith
@CheckReturnValue @NonNull @SchedulerSupport("none") @BackpressureSupport(FULL) public final @NonNull Flowable<T> startWith(@NonNull @NonNull SingleSource<@NonNull T> other)
Returns aFlowable
which first runs the otherSingleSource
then the currentFlowable
if the other succeeded normally.- Backpressure:
- The returned
Flowable
honors the backpressure of the downstream consumer. - Scheduler:
startWith
does not operate by default on a particularScheduler
.
- Parameters:
other
- the otherSingleSource
to run first- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifother
isnull
- Since:
- 3.0.0
-
startWith
@CheckReturnValue @NonNull @SchedulerSupport("none") @BackpressureSupport(FULL) public final @NonNull Flowable<T> startWith(@NonNull @NonNull MaybeSource<@NonNull T> other)
Returns aFlowable
which first runs the otherMaybeSource
then the currentFlowable
if the other succeeded or completed normally.- Backpressure:
- The returned
Flowable
honors the backpressure of the downstream consumer. - Scheduler:
startWith
does not operate by default on a particularScheduler
.
- Parameters:
other
- the otherMaybeSource
to run first- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifother
isnull
- Since:
- 3.0.0
-
startWith
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final @NonNull Flowable<T> startWith(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> other)
Returns aFlowable
that emits the items in a specifiedPublisher
before it begins to emit items emitted by the currentFlowable
.- Backpressure:
- The operator honors backpressure from downstream. Both this and the
other
Publisher
s are expected to honor backpressure as well. If any of then violates this rule, it may throw anIllegalStateException
when the currentFlowable
completes. - Scheduler:
startWith
does not operate by default on a particularScheduler
.
- Parameters:
other
- aPublisher
that contains the items you want the modifiedPublisher
to emit first- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifother
isnull
- See Also:
- ReactiveX operators documentation: StartWith
-
startWithItem
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final @NonNull Flowable<T> startWithItem(@NonNull @NonNull T item)
Returns aFlowable
that emits a specified item before it begins to emit items emitted by the currentFlowable
.- Backpressure:
- The operator honors backpressure from downstream. The current
Flowable
is expected to honor backpressure as well. If it violates this rule, it may throw anIllegalStateException
when the currentFlowable
completes. - Scheduler:
startWithItem
does not operate by default on a particularScheduler
.
- Parameters:
item
- the item to emit first- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifitem
isnull
- Since:
- 3.0.0
- See Also:
- ReactiveX operators documentation: StartWith,
startWithArray(Object...)
,startWithIterable(Iterable)
-
startWithArray
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @SafeVarargs @NonNull public final @NonNull Flowable<T> startWithArray(@NonNull @NonNull T... items)
Returns aFlowable
that emits the specified items before it begins to emit items emitted by the currentFlowable
.- Backpressure:
- The operator honors backpressure from downstream. The current
Flowable
is expected to honor backpressure as well. If it violates this rule, it may throw anIllegalStateException
when the currentFlowable
completes. - Scheduler:
startWithArray
does not operate by default on a particularScheduler
.
- Parameters:
items
- the array of values to emit first- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifitems
isnull
- See Also:
- ReactiveX operators documentation: StartWith,
startWithItem(Object)
,startWithIterable(Iterable)
-
subscribe
@BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final @NonNull Disposable subscribe()
Subscribes to the currentFlowable
and ignoresonNext
andonComplete
emissions.If the
Flowable
emits an error, it is wrapped into anOnErrorNotImplementedException
and routed to theRxJavaPlugins.onError(Throwable)
handler.- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner (i.e., no backpressure is applied to it). - Scheduler:
subscribe
does not operate by default on a particularScheduler
.
- Returns:
- the new
Disposable
instance that allows cancelling the flow - See Also:
- ReactiveX operators documentation: Subscribe,
subscribe(Consumer, Consumer, Action, DisposableContainer)
-
subscribe
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final @NonNull Disposable subscribe(@NonNull @NonNull Consumer<? super @NonNull T> onNext)
Subscribes to the currentFlowable
and provides a callback to handle the items it emits.If the
Flowable
emits an error, it is wrapped into anOnErrorNotImplementedException
and routed to theRxJavaPlugins.onError(Throwable)
handler.- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner (i.e., no backpressure is applied to it). - Scheduler:
subscribe
does not operate by default on a particularScheduler
.
- Parameters:
onNext
- theConsumer<T>
you have designed to accept emissions from the currentFlowable
- Returns:
- the new
Disposable
instance that allows cancelling the flow - Throws:
java.lang.NullPointerException
- ifonNext
isnull
- See Also:
- ReactiveX operators documentation: Subscribe,
subscribe(Consumer, Consumer, Action, DisposableContainer)
-
subscribe
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final @NonNull Disposable subscribe(@NonNull @NonNull Consumer<? super @NonNull T> onNext, @NonNull @NonNull Consumer<? super java.lang.Throwable> onError)
Subscribes to the currentFlowable
and provides callbacks to handle the items it emits and any error notification it issues.- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner (i.e., no backpressure is applied to it). - Scheduler:
subscribe
does not operate by default on a particularScheduler
.
- Parameters:
onNext
- theConsumer<T>
you have designed to accept emissions from the currentFlowable
onError
- theConsumer<Throwable>
you have designed to accept any error notification from the currentFlowable
- Returns:
- the new
Disposable
instance that allows cancelling the flow - Throws:
java.lang.NullPointerException
- ifonNext
oronError
isnull
- See Also:
- ReactiveX operators documentation: Subscribe,
subscribe(Consumer, Consumer, Action, DisposableContainer)
-
subscribe
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @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)
Subscribes to the currentFlowable
and provides callbacks to handle the items it emits and any error or completion notification it issues.- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner (i.e., no backpressure is applied to it). - Scheduler:
subscribe
does not operate by default on a particularScheduler
.
- Parameters:
onNext
- theConsumer<T>
you have designed to accept emissions from the currentFlowable
onError
- theConsumer<Throwable>
you have designed to accept any error notification from the currentFlowable
onComplete
- theAction
you have designed to accept a completion notification from the the currentFlowable
- Returns:
- the new
Disposable
instance that allows cancelling the flow - Throws:
java.lang.NullPointerException
- ifonNext
,onError
oronComplete
isnull
- See Also:
- ReactiveX operators documentation: Subscribe,
subscribe(Consumer, Consumer, Action, DisposableContainer)
-
subscribe
@BackpressureSupport(SPECIAL) @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 aDisposable
Subscriber
, adds it to the givenDisposableContainer
and ensures, that if the upstream terminates or this particularDisposable
is disposed, theSubscriber
is removed from the given container.The
Subscriber
will be removed after the callback for the terminal event has been invoked.- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner (i.e., no backpressure is applied to it). - Scheduler:
subscribe
does not operate by default on a particularScheduler
.
- Parameters:
onNext
- the callback for upstream itemsonError
- the callback for an upstream error if anyonComplete
- the callback for the upstream completion if anycontainer
- theDisposableContainer
(such asCompositeDisposable
) to add and remove the createdDisposable
Subscriber
- Returns:
- the
Disposable
that allows disposing the particular subscription. - Throws:
java.lang.NullPointerException
- ifonNext
,onError
,onComplete
orcontainer
isnull
- Since:
- 3.1.0
-
subscribe
@BackpressureSupport(SPECIAL) @SchedulerSupport("none") public final void subscribe(@NonNull @NonNull org.reactivestreams.Subscriber<? super @NonNull T> subscriber)
- Specified by:
subscribe
in interfaceorg.reactivestreams.Publisher<T>
-
subscribe
@BackpressureSupport(SPECIAL) @SchedulerSupport("none") public final void subscribe(@NonNull @NonNull FlowableSubscriber<? super @NonNull T> subscriber)
Establish a connection between thisFlowable
and the givenFlowableSubscriber
and start streaming events based on the demand of theFlowableSubscriber
.This is a "factory method" and can be called multiple times, each time starting a new
Subscription
.Each
Subscription
will work for only a singleFlowableSubscriber
.If the same
FlowableSubscriber
instance is subscribed to multipleFlowable
s and/or the sameFlowable
multiple times, it must ensure the serialization over itsonXXX
methods manually.If the
Flowable
rejects the subscription attempt or otherwise fails it will signal the error viaSubscriber.onError(Throwable)
.This subscribe method relaxes the following Reactive Streams rules:
- §1.3:
onNext
should not be called concurrently untilonSubscribe
returns.FlowableSubscriber.onSubscribe(Subscription)
should make sure a sync or async call triggered by request() is safe. - §2.3:
onError
oronComplete
must not call cancel. Calling request() or cancel() is NOP at this point. - §2.12:
onSubscribe
must be called at most once on the same instance.FlowableSubscriber
reuse is not checked and if happens, it is the responsibility of theFlowableSubscriber
to ensure proper serialization of its onXXX methods. - §3.9: negative requests should emit an
onError(IllegalArgumentException)
. Non-positive requests signal viaRxJavaPlugins.onError(Throwable)
and the stream is not affected.
- Backpressure:
- The backpressure behavior/expectation is determined by the supplied
FlowableSubscriber
. - Scheduler:
subscribe
does not operate by default on a particularScheduler
.
History: 2.0.7 - experimental; 2.1 - beta
- Parameters:
subscriber
- theFlowableSubscriber
that will consume signals from thisFlowable
- Throws:
java.lang.NullPointerException
- ifsubscriber
isnull
- Since:
- 2.2
- §1.3:
-
subscribeActual
protected abstract void subscribeActual(@NonNull @NonNull org.reactivestreams.Subscriber<? super @NonNull T> subscriber)
Operator implementations (both source and intermediate) should implement this method that performs the necessary business logic and handles the incomingSubscriber
s.There is no need to call any of the plugin hooks on the current
Flowable
instance or theSubscriber
; all hooks and basic safeguards have been applied bysubscribe(Subscriber)
before this method gets called.- Parameters:
subscriber
- the incomingSubscriber
, nevernull
-
subscribeWith
@CheckReturnValue @BackpressureSupport(SPECIAL) @SchedulerSupport("none") @NonNull public final <@NonNull E extends org.reactivestreams.Subscriber<? super @NonNull T>> E subscribeWith(@NonNull E subscriber)
Subscribes a givenSubscriber
(subclass) to thisFlowable
and returns the givenSubscriber
as is.Usage example:
Flowable<Integer> source = Flowable.range(1, 10); CompositeDisposable composite = new CompositeDisposable(); ResourceSubscriber<Integer> rs = new ResourceSubscriber<>() { // ... }; composite.add(source.subscribeWith(rs));
- Backpressure:
- The backpressure behavior/expectation is determined by the supplied
Subscriber
. - Scheduler:
subscribeWith
does not operate by default on a particularScheduler
.
- Type Parameters:
E
- the type of theSubscriber
to use and return- Parameters:
subscriber
- theSubscriber
(subclass) to use and return, notnull
- Returns:
- the input
subscriber
- Throws:
java.lang.NullPointerException
- ifsubscriber
isnull
- Since:
- 2.0
-
subscribeOn
@CheckReturnValue @NonNull @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("custom") public final @NonNull Flowable<T> subscribeOn(@NonNull @NonNull Scheduler scheduler)
Asynchronously subscribesSubscriber
s to the currentFlowable
on the specifiedScheduler
.If there is a
create(FlowableOnSubscribe, BackpressureStrategy)
type source up in the chain, it is recommended to usesubscribeOn(scheduler, false)
instead to avoid same-pool deadlock because requests may pile up behind an eager/blocking emitter.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
scheduler
- theScheduler
to perform subscription actions on- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifscheduler
isnull
- See Also:
- ReactiveX operators documentation: SubscribeOn,
RxJava Threading Examples,
observeOn(io.reactivex.rxjava3.core.Scheduler)
,subscribeOn(Scheduler, boolean)
-
subscribeOn
@CheckReturnValue @NonNull @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("custom") public final @NonNull Flowable<T> subscribeOn(@NonNull @NonNull Scheduler scheduler, boolean requestOn)
Asynchronously subscribesSubscriber
s to the currentFlowable
on the specifiedScheduler
optionally reroutes requests from other threads to the sameScheduler
thread.If there is a
create(FlowableOnSubscribe, BackpressureStrategy)
type source up in the chain, it is recommended to haverequestOn
false
to avoid same-pool deadlock because requests may pile up behind an eager/blocking emitter.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
- You specify which
Scheduler
this operator will use.
History: 2.1.1 - experimental
- Parameters:
scheduler
- theScheduler
to perform subscription actions onrequestOn
- iftrue
, requests are rerouted to the givenScheduler
as well (strong pipelining) iffalse
, requests coming from any thread are simply forwarded to the upstream on the same thread (weak pipelining)- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifscheduler
isnull
- Since:
- 2.2
- See Also:
- ReactiveX operators documentation: SubscribeOn,
RxJava Threading Examples,
observeOn(io.reactivex.rxjava3.core.Scheduler)
-
switchIfEmpty
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final @NonNull Flowable<T> switchIfEmpty(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> other)
Returns aFlowable
that emits the items emitted by the currentFlowable
or the items of an alternatePublisher
if the currentFlowable
is empty.- Backpressure:
- If the current
Flowable
is empty, the alternatePublisher
is expected to honor backpressure. If the currentFlowable
is non-empty, it is expected to honor backpressure as instead. In either case, if violated, aMissingBackpressureException
may get signaled somewhere downstream. - Scheduler:
switchIfEmpty
does not operate by default on a particularScheduler
.
- Parameters:
other
- the alternatePublisher
to subscribe to if the source does not emit any items- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifother
isnull
- Since:
- 1.1.0
-
switchMap
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Flowable<R> switchMap(@NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper)
Returns a newFlowable
by applying a function that you supply to each item emitted by the currentFlowable
that returns aPublisher
, and then emitting the items emitted by the most recently emitted of thesePublisher
s.The resulting
Flowable
completes if both the currentFlowable
and the last innerPublisher
, if any, complete. If the currentFlowable
signals anonError
, the innerPublisher
is canceled and the error delivered in-sequence.- Backpressure:
- The operator honors backpressure from downstream. The outer
Publisher
is consumed in an unbounded manner (i.e., without backpressure) and the innerPublisher
s are expected to honor backpressure but it is not enforced; the operator won't signal aMissingBackpressureException
but the violation may lead toOutOfMemoryError
due to internal buffer bloat. - Scheduler:
switchMap
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the element type of the innerPublisher
s and the output- Parameters:
mapper
- a function that, when applied to an item emitted by the currentFlowable
, returns aPublisher
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- See Also:
- ReactiveX operators documentation: FlatMap,
switchMapDelayError(Function)
-
switchMap
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Flowable<R> switchMap(@NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper, int bufferSize)
Returns a newFlowable
by applying a function that you supply to each item emitted by the currentFlowable
that returns aPublisher
, and then emitting the items emitted by the most recently emitted of thesePublisher
s.The resulting
Flowable
completes if both the currentFlowable
and the last innerPublisher
, if any, complete. If the currentFlowable
signals anonError
, the innerPublisher
is canceled and the error delivered in-sequence.- Backpressure:
- The operator honors backpressure from downstream. The outer
Publisher
is consumed in an unbounded manner (i.e., without backpressure) and the innerPublisher
s are expected to honor backpressure but it is not enforced; the operator won't signal aMissingBackpressureException
but the violation may lead toOutOfMemoryError
due to internal buffer bloat. - Scheduler:
switchMap
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the element type of the innerPublisher
s and the output- Parameters:
mapper
- a function that, when applied to an item emitted by the currentFlowable
, returns aPublisher
bufferSize
- the number of elements to prefetch from the current active innerPublisher
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: FlatMap,
switchMapDelayError(Function, int)
-
switchMapCompletable
@CheckReturnValue @NonNull @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") public final @NonNull Completable switchMapCompletable(@NonNull @NonNull Function<? super @NonNull T,? extends CompletableSource> mapper)
Maps the upstream values intoCompletableSource
s, subscribes to the newer one while disposing the subscription to the previousCompletableSource
, thus keeping at most one activeCompletableSource
running.Since a
CompletableSource
doesn't produce any items, the resulting reactive type of this operator is aCompletable
that can only indicate successful completion or a failure in any of the innerCompletableSource
s or the failure of the currentFlowable
.- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner and otherwise does not have backpressure in its return type because no items are ever produced. - Scheduler:
switchMapCompletable
does not operate by default on a particularScheduler
.- Error handling:
- If either this
Flowable
or the activeCompletableSource
signals anonError
, the resultingCompletable
is terminated immediately with thatThrowable
. Use theswitchMapCompletableDelayError(Function)
to delay such inner failures until every innerCompletableSource
s and the mainFlowable
terminates in some fashion. If they fail concurrently, the operator may combine theThrowable
s into aCompositeException
and signal it to the downstream instead. If any inactivated (switched out)CompletableSource
signals anonError
late, theThrowable
s will be signaled to the global error handler viaRxJavaPlugins.onError(Throwable)
method asUndeliverableException
errors.
History: 2.1.11 - experimental
- Parameters:
mapper
- the function called with each upstream item and should return aCompletableSource
to be subscribed to and awaited for (non blockingly) for its terminal event- Returns:
- the new
Completable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.2
- See Also:
switchMapCompletableDelayError(Function)
-
switchMapCompletableDelayError
@CheckReturnValue @NonNull @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") public final @NonNull Completable switchMapCompletableDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends CompletableSource> mapper)
Maps the upstream values intoCompletableSource
s, subscribes to the newer one while disposing the subscription to the previousCompletableSource
, thus keeping at most one activeCompletableSource
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 aCompletable
that can only indicate successful completion or a failure in any of the innerCompletableSource
s or the failure of the currentFlowable
.- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner and otherwise does not have backpressure in its return type because no items are ever produced. - Scheduler:
switchMapCompletableDelayError
does not operate by default on a particularScheduler
.- Error handling:
- The errors of this
Flowable
and all theCompletableSource
s, who had the chance to run to their completion, are delayed until all of them terminate in some fashion. At this point, if there was only one failure, the respectiveThrowable
is emitted to the downstream. If there was more than one failure, the operator combines allThrowable
s into aCompositeException
and signals that to the downstream. If any inactivated (switched out)CompletableSource
signals anonError
late, theThrowable
s will be signaled to the global error handler viaRxJavaPlugins.onError(Throwable)
method asUndeliverableException
errors.
History: 2.1.11 - experimental
- Parameters:
mapper
- the function called with each upstream item and should return aCompletableSource
to be subscribed to and awaited for (non blockingly) for its terminal event- Returns:
- the new
Completable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.2
- See Also:
switchMapCompletable(Function)
-
switchMapDelayError
@CheckReturnValue @BackpressureSupport(SPECIAL) @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Flowable<R> switchMapDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper)
Returns a newFlowable
by applying a function that you supply to each item emitted by the currentFlowable
that returns aPublisher
, and then emitting the items emitted by the most recently emitted of thesePublisher
s and delays any error until allPublisher
s terminate.The resulting
Flowable
completes if both the currentFlowable
and the last innerPublisher
, if any, complete. If the currentFlowable
signals anonError
, the termination of the last innerPublisher
will emit that error as is or wrapped into aCompositeException
along with the other possible errors the former innerPublisher
s signaled.- Backpressure:
- The operator honors backpressure from downstream. The outer
Publisher
is consumed in an unbounded manner (i.e., without backpressure) and the innerPublisher
s are expected to honor backpressure but it is not enforced; the operator won't signal aMissingBackpressureException
but the violation may lead toOutOfMemoryError
due to internal buffer bloat. - Scheduler:
switchMapDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the element type of the innerPublisher
s and the output- Parameters:
mapper
- a function that, when applied to an item emitted by the currentFlowable
, returns aPublisher
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: FlatMap,
switchMap(Function)
-
switchMapDelayError
@CheckReturnValue @BackpressureSupport(SPECIAL) @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Flowable<R> switchMapDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends @NonNull R>> mapper, int bufferSize)
Returns a newFlowable
by applying a function that you supply to each item emitted by the currentFlowable
that returns aPublisher
, and then emitting the items emitted by the most recently emitted of thesePublisher
s and delays any error until allPublisher
s terminate.The resulting
Flowable
completes if both the currentFlowable
and the last innerPublisher
, if any, complete. If the currentFlowable
signals anonError
, the termination of the last innerPublisher
will emit that error as is or wrapped into aCompositeException
along with the other possible errors the former innerPublisher
s signaled.- Backpressure:
- The operator honors backpressure from downstream. The outer
Publisher
is consumed in an unbounded manner (i.e., without backpressure) and the innerPublisher
s are expected to honor backpressure but it is not enforced; the operator won't signal aMissingBackpressureException
but the violation may lead toOutOfMemoryError
due to internal buffer bloat. - Scheduler:
switchMapDelayError
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the element type of the innerPublisher
s and the output- Parameters:
mapper
- a function that, when applied to an item emitted by the currentFlowable
, returns aPublisher
bufferSize
- the number of elements to prefetch from the current active innerPublisher
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: FlatMap,
switchMap(Function, int)
-
switchMap0
<R> Flowable<R> switchMap0(Function<? super @NonNull T,? extends org.reactivestreams.Publisher<? extends R>> mapper, int bufferSize, boolean delayError)
-
switchMapMaybe
@CheckReturnValue @NonNull @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") public final <@NonNull R> @NonNull Flowable<R> switchMapMaybe(@NonNull @NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper)
Maps the upstream items intoMaybeSource
s 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 thisFlowable
or any of the active innerMaybeSource
s fail.- Backpressure:
- The operator honors backpressure from downstream. The main
Flowable
is consumed in an unbounded manner (i.e., without backpressure). - Scheduler:
switchMapMaybe
does not operate by default on a particularScheduler
.- Error handling:
- This operator terminates with an
onError
if thisFlowable
or any of the innerMaybeSource
s fail while they are active. When this happens concurrently, their individualThrowable
errors may get combined and emitted as a singleCompositeException
. Otherwise, a late (i.e., inactive or switched out)onError
from thisFlowable
or from any of the innerMaybeSource
s will be forwarded to the global error handler viaRxJavaPlugins.onError(Throwable)
asUndeliverableException
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 aMaybeSource
to replace the current active inner source and get subscribed to.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.2
- See Also:
switchMapMaybeDelayError(Function)
-
switchMapMaybeDelayError
@CheckReturnValue @NonNull @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") public final <@NonNull R> @NonNull Flowable<R> switchMapMaybeDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends MaybeSource<? extends @NonNull R>> mapper)
Maps the upstream items intoMaybeSource
s 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 thisFlowable
or the innerMaybeSource
s until all terminate.- Backpressure:
- The operator honors backpressure from downstream. The main
Flowable
is consumed in an unbounded manner (i.e., without backpressure). - Scheduler:
switchMapMaybeDelayError
does not operate by default on a particularScheduler
.
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 aMaybeSource
to replace the current active inner source and get subscribed to.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.2
- See Also:
switchMapMaybe(Function)
-
switchMapSingle
@CheckReturnValue @NonNull @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") public final <@NonNull R> @NonNull Flowable<R> switchMapSingle(@NonNull @NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper)
Maps the upstream items intoSingleSource
s 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 while failing immediately if thisFlowable
or any of the active innerSingleSource
s fail.- Backpressure:
- The operator honors backpressure from downstream. The main
Flowable
is consumed in an unbounded manner (i.e., without backpressure). - Scheduler:
switchMapSingle
does not operate by default on a particularScheduler
.- Error handling:
- This operator terminates with an
onError
if thisFlowable
or any of the innerSingleSource
s fail while they are active. When this happens concurrently, their individualThrowable
errors may get combined and emitted as a singleCompositeException
. Otherwise, a late (i.e., inactive or switched out)onError
from thisFlowable
or from any of the innerSingleSource
s will be forwarded to the global error handler viaRxJavaPlugins.onError(Throwable)
asUndeliverableException
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 aSingleSource
to replace the current active inner source and get subscribed to.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.2
- See Also:
switchMapSingleDelayError(Function)
-
switchMapSingleDelayError
@CheckReturnValue @NonNull @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") public final <@NonNull R> @NonNull Flowable<R> switchMapSingleDelayError(@NonNull @NonNull Function<? super @NonNull T,? extends SingleSource<? extends @NonNull R>> mapper)
Maps the upstream items intoSingleSource
s 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, delaying errors from thisFlowable
or the innerSingleSource
s until all terminate.- Backpressure:
- The operator honors backpressure from downstream. The main
Flowable
is consumed in an unbounded manner (i.e., without backpressure). - Scheduler:
switchMapSingleDelayError
does not operate by default on a particularScheduler
.
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 aSingleSource
to replace the current active inner source and get subscribed to.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 2.2
- See Also:
switchMapSingle(Function)
-
take
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> take(long count)
Returns aFlowable
that emits only the firstcount
items emitted by the currentFlowable
. If the source emits fewer thancount
items then all of its items are emitted.This method returns a
Flowable
that will invoke a subscribingSubscriber
'sonNext
function a maximum ofcount
times before invokingonComplete
.Limits both the number of upstream items (after which the sequence completes) and the total downstream request amount requested from the upstream to possibly prevent the creation of excess items by the upstream.
The operator requests at most the given
count
of items from upstream even if the downstream requests more than that. For example, given atake(5)
, if the downstream requests 1, a request of 1 is submitted to the upstream and the operator remembers that only 4 items can be requested now on. A request of 5 at this point will request 4 from the upstream and any subsequent requests will be ignored.Note that requests are negotiated on an operator boundary and
take
's amount may not be preserved further upstream. For example,source.observeOn(Schedulers.computation()).take(5)
will still request the default (128) elements from the givensource
.- Backpressure:
- The current
Flowable
is consumed in a bounded manner. - Scheduler:
- This version of
take
does not operate by default on a particularScheduler
.
- Parameters:
count
- the maximum number of items and the total request amount, non-negative. Zero will immediately cancel the upstream on subscription and complete the downstream.- Returns:
- the new
Flowable
instance - Throws:
java.lang.IllegalArgumentException
- ifcount
is negative- See Also:
- ReactiveX operators documentation: Take
-
take
@CheckReturnValue @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Flowable<T> take(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits those items emitted by sourcePublisher
before a specified time runs out.If time runs out before the
Flowable
completes normally, theonComplete
event will be signaled on the defaultcomputation
Scheduler
.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
- This version of
take
operates by default on thecomputation
Scheduler
.
- Parameters:
time
- the length of the time windowunit
- the time unit oftime
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Take
-
take
@CheckReturnValue @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("custom") @NonNull public final @NonNull Flowable<T> take(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns aFlowable
that emits those items emitted by sourcePublisher
before a specified time (on a specifiedScheduler
) runs out.If time runs out before the
Flowable
completes normally, theonComplete
event will be signaled on the providedScheduler
.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
time
- the length of the time windowunit
- the time unit oftime
scheduler
- theScheduler
used for time source- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Take
-
takeLast
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> takeLast(int count)
Returns aFlowable
that emits at most the lastcount
items emitted by the currentFlowable
. If the source emits fewer thancount
items then all of its items are emitted.- Backpressure:
- The operator honors backpressure from downstream if the
count
is non-zero; ignores backpressure if thecount
is zero as it doesn't signal any values. - Scheduler:
- This version of
takeLast
does not operate by default on a particularScheduler
.
- Parameters:
count
- the maximum number of items to emit from the end of the sequence of items emitted by the currentFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.IllegalArgumentException
- ifcount
is negative- See Also:
- ReactiveX operators documentation: TakeLast
-
takeLast
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<T> takeLast(long count, long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits at most a specified number of items from the currentFlowable
that were emitted in a specified window of time before the currentFlowable
completed.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., no backpressure is applied to it). - Scheduler:
takeLast
does not operate on any particular scheduler but uses the current time from thecomputation
Scheduler
.
- Parameters:
count
- the maximum number of items to emittime
- the length of the time windowunit
- the time unit oftime
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
java.lang.IllegalArgumentException
- ifcount
is negative- See Also:
- ReactiveX operators documentation: TakeLast
-
takeLast
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("custom") @NonNull public final @NonNull Flowable<T> takeLast(long count, long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns aFlowable
that emits at most a specified number of items from the currentFlowable
that were emitted in a specified window of time before the currentFlowable
completed, where the timing information is provided by a givenScheduler
.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., no backpressure is applied to it). - Scheduler:
- You specify which
Scheduler
this operator will use for tracking the current time
- Parameters:
count
- the maximum number of items to emittime
- the length of the time windowunit
- the time unit oftime
scheduler
- theScheduler
that provides the timestamps for the observed items- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
java.lang.IllegalArgumentException
- ifcount
is less than zero- See Also:
- ReactiveX operators documentation: TakeLast
-
takeLast
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("custom") public final @NonNull Flowable<T> takeLast(long count, long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, boolean delayError, int bufferSize)
Returns aFlowable
that emits at most a specified number of items from the currentFlowable
that were emitted in a specified window of time before the currentFlowable
completed, where the timing information is provided by a givenScheduler
.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., no backpressure is applied to it). - Scheduler:
- You specify which
Scheduler
this operator will use for tracking the current time
- Parameters:
count
- the maximum number of items to emittime
- the length of the time windowunit
- the time unit oftime
scheduler
- theScheduler
that provides the timestamps for the observed itemsdelayError
- iftrue
, an exception signaled by the currentFlowable
is delayed until the regular elements are consumed by the downstream; iffalse
, an exception is immediately signaled and all regular elements droppedbufferSize
- the hint about how many elements to expect to be last- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
java.lang.IllegalArgumentException
- ifcount
is negative orbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: TakeLast
-
takeLast
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Flowable<T> takeLast(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits the items from the currentFlowable
that were emitted in a specified window of time before the currentFlowable
completed.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., no backpressure is applied to it) but note that this may lead toOutOfMemoryError
due to internal buffer bloat. Consider usingtakeLast(long, long, TimeUnit)
in this case. - Scheduler:
- This version of
takeLast
operates by default on thecomputation
Scheduler
.
- Parameters:
time
- the length of the time windowunit
- the time unit oftime
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: TakeLast
-
takeLast
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Flowable<T> takeLast(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, boolean delayError)
Returns aFlowable
that emits the items from the currentFlowable
that were emitted in a specified window of time before the currentFlowable
completed.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., no backpressure is applied to it) but note that this may lead toOutOfMemoryError
due to internal buffer bloat. Consider usingtakeLast(long, long, TimeUnit)
in this case. - Scheduler:
- This version of
takeLast
operates by default on thecomputation
Scheduler
.
- Parameters:
time
- the length of the time windowunit
- the time unit oftime
delayError
- iftrue
, an exception signaled by the currentFlowable
is delayed until the regular elements are consumed by the downstream; iffalse
, an exception is immediately signaled and all regular elements dropped- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: TakeLast
-
takeLast
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("custom") @NonNull public final @NonNull Flowable<T> takeLast(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns aFlowable
that emits the items from the currentFlowable
that were emitted in a specified window of time before the currentFlowable
completed, where the timing information is provided by a specifiedScheduler
.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., no backpressure is applied to it) but note that this may lead toOutOfMemoryError
due to internal buffer bloat. Consider usingtakeLast(long, long, TimeUnit, Scheduler)
in this case. - Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
time
- the length of the time windowunit
- the time unit oftime
scheduler
- theScheduler
that provides the timestamps for the observed items- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: TakeLast
-
takeLast
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("custom") @NonNull public final @NonNull Flowable<T> takeLast(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, boolean delayError)
Returns aFlowable
that emits the items from the currentFlowable
that were emitted in a specified window of time before the currentFlowable
completed, where the timing information is provided by a specifiedScheduler
.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., no backpressure is applied to it) but note that this may lead toOutOfMemoryError
due to internal buffer bloat. Consider usingtakeLast(long, long, TimeUnit, Scheduler)
in this case. - Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
time
- the length of the time windowunit
- the time unit oftime
scheduler
- theScheduler
that provides the timestamps for the observed itemsdelayError
- iftrue
, an exception signaled by the currentFlowable
is delayed until the regular elements are consumed by the downstream; iffalse
, an exception is immediately signaled and all regular elements dropped- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: TakeLast
-
takeLast
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("custom") @NonNull public final @NonNull Flowable<T> takeLast(long time, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, boolean delayError, int bufferSize)
Returns aFlowable
that emits the items from the currentFlowable
that were emitted in a specified window of time before the currentFlowable
completed, where the timing information is provided by a specifiedScheduler
.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., no backpressure is applied to it) but note that this may lead toOutOfMemoryError
due to internal buffer bloat. Consider usingtakeLast(long, long, TimeUnit, Scheduler)
in this case. - Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
time
- the length of the time windowunit
- the time unit oftime
scheduler
- theScheduler
that provides the timestamps for the observed itemsdelayError
- iftrue
, an exception signaled by the currentFlowable
is delayed until the regular elements are consumed by the downstream; iffalse
, an exception is immediately signaled and all regular elements droppedbufferSize
- the hint about how many elements to expect to be last- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: TakeLast
-
takeUntil
@CheckReturnValue @NonNull @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") public final @NonNull Flowable<T> takeUntil(@NonNull @NonNull Predicate<? super @NonNull T> stopPredicate)
Returns aFlowable
that emits items emitted by the currentFlowable
, checks the specified predicate for each item, and then completes when the condition is satisfied.The difference between this operator and
takeWhile(Predicate)
is that here, the condition is evaluated after the item is emitted.- Backpressure:
- The operator is a pass-through for backpressure; the backpressure behavior is determined by the upstream source and the downstream consumer.
- Scheduler:
takeUntil
does not operate by default on a particularScheduler
.
- Parameters:
stopPredicate
- a function that evaluates an item emitted by the currentFlowable
and returns aBoolean
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifstopPredicate
isnull
- Since:
- 1.1.0
- See Also:
- ReactiveX operators documentation: TakeUntil,
takeWhile(Predicate)
-
takeUntil
@CheckReturnValue @NonNull @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") public final <@NonNull U> @NonNull Flowable<T> takeUntil(@NonNull @NonNull org.reactivestreams.Publisher<@NonNull U> other)
Returns aFlowable
that emits the items emitted by the currentFlowable
until a secondPublisher
emits an item or completes.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
takeUntil
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the type of items emitted byother
- Parameters:
other
- thePublisher
whose first emitted item or completion will causetakeUntil
to stop emitting items from the currentFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifother
isnull
- See Also:
- ReactiveX operators documentation: TakeUntil
-
takeWhile
@CheckReturnValue @NonNull @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") public final @NonNull Flowable<T> takeWhile(@NonNull @NonNull Predicate<? super @NonNull T> predicate)
Returns aFlowable
that emits items emitted by the currentFlowable
so long as each item satisfied a specified condition, and then completes as soon as this condition is not satisfied.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
takeWhile
does not operate by default on a particularScheduler
.
- Parameters:
predicate
- a function that evaluates an item emitted by the currentFlowable
and returns aBoolean
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifpredicate
isnull
- See Also:
- ReactiveX operators documentation: TakeWhile,
takeUntil(Predicate)
-
throttleFirst
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Flowable<T> throttleFirst(long windowDuration, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits only the first item emitted by the currentFlowable
during sequential time windows of a specified duration.This differs from
throttleLast(long, java.util.concurrent.TimeUnit)
in that this only tracks the passage of time whereasthrottleLast(long, java.util.concurrent.TimeUnit)
ticks at scheduled intervals.- Backpressure:
- This operator does not support backpressure as it uses time to control data flow.
- Scheduler:
throttleFirst
operates by default on thecomputation
Scheduler
.
- Parameters:
windowDuration
- time to wait before emitting another item after emitting the last itemunit
- the unit of time ofwindowDuration
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Sample, RxJava wiki: Backpressure
-
throttleFirst
@CheckReturnValue @NonNull @BackpressureSupport(ERROR) @SchedulerSupport("custom") public final @NonNull Flowable<T> throttleFirst(long skipDuration, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns aFlowable
that emits only the first item emitted by the currentFlowable
during sequential time windows of a specified duration, where the windows are managed by a specifiedScheduler
.This differs from
throttleLast(long, java.util.concurrent.TimeUnit)
in that this only tracks the passage of time whereasthrottleLast(long, java.util.concurrent.TimeUnit)
ticks at scheduled intervals.- Backpressure:
- This operator does not support backpressure as it uses time to control data flow.
- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
skipDuration
- time to wait before emitting another item after emitting the last itemunit
- the unit of time ofskipDuration
scheduler
- theScheduler
to use internally to manage the timers that handle timeout for each event- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Sample, RxJava wiki: Backpressure
-
throttleFirst
@CheckReturnValue @NonNull @BackpressureSupport(ERROR) @SchedulerSupport("custom") public final @NonNull Flowable<T> throttleFirst(long skipDuration, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, @NonNull @NonNull Consumer<? super @NonNull T> onDropped)
Returns aFlowable
that emits only the first item emitted by the currentFlowable
during sequential time windows of a specified duration, where the windows are managed by a specifiedScheduler
.This differs from
throttleLast(long, java.util.concurrent.TimeUnit)
in that this only tracks the passage of time whereasthrottleLast(long, java.util.concurrent.TimeUnit)
ticks at scheduled intervals.- Backpressure:
- This operator does not support backpressure as it uses time to control data flow.
- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
skipDuration
- time to wait before emitting another item after emitting the last itemunit
- the unit of time ofskipDuration
scheduler
- theScheduler
to use internally to manage the timers that handle timeout for each eventonDropped
- called when an item doesn't get delivered to the downstream- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
oronDropped
isnull
- Since:
- 3.1.6 - Experimental
- See Also:
- ReactiveX operators documentation: Sample, RxJava wiki: Backpressure
-
throttleLast
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Flowable<T> throttleLast(long intervalDuration, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits only the last item emitted by the currentFlowable
during sequential time windows of a specified duration.This differs from
throttleFirst(long, java.util.concurrent.TimeUnit)
in that this ticks along at a scheduled interval whereasthrottleFirst(long, java.util.concurrent.TimeUnit)
does not tick, it just tracks the passage of time.- Backpressure:
- This operator does not support backpressure as it uses time to control data flow.
- Scheduler:
throttleLast
operates by default on thecomputation
Scheduler
.
- Parameters:
intervalDuration
- duration of windows within which the last item emitted by the currentFlowable
will be emittedunit
- the unit of time ofintervalDuration
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Sample,
RxJava wiki: Backpressure,
sample(long, TimeUnit)
-
throttleLast
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("custom") @NonNull public final @NonNull Flowable<T> throttleLast(long intervalDuration, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns aFlowable
that emits only the last item emitted by the currentFlowable
during sequential time windows of a specified duration, where the duration is governed by a specifiedScheduler
.This differs from
throttleFirst(long, TimeUnit, Scheduler)
in that this ticks along at a scheduled interval whereasthrottleFirst
does not tick, it just tracks the passage of time.- Backpressure:
- This operator does not support backpressure as it uses time to control data flow.
- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
intervalDuration
- duration of windows within which the last item emitted by the currentFlowable
will be emittedunit
- the unit of time ofintervalDuration
scheduler
- theScheduler
to use internally to manage the timers that handle timeout for each event- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Sample,
RxJava wiki: Backpressure,
sample(long, TimeUnit, Scheduler)
-
throttleLast
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("custom") @NonNull public final @NonNull Flowable<T> throttleLast(long intervalDuration, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, @NonNull @NonNull Consumer<? super @NonNull T> onDropped)
Returns aFlowable
that emits only the last item emitted by the currentFlowable
during sequential time windows of a specified duration, where the duration is governed by a specifiedScheduler
.This differs from
throttleFirst(long, TimeUnit, Scheduler)
in that this ticks along at a scheduled interval whereasthrottleFirst
does not tick, it just tracks the passage of time.- Backpressure:
- This operator does not support backpressure as it uses time to control data flow.
- Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
intervalDuration
- duration of windows within which the last item emitted by the currentFlowable
will be emittedunit
- the unit of time ofintervalDuration
scheduler
- theScheduler
to use internally to manage the timers that handle timeout for each eventonDropped
- called with the current entry when it has been replaced by a new one- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
oronDropped
isnull
- Since:
- 3.1.6 - Experimental
- See Also:
- ReactiveX operators documentation: Sample,
RxJava wiki: Backpressure,
sample(long, TimeUnit, Scheduler)
-
throttleLatest
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Flowable<T> throttleLatest(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Throttles items from the upstreamFlowable
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.
- Backpressure:
- This operator does not support backpressure as it uses time to control data flow.
If the downstream is not ready to receive items, a
MissingBackpressureException
will be signaled. - Scheduler:
throttleLatest
operates by default on thecomputation
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 againunit
- the time unit- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- Since:
- 2.2
- See Also:
throttleLatest(long, TimeUnit, boolean)
,throttleLatest(long, TimeUnit, Scheduler)
-
throttleLatest
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Flowable<T> throttleLatest(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit, boolean emitLast)
Throttles items from the upstreamFlowable
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.
- Backpressure:
- This operator does not support backpressure as it uses time to control data flow.
If the downstream is not ready to receive items, a
MissingBackpressureException
will be signaled. - Scheduler:
throttleLatest
operates by default on thecomputation
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 againunit
- the time unitemitLast
- Iftrue
, 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. Iffalse
, the very last upstream item is ignored and the flow terminates.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- Since:
- 2.2
- See Also:
throttleLatest(long, TimeUnit, Scheduler, boolean)
-
throttleLatest
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("custom") @NonNull public final @NonNull Flowable<T> throttleLatest(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Throttles items from the upstreamFlowable
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.
- Backpressure:
- This operator does not support backpressure as it uses time to control data flow.
If the downstream is not ready to receive items, a
MissingBackpressureException
will be signaled. - 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 againunit
- the time unitscheduler
- theScheduler
where the timed wait and latest item emission will be performed- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- Since:
- 2.2
- See Also:
throttleLatest(long, TimeUnit, Scheduler, boolean)
-
throttleLatest
@CheckReturnValue @NonNull @BackpressureSupport(ERROR) @SchedulerSupport("custom") public final @NonNull Flowable<T> throttleLatest(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, boolean emitLast)
Throttles items from the upstreamFlowable
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.
- Backpressure:
- This operator does not support backpressure as it uses time to control data flow.
If the downstream is not ready to receive items, a
MissingBackpressureException
will be signaled. - 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 againunit
- the time unitscheduler
- theScheduler
where the timed wait and latest item emission will be performedemitLast
- Iftrue
, 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. Iffalse
, the very last upstream item is ignored and the flow terminates.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- Since:
- 2.2
-
throttleLatest
@CheckReturnValue @NonNull @BackpressureSupport(ERROR) @SchedulerSupport("custom") public final @NonNull Flowable<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 upstreamFlowable
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.
- Backpressure:
- This operator does not support backpressure as it uses time to control data flow.
If the downstream is not ready to receive items, a
MissingBackpressureException
will be signaled. - Scheduler:
- You specify which
Scheduler
this operator will use. - Error handling:
-
If the upstream signals an
onError
oronDropped
callback crashes, the error is delivered immediately to the downstream. If both happen, aCompositeException
is created, containing both the upstream and the callback error. If theonDropped
callback crashes during cancellation, the exception is forwarded to the global error handler viaRxJavaPlugins.onError(Throwable)
.
- Parameters:
timeout
- the time to wait after an item emission towards the downstream before trying to emit the latest item from upstream againunit
- the time unitscheduler
- theScheduler
where the timed wait and latest item emission will be performedemitLast
- Iftrue
, 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. Iffalse
, 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 ifemitLast
isfalse
and the current undelivered item when the sequence gets canceled.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
,scheduler
oronDropped
isnull
- Since:
- 3.1.6 - Experimental
-
throttleWithTimeout
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Flowable<T> throttleWithTimeout(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that mirrors the currentFlowable
, except that it drops items emitted by the currentFlowable
that are followed by newer items before a timeout value expires. The timer resets on each emission (alias todebounce(long, TimeUnit)
).Note: If items keep being emitted by the current
Flowable
faster than the timeout then no items will be emitted by the resultingFlowable
.- Backpressure:
- This operator does not support backpressure as it uses time to control data flow.
- Scheduler:
throttleWithTimeout
operates by default on thecomputation
Scheduler
.
- Parameters:
timeout
- the length of the window of time that must pass after the emission of an item from the currentFlowable
in which it emits no items in order for the item to be emitted by the resultingFlowable
unit
- the unit of time for the specifiedtimeout
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Debounce,
RxJava wiki: Backpressure,
debounce(long, TimeUnit)
-
throttleWithTimeout
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("custom") @NonNull public final @NonNull Flowable<T> throttleWithTimeout(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns aFlowable
that mirrors the currentFlowable
, except that it drops items emitted by the currentFlowable
that are followed by newer items before a timeout value expires on a specifiedScheduler
. The timer resets on each emission (alias todebounce(long, TimeUnit, Scheduler)
).Note: If items keep being emitted by the current
Flowable
faster than the timeout then no items will be emitted by the resultingFlowable
.- Backpressure:
- This operator does not support backpressure as it uses time to control data flow.
- 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 currentFlowable
in which it emits no items in order for the item to be emitted by the resultingFlowable
unit
- the unit of time for the specifiedtimeout
scheduler
- theScheduler
to use internally to manage the timers that handle the timeout for each item- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Debounce,
RxJava wiki: Backpressure,
debounce(long, TimeUnit, Scheduler)
-
throttleWithTimeout
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("custom") @NonNull public final @NonNull Flowable<T> throttleWithTimeout(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, @NonNull @NonNull Consumer<? super @NonNull T> onDropped)
Returns aFlowable
that mirrors the currentFlowable
, except that it drops items emitted by the currentFlowable
that are followed by newer items before a timeout value expires on a specifiedScheduler
. The timer resets on each emission (alias todebounce(long, TimeUnit, Scheduler, Consumer)
).Note: If items keep being emitted by the current
Flowable
faster than the timeout then no items will be emitted by the resultingFlowable
.- Backpressure:
- This operator does not support backpressure as it uses time to control data flow.
- 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 currentFlowable
in which it emits no items in order for the item to be emitted by the resultingFlowable
unit
- the unit of time for the specifiedtimeout
scheduler
- theScheduler
to use internally to manage the timers that handle the timeout for each itemonDropped
- called with the current entry when it has been replaced by a new one- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
oronDropped
isnull
- Since:
- 3.1.6 - Experimental
- See Also:
- ReactiveX operators documentation: Debounce,
RxJava wiki: Backpressure,
debounce(long, TimeUnit, Scheduler, Consumer)
-
timeInterval
@CheckReturnValue @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<Timed<T>> timeInterval()
Returns aFlowable
that emits records of the time interval between consecutive items emitted by the currentFlowable
.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
timeInterval
does not operate on any particular scheduler but uses the current time from thecomputation
Scheduler
.
- Returns:
- the new
Flowable
instance - See Also:
- ReactiveX operators documentation: TimeInterval
-
timeInterval
@CheckReturnValue @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<Timed<T>> timeInterval(@NonNull @NonNull Scheduler scheduler)
Returns aFlowable
that emits records of the time interval between consecutive items emitted by the currentFlowable
, where this interval is computed on a specifiedScheduler
.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
timeInterval
does not operate on any particular scheduler but uses the current time from the specifiedScheduler
.
- Parameters:
scheduler
- theScheduler
used to compute time intervals- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifscheduler
isnull
- See Also:
- ReactiveX operators documentation: TimeInterval
-
timeInterval
@CheckReturnValue @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<Timed<T>> timeInterval(@NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits records of the time interval between consecutive items emitted by the currentFlowable
.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
timeInterval
does not operate on any particular scheduler but uses the current time from thecomputation
Scheduler
.
- Parameters:
unit
- the time unit for the current time- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: TimeInterval
-
timeInterval
@CheckReturnValue @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<Timed<T>> timeInterval(@NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns aFlowable
that emits records of the time interval between consecutive items emitted by the currentFlowable
, where this interval is computed on a specifiedScheduler
.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
timeInterval
does not operate on any particular scheduler but uses the current time from the specifiedScheduler
.
- Parameters:
unit
- the time unit for the current timescheduler
- theScheduler
used to compute time intervals- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: TimeInterval
-
timeout
@CheckReturnValue @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") @NonNull public final <@NonNull V> @NonNull Flowable<T> timeout(@NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<@NonNull V>> itemTimeoutIndicator)
Returns aFlowable
that mirrors the currentFlowable
, but notifiesSubscriber
s of aTimeoutException
if an item emitted by the currentFlowable
doesn't arrive within a window of time after the emission of the previous item, where that period of time is measured by aPublisher
that is a function of the previous item.Note: The arrival of the first source item is never timed out.
- Backpressure:
- The operator honors backpressure from downstream. The
Publisher
sources are expected to honor backpressure as well. If any of the currentFlowable
s violate this, it may throw anIllegalStateException
when the currentFlowable
completes. - Scheduler:
- This version of
timeout
operates by default on theimmediate
Scheduler
.
- Type Parameters:
V
- the timeout value type (ignored)- Parameters:
itemTimeoutIndicator
- a function that returns aPublisher
for each item emitted by the currentFlowable
and that determines the timeout window for the subsequent item- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifitemTimeoutIndicator
isnull
- See Also:
- ReactiveX operators documentation: Timeout
-
timeout
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final <@NonNull V> @NonNull Flowable<T> timeout(@NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<@NonNull V>> itemTimeoutIndicator, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> fallback)
Returns aFlowable
that mirrors the currentFlowable
, but that switches to a fallbackPublisher
if an item emitted by the currentFlowable
doesn't arrive within a window of time after the emission of the previous item, where that period of time is measured by aPublisher
that is a function of the previous item.Note: The arrival of the first source item is never timed out.
- Backpressure:
- The operator honors backpressure from downstream. The
Publisher
sources are expected to honor backpressure as well. If any of the currentFlowable
s violate this, it may throw anIllegalStateException
when the currentFlowable
completes. - Scheduler:
- This version of
timeout
operates by default on theimmediate
Scheduler
.
- Type Parameters:
V
- the timeout value type (ignored)- Parameters:
itemTimeoutIndicator
- a function that returns aPublisher
, for each item emitted by the currentFlowable
, that determines the timeout window for the subsequent itemfallback
- the fallbackPublisher
to switch to if the currentFlowable
times out- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifitemTimeoutIndicator
orfallback
isnull
- See Also:
- ReactiveX operators documentation: Timeout
-
timeout
@CheckReturnValue @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Flowable<T> timeout(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that mirrors the currentFlowable
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 resultingFlowable
terminates and notifiesSubscriber
s of aTimeoutException
.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
- This version of
timeout
operates by default on thecomputation
Scheduler
.
- Parameters:
timeout
- maximum duration between emitted items before a timeout occursunit
- the unit of time that applies to thetimeout
argument.- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Timeout
-
timeout
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("io.reactivex:computation") public final @NonNull Flowable<T> timeout(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> fallback)
Returns aFlowable
that mirrors the currentFlowable
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 currentFlowable
is disposed and the resultingFlowable
begins instead to mirror a fallbackPublisher
.- Backpressure:
- The operator honors backpressure from downstream. The
Publisher
sources are expected to honor backpressure as well. If any of the currentFlowable
s violate this, it may throw anIllegalStateException
when the currentFlowable
completes. - Scheduler:
- This version of
timeout
operates by default on thecomputation
Scheduler
.
- Parameters:
timeout
- maximum duration between items before a timeout occursunit
- the unit of time that applies to thetimeout
argumentfallback
- the fallbackPublisher
to use in case of a timeout- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orfallback
isnull
- See Also:
- ReactiveX operators documentation: Timeout
-
timeout
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("custom") public final @NonNull Flowable<T> timeout(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> fallback)
Returns aFlowable
that mirrors the currentFlowable
but applies a timeout policy for each emitted item using a specifiedScheduler
. If the next item isn't emitted within the specified timeout duration starting from its predecessor, the currentFlowable
is disposed and the resultingFlowable
begins instead to mirror a fallbackPublisher
.- Backpressure:
- The operator honors backpressure from downstream. The
Publisher
sources are expected to honor backpressure as well. If any of the currentFlowable
s violate this, it may throw anIllegalStateException
when the currentFlowable
completes. - Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
timeout
- maximum duration between items before a timeout occursunit
- the unit of time that applies to thetimeout
argumentscheduler
- theScheduler
to run the timeout timers onfallback
- thePublisher
to use as the fallback in case of a timeout- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
,scheduler
orfallback
isnull
- See Also:
- ReactiveX operators documentation: Timeout
-
timeout
@CheckReturnValue @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("custom") @NonNull public final @NonNull Flowable<T> timeout(long timeout, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns aFlowable
that mirrors the currentFlowable
but applies a timeout policy for each emitted item, where this policy is governed by a specifiedScheduler
. If the next item isn't emitted within the specified timeout duration starting from its predecessor, the resultingFlowable
terminates and notifiesSubscriber
s of aTimeoutException
.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
timeout
- maximum duration between items before a timeout occursunit
- the unit of time that applies to thetimeout
argumentscheduler
- theScheduler
to run the timeout timers on- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Timeout
-
timeout
@CheckReturnValue @NonNull @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") public final <@NonNull U,@NonNull V> @NonNull Flowable<T> timeout(@NonNull @NonNull org.reactivestreams.Publisher<@NonNull U> firstTimeoutIndicator, @NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<@NonNull V>> itemTimeoutIndicator)
Returns aFlowable
that mirrors the currentFlowable
, but notifiesSubscriber
s of aTimeoutException
if either the first item emitted by the currentFlowable
or any subsequent item doesn't arrive within time windows defined by otherPublisher
s.- Backpressure:
- The operator honors backpressure from downstream. Both this and the returned
Publisher
s are expected to honor backpressure as well. If any of then violates this rule, it may throw anIllegalStateException
when thePublisher
completes. - Scheduler:
timeout
does not operate by default on anyScheduler
.
- Type Parameters:
U
- the first timeout value type (ignored)V
- the subsequent timeout value type (ignored)- Parameters:
firstTimeoutIndicator
- a function that returns aPublisher
that determines the timeout window for the first source itemitemTimeoutIndicator
- a function that returns aPublisher
for each item emitted by the currentFlowable
and that determines the timeout window in which the subsequent source item must arrive in order to continue the sequence- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- iffirstTimeoutIndicator
oritemTimeoutIndicator
isnull
- See Also:
- ReactiveX operators documentation: Timeout
-
timeout
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final <@NonNull U,@NonNull V> @NonNull Flowable<T> timeout(@NonNull @NonNull org.reactivestreams.Publisher<@NonNull U> firstTimeoutIndicator, @NonNull @NonNull Function<? super @NonNull T,? extends org.reactivestreams.Publisher<@NonNull V>> itemTimeoutIndicator, @NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull T> fallback)
Returns aFlowable
that mirrors the currentFlowable
, but switches to a fallbackPublisher
if either the first item emitted by the currentFlowable
or any subsequent item doesn't arrive within time windows defined by otherPublisher
s.- Backpressure:
- The operator honors backpressure from downstream. The
Publisher
sources are expected to honor backpressure as well. If any of the currentFlowable
s violate this, it may throw anIllegalStateException
when the currentFlowable
completes. - Scheduler:
timeout
does not operate by default on anyScheduler
.
- Type Parameters:
U
- the first timeout value type (ignored)V
- the subsequent timeout value type (ignored)- Parameters:
firstTimeoutIndicator
- a function that returns aPublisher
which determines the timeout window for the first source itemitemTimeoutIndicator
- a function that returns aPublisher
for each item emitted by the currentFlowable
and that determines the timeout window in which the subsequent source item must arrive in order to continue the sequencefallback
- the fallbackPublisher
to switch to if the currentFlowable
times out- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- iffirstTimeoutIndicator
,itemTimeoutIndicator
orfallback
isnull
- See Also:
- ReactiveX operators documentation: Timeout
-
timeout0
private Flowable<T> timeout0(long timeout, java.util.concurrent.TimeUnit unit, org.reactivestreams.Publisher<? extends @NonNull T> fallback, Scheduler scheduler)
-
timeout0
private <@NonNull U,@NonNull V> Flowable<T> timeout0(org.reactivestreams.Publisher<@NonNull U> firstTimeoutIndicator, Function<? super @NonNull T,? extends org.reactivestreams.Publisher<@NonNull V>> itemTimeoutIndicator, org.reactivestreams.Publisher<? extends @NonNull T> fallback)
-
timestamp
@CheckReturnValue @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<Timed<T>> timestamp()
Returns aFlowable
that emits each item emitted by the currentFlowable
, wrapped in aTimed
object.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
timestamp
does not operate on any particular scheduler but uses the current time from thecomputation
Scheduler
.
- Returns:
- the new
Flowable
instance - See Also:
- ReactiveX operators documentation: Timestamp
-
timestamp
@CheckReturnValue @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<Timed<T>> timestamp(@NonNull @NonNull Scheduler scheduler)
Returns aFlowable
that emits each item emitted by the currentFlowable
, wrapped in aTimed
object whose timestamps are provided by a specifiedScheduler
.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
- This operator does not operate on any particular scheduler but uses the current time
from the specified
Scheduler
.
- Parameters:
scheduler
- theScheduler
to use as a time source- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifscheduler
isnull
- See Also:
- ReactiveX operators documentation: Timestamp
-
timestamp
@CheckReturnValue @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<Timed<T>> timestamp(@NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits each item emitted by the currentFlowable
, wrapped in aTimed
object.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
timestamp
does not operate on any particular scheduler but uses the current time from thecomputation
Scheduler
.
- Parameters:
unit
- the time unit for the current time- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Timestamp
-
timestamp
@CheckReturnValue @NonNull @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") public final @NonNull Flowable<Timed<T>> timestamp(@NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns aFlowable
that emits each item emitted by the currentFlowable
, wrapped in aTimed
object whose timestamps are provided by a specifiedScheduler
.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
- This operator does not operate on any particular scheduler but uses the current time
from the specified
Scheduler
.
- Parameters:
unit
- the time unit for the current timescheduler
- theScheduler
to use as a time source- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Timestamp
-
to
@CheckReturnValue @BackpressureSupport(SPECIAL) @SchedulerSupport("none") public final <@NonNull R> R to(@NonNull @NonNull FlowableConverter<@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.
- Backpressure:
- The backpressure behavior depends on what happens in the
converter
function. - Scheduler:
to
does not operate by default on a particularScheduler
.
History: 2.1.7 - experimental
- Type Parameters:
R
- the resulting object type- Parameters:
converter
- the function that receives the currentFlowable
instance and returns a value- Returns:
- the converted value
- Throws:
java.lang.NullPointerException
- ifconverter
isnull
- Since:
- 2.2
-
toList
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final @NonNull Single<java.util.List<T>> toList()
Returns aSingle
that emits a single item, a list composed of all the items emitted by the finite upstream sourcePublisher
.Normally, a
Publisher
that returns multiple items will do so by invoking itsSubscriber
'sonNext
method for each such item. You can change this behavior by having the operator compose a list of all of these items and then to invoke theSingleObserver
'sonSuccess
method once, passing it the entire list, by calling theFlowable
'stoList
method prior to calling itssubscribe()
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 fatalOutOfMemoryError
.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., without applying backpressure to it). - Scheduler:
toList
does not operate by default on a particularScheduler
.
- Returns:
- the new
Single
instance - See Also:
- ReactiveX operators documentation: To
-
toList
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final @NonNull Single<java.util.List<T>> toList(int capacityHint)
Returns aSingle
that emits a single item, a list composed of all the items emitted by the finite sourcePublisher
.Normally, a
Publisher
that returns multiple items will do so by invoking itsSubscriber
'sonNext
method for each such item. You can change this behavior by having the operator compose a list of all of these items and then to invoke theSingleObserver
'sonSuccess
method once, passing it the entire list, by calling theFlowable
'stoList
method prior to calling itssubscribe()
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 fatalOutOfMemoryError
.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., without applying backpressure to it). - Scheduler:
toList
does not operate by default on a particularScheduler
.
- Parameters:
capacityHint
- the number of elements expected from the currentFlowable
- Returns:
- the new
Single
instance - Throws:
java.lang.IllegalArgumentException
- ifcapacityHint
is non-positive- See Also:
- ReactiveX operators documentation: To
-
toList
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @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 aSingle
that emits a single item, a list composed of all the items emitted by the finite sourcePublisher
.Normally, a
Publisher
that returns multiple items will do so by invoking itsSubscriber
'sonNext
method for each such item. You can change this behavior by having the operator compose a collection of all of these items and then to invoke theSingleObserver
'sonSuccess
method once, passing it the entire collection, by calling theFlowable
'stoList
method prior to calling itssubscribe()
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 fatalOutOfMemoryError
.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., without applying backpressure to it). - Scheduler:
toList
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the subclass of a collection of Ts- Parameters:
collectionSupplier
- theSupplier
returning the collection (for each individualSubscriber
) to be filled in- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifcollectionSupplier
isnull
- See Also:
- ReactiveX operators documentation: To
-
toMap
@CheckReturnValue @NonNull @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") public final <@NonNull K> @NonNull Single<java.util.Map<K,T>> toMap(@NonNull @NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector)
Returns aSingle
that emits a singleHashMap
containing all items emitted by the finite sourcePublisher
, mapped by the keys returned by a specifiedkeySelector
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 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 fatalOutOfMemoryError
.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., without applying backpressure to it). - Scheduler:
toMap
does not operate by default on a particularScheduler
.
- 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 theHashMap
- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifkeySelector
isnull
- See Also:
- ReactiveX operators documentation: To
-
toMap
@CheckReturnValue @NonNull @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") 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 aSingle
that emits a singleHashMap
containing values corresponding to items emitted by the finite sourcePublisher
, mapped by the keys returned by a specifiedkeySelector
function.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 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 fatalOutOfMemoryError
.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., without applying backpressure to it). - Scheduler:
toMap
does not operate by default on a particularScheduler
.
- Type Parameters:
K
- the key type of the MapV
- the value type of the Map- Parameters:
keySelector
- the function that extracts the key from a source item to be used in theHashMap
valueSelector
- the function that extracts the value from a source item to be used in theHashMap
- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifkeySelector
orvalueSelector
isnull
- See Also:
- ReactiveX operators documentation: To
-
toMap
@CheckReturnValue @NonNull @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") 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 aSingle
that emits a singleMap
, returned by a specifiedmapFactory
function, that contains keys and values extracted from the items emitted by the finite sourcePublisher
.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 fatalOutOfMemoryError
.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., without applying backpressure to it). - Scheduler:
toMap
does not operate by default on a particularScheduler
.
- Type Parameters:
K
- the key type of the MapV
- the value type of the Map- Parameters:
keySelector
- the function that extracts the key from a source item to be used in the MapvalueSelector
- the function that extracts the value from the source items to be used as value in the MapmapSupplier
- the function that returns aMap
instance to be used- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifkeySelector
,valueSelector
ormapSupplier
isnull
- See Also:
- ReactiveX operators documentation: To
-
toMultimap
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final <@NonNull K> @NonNull Single<java.util.Map<K,java.util.Collection<T>>> toMultimap(@NonNull @NonNull Function<? super @NonNull T,? extends @NonNull K> keySelector)
Returns aSingle
that emits a singleHashMap
that contains anArrayList
of items emitted by the finite sourcePublisher
keyed by a specifiedkeySelector
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 fatalOutOfMemoryError
.- Backpressure:
- This operator does not support backpressure as by intent it is requesting and buffering everything.
- Scheduler:
toMultimap
does not operate by default on a particularScheduler
.
- Type Parameters:
K
- the key type of the Map- Parameters:
keySelector
- the function that extracts the key from the source items to be used as key in theHashMap
- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifkeySelector
isnull
- See Also:
- ReactiveX operators documentation: To
-
toMultimap
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final <@NonNull K,@NonNull V> @NonNull Single<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)
Returns aSingle
that emits a singleHashMap
that contains anArrayList
of values extracted by a specifiedvalueSelector
function from items emitted by the finite sourcePublisher
, keyed by a specifiedkeySelector
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 fatalOutOfMemoryError
.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., without applying backpressure to it). - Scheduler:
toMultimap
does not operate by default on a particularScheduler
.
- Type Parameters:
K
- the key type of the MapV
- the value type of the Map- Parameters:
keySelector
- the function that extracts a key from the source items to be used as key in theHashMap
valueSelector
- the function that extracts a value from the source items to be used as value in theHashMap
- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifkeySelector
orvalueSelector
isnull
- See Also:
- ReactiveX operators documentation: To
-
toMultimap
@CheckReturnValue @NonNull @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") public final <@NonNull K,@NonNull V> @NonNull Single<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 aSingle
that emits a singleMap
, returned by a specifiedmapFactory
function, that contains a custom collection of values, extracted by a specifiedvalueSelector
function from items emitted by the finite sourcePublisher
, and keyed by thekeySelector
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 fatalOutOfMemoryError
.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., without applying backpressure to it). - Scheduler:
toMultimap
does not operate by default on a particularScheduler
.
- Type Parameters:
K
- the key type of the MapV
- 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 MapvalueSelector
- the function that extracts a value from the source items to be used as the value in theMap
mapSupplier
- the function that returns a Map instance to be usedcollectionFactory
- the function that returns aCollection
instance for a particular key to be used in theMap
- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifkeySelector
,valueSelector
,mapSupplier
orcollectionFactory
isnull
- See Also:
- ReactiveX operators documentation: To
-
toMultimap
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final <@NonNull K,@NonNull V> @NonNull Single<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 aSingle
that emits a singleMap
, returned by a specifiedmapFactory
function, that contains anArrayList
of values, extracted by a specifiedvalueSelector
function from items emitted by the finite sourcePublisher
and keyed by thekeySelector
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 fatalOutOfMemoryError
.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., without applying backpressure to it). - Scheduler:
toMultimap
does not operate by default on a particularScheduler
.
- Type Parameters:
K
- the key type of theMap
V
- the value type of theMap
- Parameters:
keySelector
- the function that extracts a key from the source items to be used as the key in theMap
valueSelector
- the function that extracts a value from the source items to be used as the value in theMap
mapSupplier
- the function that returns aMap
instance to be used- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifkeySelector
,valueSelector
ormapSupplier
isnull
- See Also:
- ReactiveX operators documentation: To
-
toObservable
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final @NonNull Observable<T> toObservable()
Converts the currentFlowable
into a non-backpressuredObservable
.- Backpressure:
Observable
s don't support backpressure thus the currentFlowable
is consumed in an unbounded manner (by requestingLong.MAX_VALUE
).- Scheduler:
toObservable
does not operate by default on a particularScheduler
.
- Returns:
- the new
Observable
instance - Since:
- 2.0
-
toSortedList
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final @NonNull Single<java.util.List<T>> toSortedList()
Returns aSingle
that emits aList
that contains the items emitted by the finite sourcePublisher
, in a sorted order. Each item emitted by thePublisher
must implementComparable
with respect to all other items in the sequence.If any item emitted by this
Flowable
does not implementComparable
with respect to all other items emitted by thisFlowable
, no items will be emitted and the sequence is terminated with aClassCastException
.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 fatalOutOfMemoryError
.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., without applying backpressure to it). - Scheduler:
toSortedList
does not operate by default on a particularScheduler
.
- Returns:
- the new
Single
instance - See Also:
- ReactiveX operators documentation: To
-
toSortedList
@CheckReturnValue @NonNull @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") public final @NonNull Single<java.util.List<T>> toSortedList(@NonNull @NonNull java.util.Comparator<? super @NonNull T> comparator)
Returns aSingle
that emits aList
that contains the items emitted by the finite sourcePublisher
, 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 fatalOutOfMemoryError
.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., without applying backpressure to it). - Scheduler:
toSortedList
does not operate by default on a particularScheduler
.
- Parameters:
comparator
- a function that compares two items emitted by the currentFlowable
and returns anint
that indicates their sort order- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifcomparator
isnull
- See Also:
- ReactiveX operators documentation: To
-
toSortedList
@CheckReturnValue @NonNull @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") public final @NonNull Single<java.util.List<T>> toSortedList(@NonNull @NonNull java.util.Comparator<? super @NonNull T> comparator, int capacityHint)
Returns aSingle
that emits aList
that contains the items emitted by the finite sourcePublisher
, 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 fatalOutOfMemoryError
.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., without applying backpressure to it). - Scheduler:
toSortedList
does not operate by default on a particularScheduler
.
- Parameters:
comparator
- a function that compares two items emitted by the currentFlowable
and returns anint
that indicates their sort ordercapacityHint
- the initial capacity of theArrayList
used to accumulate items before sorting- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifcomparator
isnull
java.lang.IllegalArgumentException
- ifcapacityHint
is non-positive- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: To
-
toSortedList
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final @NonNull Single<java.util.List<T>> toSortedList(int capacityHint)
Returns aSingle
that emits aList
that contains the items emitted by the finite sourcePublisher
, in a sorted order. Each item emitted by thePublisher
must implementComparable
with respect to all other items in the sequence.If any item emitted by this
Flowable
does not implementComparable
with respect to all other items emitted by thisFlowable
, no items will be emitted and the sequence is terminated with aClassCastException
.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 fatalOutOfMemoryError
.- Backpressure:
- The operator honors backpressure from downstream and consumes the current
Flowable
in an unbounded manner (i.e., without applying backpressure to it). - Scheduler:
toSortedList
does not operate by default on a particularScheduler
.
- Parameters:
capacityHint
- the initial capacity of theArrayList
used to accumulate items before sorting- Returns:
- the new
Single
instance - Throws:
java.lang.IllegalArgumentException
- ifcapacityHint
is non-positive- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: To
-
unsubscribeOn
@CheckReturnValue @NonNull @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("custom") public final @NonNull Flowable<T> unsubscribeOn(@NonNull @NonNull Scheduler scheduler)
Cancels the currentFlowable
asynchronously by invokingSubscription.cancel()
on the specifiedScheduler
.The operator suppresses signals from the current
Flowable
immediately when the downstream cancels the flow because the actual cancellation itself could take an arbitrary amount of time to take effect and make the flow stop producing items.- Backpressure:
- The operator doesn't interfere with backpressure which is determined by the current
Flowable
's backpressure behavior. - Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
scheduler
- theScheduler
to perform cancellation actions on- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifscheduler
isnull
- See Also:
- ReactiveX operators documentation: SubscribeOn
-
window
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<Flowable<T>> window(long count)
Returns aFlowable
that emits windows of items it collects from the currentFlowable
. The resultingFlowable
emits connected, non-overlapping windows, each containingcount
items. When the currentFlowable
completes or encounters an error, the resultingFlowable
emits the current window and propagates the notification from the currentFlowable
.Note that ignoring windows or subscribing later (i.e., on another thread) will result in so-called window abandonment where a window will only contain one element. The behavior is a trade-off between no-dataloss and ensuring upstream cancellation can happen.
- Backpressure:
- The operator honors backpressure of its inner and outer subscribers, however, the inner
Flowable
uses an unbounded buffer that may hold at mostcount
elements. - Scheduler:
- This version of
window
does not operate by default on a particularScheduler
.
- Parameters:
count
- the maximum size of each window before it should be emitted- Returns:
- the new
Flowable
instance - Throws:
java.lang.IllegalArgumentException
- ifcount
is non-positive- See Also:
- ReactiveX operators documentation: Window
-
window
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<Flowable<T>> window(long count, long skip)
Returns aFlowable
that emits windows of items it collects from the currentFlowable
. The resultingFlowable
emits windows everyskip
items, each containing no more thancount
items. When the currentFlowable
completes or encounters an error, the resultingFlowable
emits the current window and propagates the notification from the currentFlowable
.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 between no-dataloss and ensuring upstream cancellation can happen under some race conditions.
- Backpressure:
- The operator honors backpressure of its inner and outer subscribers, however, the inner
Flowable
uses an unbounded buffer that may hold at mostcount
elements. - Scheduler:
- This version of
window
does not operate by default on a particularScheduler
.
- Parameters:
count
- the maximum size of each window before it should be emittedskip
- how many items need to be skipped before starting a new window. Note that ifskip
andcount
are equal this is the same operation aswindow(long)
.- Returns:
- the new
Flowable
instance - Throws:
java.lang.IllegalArgumentException
- ifcount
orskip
is non-positive- See Also:
- ReactiveX operators documentation: Window
-
window
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull Flowable<Flowable<T>> window(long count, long skip, int bufferSize)
Returns aFlowable
that emits windows of items it collects from the currentFlowable
. The resultingFlowable
emits windows everyskip
items, each containing no more thancount
items. When the currentFlowable
completes or encounters an error, the resultingFlowable
emits the current window and propagates the notification from the currentFlowable
.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 between no-dataloss and ensuring upstream cancellation can happen under some race conditions.
- Backpressure:
- The operator honors backpressure of its inner and outer subscribers, however, the inner
Flowable
uses an unbounded buffer that may hold at mostcount
elements. - Scheduler:
- This version of
window
does not operate by default on a particularScheduler
.
- Parameters:
count
- the maximum size of each window before it should be emittedskip
- how many items need to be skipped before starting a new window. Note that ifskip
andcount
are equal this is the same operation aswindow(long)
.bufferSize
- the capacity hint for the buffer in the inner windows- Returns:
- the new
Flowable
instance - Throws:
java.lang.IllegalArgumentException
- ifcount
,skip
orbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Window
-
window
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Flowable<Flowable<T>> window(long timespan, long timeskip, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits windows of items it collects from the currentFlowable
. The resultingFlowable
starts a new window periodically, as determined by thetimeskip
argument. It emits each window after a fixed timespan, specified by thetimespan
argument. When the currentFlowable
completes or encounters an error, the resultingFlowable
emits the current window and propagates the notification from the currentFlowable
.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.
- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner. The resultingFlowable
doesn't support backpressure as it uses time to control the creation of windows. The emitted innerFlowable
s honor backpressure but have an unbounded inner buffer that may lead toOutOfMemoryError
if left unconsumed. - Scheduler:
- This version of
window
operates by default on thecomputation
Scheduler
.
- Parameters:
timespan
- the period of time each window collects items before it should be emittedtimeskip
- the period of time after which a new window will be createdunit
- the unit of time that applies to thetimespan
andtimeskip
arguments- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Window
-
window
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("custom") @NonNull public final @NonNull Flowable<Flowable<T>> window(long timespan, long timeskip, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns aFlowable
that emits windows of items it collects from the currentFlowable
. The resultingFlowable
starts a new window periodically, as determined by thetimeskip
argument. It emits each window after a fixed timespan, specified by thetimespan
argument. When the currentFlowable
completes or encounters an error, the resultingFlowable
emits the current window and propagates the notification from the currentFlowable
.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.
- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner. The resultingFlowable
doesn't support backpressure as it uses time to control the creation of windows. The returned innerFlowable
s honor backpressure but have an unbounded inner buffer that may lead toOutOfMemoryError
if left unconsumed. - Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
timespan
- the period of time each window collects items before it should be emittedtimeskip
- the period of time after which a new window will be createdunit
- the unit of time that applies to thetimespan
andtimeskip
argumentsscheduler
- theScheduler
to use when determining the end and start of a window- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Window
-
window
@CheckReturnValue @NonNull @BackpressureSupport(ERROR) @SchedulerSupport("custom") public final @NonNull Flowable<Flowable<T>> window(long timespan, long timeskip, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, int bufferSize)
Returns aFlowable
that emits windows of items it collects from the currentFlowable
. The resultingFlowable
starts a new window periodically, as determined by thetimeskip
argument. It emits each window after a fixed timespan, specified by thetimespan
argument. When the currentFlowable
completes or encounters an error, the resultingFlowable
emits the current window and propagates the notification from the currentFlowable
.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.
- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner. The resultingFlowable
doesn't support backpressure as it uses time to control the creation of windows. The returned innerFlowable
s honor backpressure but have an unbounded inner buffer that may lead toOutOfMemoryError
if left unconsumed. - Scheduler:
- You specify which
Scheduler
this operator will use.
- Parameters:
timespan
- the period of time each window collects items before it should be emittedtimeskip
- the period of time after which a new window will be createdunit
- the unit of time that applies to thetimespan
andtimeskip
argumentsscheduler
- theScheduler
to use when determining the end and start of a windowbufferSize
- the capacity hint for the buffer in the inner windows- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
java.lang.IllegalArgumentException
- iftimespan
,timeskip
orbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Window
-
window
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Flowable<Flowable<T>> window(long timespan, @NonNull @NonNull java.util.concurrent.TimeUnit unit)
Returns aFlowable
that emits windows of items it collects from the currentFlowable
. The resultingFlowable
emits connected, non-overlapping windows, each of a fixed duration specified by thetimespan
argument. When the currentFlowable
completes or encounters an error, the resultingFlowable
emits the current window and propagates the notification from the currentFlowable
.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.
- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner. The resultingFlowable
doesn't support backpressure as it uses time to control the creation of windows. The emitted innerFlowable
s honor backpressure and may hold up tocount
elements at most. - Scheduler:
- This version of
window
operates by default on thecomputation
Scheduler
.
- Parameters:
timespan
- the period of time each window collects items before it should be emitted and replaced with a new windowunit
- the unit of time that applies to thetimespan
argument- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
- See Also:
- ReactiveX operators documentation: Window
-
window
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Flowable<Flowable<T>> window(long timespan, @NonNull @NonNull java.util.concurrent.TimeUnit unit, long count)
Returns aFlowable
that emits windows of items it collects from the currentFlowable
. The resultingFlowable
emits connected, non-overlapping windows, each of a fixed duration as specified by thetimespan
argument or a maximum size as specified by thecount
argument (whichever is reached first). When the currentFlowable
completes or encounters an error, the resultingFlowable
emits the current window and propagates the notification from the currentFlowable
.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.
- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner. The resultingFlowable
doesn't support backpressure as it uses time to control the creation of windows. The emitted innerFlowable
s honor backpressure and may hold up tocount
elements at most. - Scheduler:
- This version of
window
operates by default on thecomputation
Scheduler
.
- Parameters:
timespan
- the period of time each window collects items before it should be emitted and replaced with a new windowunit
- the unit of time that applies to thetimespan
argumentcount
- the maximum size of each window before it should be emitted- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
java.lang.IllegalArgumentException
- ifcount
is non-positive- See Also:
- ReactiveX operators documentation: Window
-
window
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("io.reactivex:computation") @NonNull public final @NonNull Flowable<Flowable<T>> window(long timespan, @NonNull @NonNull java.util.concurrent.TimeUnit unit, long count, boolean restart)
Returns aFlowable
that emits windows of items it collects from the currentFlowable
. The resultingFlowable
emits connected, non-overlapping windows, each of a fixed duration as specified by thetimespan
argument or a maximum size as specified by thecount
argument (whichever is reached first). When the currentFlowable
completes or encounters an error, the resultingFlowable
emits the current window and propagates the notification from the currentFlowable
.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.
- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner. The resultingFlowable
doesn't support backpressure as it uses time to control the creation of windows. The emitted innerFlowable
s honor backpressure and may hold up tocount
elements at most. - Scheduler:
- This version of
window
operates by default on thecomputation
Scheduler
.
- Parameters:
timespan
- the period of time each window collects items before it should be emitted and replaced with a new windowunit
- the unit of time that applies to thetimespan
argumentcount
- the maximum size of each window before it should be emittedrestart
- iftrue
, when a window reaches the capacity limit, the timer is restarted as well- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
isnull
java.lang.IllegalArgumentException
- ifcount
is non-positive- See Also:
- ReactiveX operators documentation: Window
-
window
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("custom") @NonNull public final @NonNull Flowable<Flowable<T>> window(long timespan, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler)
Returns aFlowable
that emits windows of items it collects from the currentFlowable
. The resultingFlowable
emits connected, non-overlapping windows, each of a fixed duration as specified by thetimespan
argument. When the currentFlowable
completes or encounters an error, the resultingFlowable
emits the current window and propagates the notification from the currentFlowable
.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.
- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner. The resultingFlowable
doesn't support backpressure as it uses time to control the creation of windows. The emitted innerFlowable
s honor backpressure but have an unbounded inner buffer that may lead toOutOfMemoryError
if left unconsumed. - 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 windowunit
- the unit of time which applies to thetimespan
argumentscheduler
- theScheduler
to use when determining the end and start of a window- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
- See Also:
- ReactiveX operators documentation: Window
-
window
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("custom") @NonNull public final @NonNull Flowable<Flowable<T>> window(long timespan, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, long count)
Returns aFlowable
that emits windows of items it collects from the currentFlowable
. The resultingFlowable
emits connected, non-overlapping windows, each of a fixed duration specified by thetimespan
argument or a maximum size specified by thecount
argument (whichever is reached first). When the currentFlowable
completes or encounters an error, the resultingFlowable
emits the current window and propagates the notification from the currentFlowable
.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.
- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner. The resultingFlowable
doesn't support backpressure as it uses time to control the creation of windows. The emitted innerFlowable
s honor backpressure and may hold up tocount
elements at most. - 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 windowunit
- the unit of time which applies to thetimespan
argumentcount
- the maximum size of each window before it should be emittedscheduler
- theScheduler
to use when determining the end and start of a window- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
java.lang.IllegalArgumentException
- ifcount
is non-positive- See Also:
- ReactiveX operators documentation: Window
-
window
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("custom") @NonNull public final @NonNull Flowable<Flowable<T>> window(long timespan, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, long count, boolean restart)
Returns aFlowable
that emits windows of items it collects from the currentFlowable
. The resultingFlowable
emits connected, non-overlapping windows, each of a fixed duration specified by thetimespan
argument or a maximum size specified by thecount
argument (whichever is reached first). When the currentFlowable
completes or encounters an error, the resultingFlowable
emits the current window and propagates the notification from the currentFlowable
.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.
- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner. The resultingFlowable
doesn't support backpressure as it uses time to control the creation of windows. The emitted innerFlowable
s honor backpressure and may hold up tocount
elements at most. - 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 windowunit
- the unit of time which applies to thetimespan
argumentcount
- the maximum size of each window before it should be emittedscheduler
- theScheduler
to use when determining the end and start of a windowrestart
- iftrue
, when a window reaches the capacity limit, the timer is restarted as well- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
java.lang.IllegalArgumentException
- ifcount
is non-positive- See Also:
- ReactiveX operators documentation: Window
-
window
@CheckReturnValue @NonNull @BackpressureSupport(ERROR) @SchedulerSupport("custom") public final @NonNull Flowable<Flowable<T>> window(long timespan, @NonNull @NonNull java.util.concurrent.TimeUnit unit, @NonNull @NonNull Scheduler scheduler, long count, boolean restart, int bufferSize)
Returns aFlowable
that emits windows of items it collects from the currentFlowable
. The resultingFlowable
emits connected, non-overlapping windows, each of a fixed duration specified by thetimespan
argument or a maximum size specified by thecount
argument (whichever is reached first). When the currentFlowable
completes or encounters an error, the resultingFlowable
emits the current window and propagates the notification from the currentFlowable
.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.
- Backpressure:
- The operator consumes the current
Flowable
in an unbounded manner. The resultingFlowable
doesn't support backpressure as it uses time to control the creation of windows. The emitted innerFlowable
s honor backpressure and may hold up tocount
elements at most. - 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 windowunit
- the unit of time which applies to thetimespan
argumentcount
- the maximum size of each window before it should be emittedscheduler
- theScheduler
to use when determining the end and start of a windowrestart
- iftrue
, when a window reaches the capacity limit, the timer is restarted as wellbufferSize
- the capacity hint for the buffer in the inner windows- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifunit
orscheduler
isnull
java.lang.IllegalArgumentException
- ifcount
,timespan
orbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Window
-
window
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("none") @NonNull public final <@NonNull B> @NonNull Flowable<Flowable<T>> window(@NonNull @NonNull org.reactivestreams.Publisher<@NonNull B> boundaryIndicator)
Returns aFlowable
that emits non-overlapping windows of items it collects from the currentFlowable
where the boundary of each window is determined by the items emitted from a specified boundary-governingPublisher
.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.
- Backpressure:
- The outer
Publisher
of this operator does not support backpressure as it uses aboundary
Publisher
to control data flow. The innerPublisher
s honor backpressure and buffer everything until the boundary signals the next element. - Scheduler:
- This version of
window
does not operate by default on a particularScheduler
.
- Type Parameters:
B
- the window element type (ignored)- Parameters:
boundaryIndicator
- aPublisher
whose emitted items close and open windows- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifboundaryIndicator
isnull
- See Also:
- ReactiveX operators documentation: Window
-
window
@CheckReturnValue @NonNull @BackpressureSupport(ERROR) @SchedulerSupport("none") public final <@NonNull B> @NonNull Flowable<Flowable<T>> window(@NonNull @NonNull org.reactivestreams.Publisher<@NonNull B> boundaryIndicator, int bufferSize)
Returns aFlowable
that emits non-overlapping windows of items it collects from the currentFlowable
where the boundary of each window is determined by the items emitted from a specified boundary-governingPublisher
.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.
- Backpressure:
- The outer
Publisher
of this operator does not support backpressure as it uses aboundary
Publisher
to control data flow. The innerPublisher
s honor backpressure and buffer everything until the boundary signals the next element. - Scheduler:
- This version of
window
does not operate by default on a particularScheduler
.
- Type Parameters:
B
- the window element type (ignored)- Parameters:
boundaryIndicator
- aPublisher
whose emitted items close and open windowsbufferSize
- the capacity hint for the buffer in the inner windows- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifboundaryIndicator
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Window
-
window
@CheckReturnValue @BackpressureSupport(ERROR) @SchedulerSupport("none") @NonNull public final <@NonNull U,@NonNull V> @NonNull Flowable<Flowable<T>> window(@NonNull @NonNull org.reactivestreams.Publisher<@NonNull U> openingIndicator, @NonNull @NonNull Function<? super @NonNull U,? extends org.reactivestreams.Publisher<@NonNull V>> closingIndicator)
Returns aFlowable
that emits windows of items it collects from the currentFlowable
. The resultingFlowable
emits windows that contain those items emitted by the currentFlowable
between the time when thewindowOpenings
Publisher
emits an item and when thePublisher
returned byclosingSelector
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.
- Backpressure:
- The outer
Publisher
of this operator doesn't support backpressure because the emission of new innerPublisher
s are controlled by thewindowOpenings
Publisher
. The innerPublisher
s honor backpressure and buffer everything until the associated closingPublisher
signals or completes. - Scheduler:
- This version of
window
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the element type of the window-openingPublisher
V
- the element type of the window-closingPublisher
s- Parameters:
openingIndicator
- aPublisher
that, when it emits an item, causes another window to be createdclosingIndicator
- aFunction
that produces aPublisher
for every window created. When thisPublisher
emits an item, the associated window is closed and emitted- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifopeningIndicator
orclosingIndicator
isnull
- See Also:
- ReactiveX operators documentation: Window
-
window
@CheckReturnValue @NonNull @BackpressureSupport(ERROR) @SchedulerSupport("none") public final <@NonNull U,@NonNull V> @NonNull Flowable<Flowable<T>> window(@NonNull @NonNull org.reactivestreams.Publisher<@NonNull U> openingIndicator, @NonNull @NonNull Function<? super @NonNull U,? extends org.reactivestreams.Publisher<@NonNull V>> closingIndicator, int bufferSize)
Returns aFlowable
that emits windows of items it collects from the currentFlowable
. The resultingFlowable
emits windows that contain those items emitted by the currentFlowable
between the time when thewindowOpenings
Publisher
emits an item and when thePublisher
returned byclosingSelector
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.
- Backpressure:
- The outer
Publisher
of this operator doesn't support backpressure because the emission of new innerPublisher
s are controlled by thewindowOpenings
Publisher
. The innerPublisher
s honor backpressure and buffer everything until the associated closingPublisher
signals or completes. - Scheduler:
- This version of
window
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the element type of the window-openingPublisher
V
- the element type of the window-closingPublisher
s- Parameters:
openingIndicator
- aPublisher
that, when it emits an item, causes another window to be createdclosingIndicator
- aFunction
that produces aPublisher
for every window created. When thisPublisher
emits an item, the associated window is closed and emittedbufferSize
- the capacity hint for the buffer in the inner windows- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifopeningIndicator
orclosingIndicator
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- See Also:
- ReactiveX operators documentation: Window
-
withLatestFrom
@CheckReturnValue @NonNull @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") public final <@NonNull U,@NonNull R> @NonNull Flowable<R> withLatestFrom(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull U> other, @NonNull @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> combiner)
Merges the specifiedPublisher
into the currentFlowable
sequence by using theresultSelector
function only when the currentFlowable
(this instance) 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
Flowable
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.- Backpressure:
- The operator is a pass-through for backpressure: the backpressure support
depends on the upstream and downstream's backpressure behavior. The other
Publisher
is consumed in an unbounded fashion. - Scheduler:
- This operator, by default, doesn't run any particular
Scheduler
.
- Type Parameters:
U
- the element type of the otherPublisher
R
- the result type of the combination- Parameters:
other
- the otherPublisher
combiner
- the function to call when the currentFlowable
emits an item and the otherPublisher
has already emitted an item, to generate the item to be emitted by the resultingFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifother
orcombiner
isnull
- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: CombineLatest
-
withLatestFrom
@CheckReturnValue @NonNull @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") public final <@NonNull T1,@NonNull T2,@NonNull R> @NonNull Flowable<R> withLatestFrom(@NonNull @NonNull org.reactivestreams.Publisher<@NonNull T1> source1, @NonNull @NonNull org.reactivestreams.Publisher<@NonNull T2> source2, @NonNull @NonNull Function3<? super @NonNull T,? super @NonNull T1,? super @NonNull T2,@NonNull R> combiner)
Combines the value emission from the currentFlowable
with the latest emissions from the otherPublisher
s 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
Flowable
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.- Backpressure:
- This operator is a pass-through for backpressure behavior between the current
Flowable
and the downstreamSubscriber
. The otherPublisher
s are consumed in an unbounded manner. - Scheduler:
- This operator does not operate by default on a particular
Scheduler
.
- Type Parameters:
T1
- the first other source's value typeT2
- the second other source's value typeR
- the result value type- Parameters:
source1
- the first otherPublisher
source2
- the second otherPublisher
combiner
- the function called with an array of values from each participatingPublisher
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
orcombiner
isnull
- Since:
- 2.0
-
withLatestFrom
@CheckReturnValue @NonNull @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") public final <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull R> @NonNull Flowable<R> withLatestFrom(@NonNull @NonNull org.reactivestreams.Publisher<@NonNull T1> source1, @NonNull @NonNull org.reactivestreams.Publisher<@NonNull T2> source2, @NonNull @NonNull org.reactivestreams.Publisher<@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 currentFlowable
with the latest emissions from the otherPublisher
s 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
Flowable
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.- Backpressure:
- This operator is a pass-through for backpressure behavior between the current
Flowable
and the downstreamSubscriber
. The otherPublisher
s are consumed in an unbounded manner. - Scheduler:
- This operator does not operate by default on a particular
Scheduler
.
- Type Parameters:
T1
- the first other source's value typeT2
- the second other source's value typeT3
- the third other source's value typeR
- the result value type- Parameters:
source1
- the first otherPublisher
source2
- the second otherPublisher
source3
- the third otherPublisher
combiner
- the function called with an array of values from each participatingPublisher
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
orcombiner
isnull
- Since:
- 2.0
-
withLatestFrom
@CheckReturnValue @NonNull @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") public final <@NonNull T1,@NonNull T2,@NonNull T3,@NonNull T4,@NonNull R> @NonNull Flowable<R> withLatestFrom(@NonNull @NonNull org.reactivestreams.Publisher<@NonNull T1> source1, @NonNull @NonNull org.reactivestreams.Publisher<@NonNull T2> source2, @NonNull @NonNull org.reactivestreams.Publisher<@NonNull T3> source3, @NonNull @NonNull org.reactivestreams.Publisher<@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 currentFlowable
with the latest emissions from the otherPublisher
s 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
Flowable
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.- Backpressure:
- This operator is a pass-through for backpressure behavior between the current
Flowable
and the downstreamSubscriber
. The otherPublisher
s are consumed in an unbounded manner. - Scheduler:
- This operator does not operate by default on a particular
Scheduler
.
- Type Parameters:
T1
- the first other source's value typeT2
- the second other source's value typeT3
- the third other source's value typeT4
- the fourth other source's value typeR
- the result value type- Parameters:
source1
- the first otherPublisher
source2
- the second otherPublisher
source3
- the third otherPublisher
source4
- the fourth otherPublisher
combiner
- the function called with an array of values from each participatingPublisher
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifsource1
,source2
,source3
,source4
orcombiner
isnull
- Since:
- 2.0
-
withLatestFrom
@CheckReturnValue @NonNull @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") public final <@NonNull R> @NonNull Flowable<R> withLatestFrom(@NonNull @NonNull org.reactivestreams.Publisher<?>[] others, @NonNull @NonNull Function<? super java.lang.Object[],@NonNull R> combiner)
Combines the value emission from the currentFlowable
with the latest emissions from the otherPublisher
s 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
Flowable
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.- Backpressure:
- This operator is a pass-through for backpressure behavior between the current
Flowable
and the downstreamSubscriber
. The otherPublisher
s are consumed in an unbounded manner. - 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 sourcescombiner
- the function called with an array of values from each participatingPublisher
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifothers
orcombiner
isnull
- Since:
- 2.0
-
withLatestFrom
@CheckReturnValue @NonNull @BackpressureSupport(PASS_THROUGH) @SchedulerSupport("none") public final <@NonNull R> @NonNull Flowable<R> withLatestFrom(@NonNull @NonNull java.lang.Iterable<? extends org.reactivestreams.Publisher<?>> others, @NonNull @NonNull Function<? super java.lang.Object[],@NonNull R> combiner)
Combines the value emission from the currentFlowable
with the latest emissions from the otherPublisher
s 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
Flowable
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.- Backpressure:
- This operator is a pass-through for backpressure behavior between the current
Flowable
and the downstreamSubscriber
. The otherPublisher
s are consumed in an unbounded manner. - 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 sourcescombiner
- the function called with an array of values from each participatingPublisher
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifothers
orcombiner
isnull
- Since:
- 2.0
-
zipWith
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final <@NonNull U,@NonNull R> @NonNull Flowable<R> zipWith(@NonNull @NonNull java.lang.Iterable<@NonNull U> other, @NonNull @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> zipper)
Returns aFlowable
that emits items that are the result of applying a specified function to pairs of values, one each from the currentFlowable
and a specifiedIterable
sequence.Note that the
other
Iterable
is evaluated as items are observed from the currentFlowable
; it is not pre-consumed. This allows you to zip infinite streams on either side.- Backpressure:
- The operator expects backpressure from the sources and honors backpressure from the downstream.
(I.e., zipping with
interval(long, TimeUnit)
may result inMissingBackpressureException
, use one of theonBackpressureX
to handle similar, backpressure-ignoring sources. - Scheduler:
zipWith
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the type of items in theother
Iterable
R
- the type of items emitted by the resultingFlowable
- Parameters:
other
- theIterable
sequencezipper
- a function that combines the pairs of items from the currentFlowable
and theIterable
to generate the items to be emitted by the resultingFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifother
orzipper
isnull
- See Also:
- ReactiveX operators documentation: Zip
-
zipWith
@CheckReturnValue @NonNull @BackpressureSupport(FULL) @SchedulerSupport("none") public final <@NonNull U,@NonNull R> @NonNull Flowable<R> zipWith(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull U> other, @NonNull @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> zipper)
Returns aFlowable
that emits items that are the result of applying a specified function to pairs of values, one each from the currentFlowable
and another specifiedPublisher
.The operator subscribes to its sources in the order they are specified and completes eagerly if one of the sources is shorter than the rest while canceling the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling
doOnComplete()
). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will cancel B immediately. For example:range(1, 5).doOnComplete(action1).zipWith(range(6, 5).doOnComplete(action2), (a, b) -> a + b)
action1
will be called butaction2
won't.
To work around this termination property, usedoOnCancel(Action)
as well or useusing()
to do cleanup in case of completion or cancellation.- Backpressure:
- The operator expects backpressure from the sources and honors backpressure from the downstream.
(I.e., zipping with
interval(long, TimeUnit)
may result inMissingBackpressureException
, use one of theonBackpressureX
to handle similar, backpressure-ignoring sources. - Scheduler:
zipWith
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the type of items emitted by theother
Publisher
R
- the type of items emitted by the resultingFlowable
- Parameters:
other
- the otherPublisher
zipper
- a function that combines the pairs of items from the twoPublisher
s to generate the items to be emitted by the resultingFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifother
orzipper
isnull
- See Also:
- ReactiveX operators documentation: Zip
-
zipWith
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull U,@NonNull R> @NonNull Flowable<R> zipWith(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull U> other, @NonNull @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> zipper, boolean delayError)
Returns aFlowable
that emits items that are the result of applying a specified function to pairs of values, one each from the currentFlowable
and another specifiedPublisher
.The operator subscribes to its sources in the order they are specified and completes eagerly if one of the sources is shorter than the rest while canceling the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling
doOnComplete()
). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will cancel B immediately. For example:range(1, 5).doOnComplete(action1).zipWith(range(6, 5).doOnComplete(action2), (a, b) -> a + b)
action1
will be called butaction2
won't.
To work around this termination property, usedoOnCancel(Action)
as well or useusing()
to do cleanup in case of completion or cancellation.- Backpressure:
- The operator expects backpressure from the sources and honors backpressure from the downstream.
(I.e., zipping with
interval(long, TimeUnit)
may result inMissingBackpressureException
, use one of theonBackpressureX
to handle similar, backpressure-ignoring sources. - Scheduler:
zipWith
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the type of items emitted by theother
Publisher
R
- the type of items emitted by the resultingFlowable
- Parameters:
other
- the otherPublisher
zipper
- a function that combines the pairs of items from the twoPublisher
s to generate the items to be emitted by the resultingFlowable
delayError
- iftrue
, errors from the currentFlowable
or the otherPublisher
is delayed until both terminate- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifother
orzipper
isnull
- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: Zip
-
zipWith
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull U,@NonNull R> @NonNull Flowable<R> zipWith(@NonNull @NonNull org.reactivestreams.Publisher<? extends @NonNull U> other, @NonNull @NonNull BiFunction<? super @NonNull T,? super @NonNull U,? extends @NonNull R> zipper, boolean delayError, int bufferSize)
Returns aFlowable
that emits items that are the result of applying a specified function to pairs of values, one each from the currentFlowable
and another specifiedPublisher
.The operator subscribes to its sources in the order they are specified and completes eagerly if one of the sources is shorter than the rest while canceling the other sources. Therefore, it is possible those other sources will never be able to run to completion (and thus not calling
doOnComplete()
). This can also happen if the sources are exactly the same length; if source A completes and B has been consumed and is about to complete, the operator detects A won't be sending further values and it will cancel B immediately. For example:range(1, 5).doOnComplete(action1).zipWith(range(6, 5).doOnComplete(action2), (a, b) -> a + b)
action1
will be called butaction2
won't.
To work around this termination property, usedoOnCancel(Action)
as well or useusing()
to do cleanup in case of completion or cancellation.- Backpressure:
- The operator expects backpressure from the sources and honors backpressure from the downstream.
(I.e., zipping with
interval(long, TimeUnit)
may result inMissingBackpressureException
, use one of theonBackpressureX
to handle similar, backpressure-ignoring sources. - Scheduler:
zipWith
does not operate by default on a particularScheduler
.
- Type Parameters:
U
- the type of items emitted by theother
Publisher
R
- the type of items emitted by the resultingFlowable
- Parameters:
other
- the otherPublisher
zipper
- a function that combines the pairs of items from the twoPublisher
s to generate the items to be emitted by the resultingFlowable
bufferSize
- the capacity hint for the buffer in the inner windowsdelayError
- iftrue
, errors from the currentFlowable
or the otherPublisher
is delayed until both terminate- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifother
orzipper
isnull
java.lang.IllegalArgumentException
- ifbufferSize
is non-positive- Since:
- 2.0
- See Also:
- ReactiveX operators documentation: Zip
-
test
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @SchedulerSupport("none") @NonNull public final @NonNull TestSubscriber<T> test()
Creates aTestSubscriber
that requestsLong.MAX_VALUE
and subscribes it to thisFlowable
.- Backpressure:
- The returned
TestSubscriber
consumes thisFlowable
in an unbounded fashion. - Scheduler:
test
does not operate by default on a particularScheduler
.
- Returns:
- the new
TestSubscriber
instance - Since:
- 2.0
-
test
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull TestSubscriber<T> test(long initialRequest)
Creates aTestSubscriber
with the given initial request amount and subscribes it to thisFlowable
.- Backpressure:
- The returned
TestSubscriber
requests the giveninitialRequest
amount upfront. - Scheduler:
test
does not operate by default on a particularScheduler
.
- Parameters:
initialRequest
- the initial request amount, positive- Returns:
- the new
TestSubscriber
instance - Since:
- 2.0
-
test
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull TestSubscriber<T> test(long initialRequest, boolean cancel)
Creates aTestSubscriber
with the given initial request amount, optionally cancels it before the subscription and subscribes it to thisFlowable
.- Backpressure:
- The returned
TestSubscriber
requests the giveninitialRequest
amount upfront. - Scheduler:
test
does not operate by default on a particularScheduler
.
- Parameters:
initialRequest
- the initial request amount, positivecancel
- should theTestSubscriber
be canceled before the subscription?- Returns:
- the new
TestSubscriber
instance - Since:
- 2.0
-
fromOptional
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<@NonNull T> fromOptional(@NonNull @NonNull java.util.Optional<@NonNull T> optional)
Converts the existing value of the provided optional into ajust(Object)
or an empty optional into anempty()
Flowable
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)
aroundfromOptional
:Flowable.defer(() -> Flowable.fromOptional(createOptional()));
- Backpressure:
- The returned
Flowable
supports backpressure. - Scheduler:
fromOptional
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the element type of the optional value- Parameters:
optional
- the optional value to convert into aFlowable
- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifoptional
isnull
- Since:
- 3.0.0
- See Also:
just(Object)
,empty()
-
fromCompletionStage
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<@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 theCompletionStage
is to be created per consumer upon subscription, usedefer(Supplier)
aroundfromCompletionStage
:Flowable.defer(() -> Flowable.fromCompletionStage(createCompletionStage()));
If the
CompletionStage
completes withnull
, aNullPointerException
is signaled.Canceling the flow can't cancel the execution of the
CompletionStage
becauseCompletionStage
itself doesn't support cancellation. Instead, the operator detaches from theCompletionStage
.- Backpressure:
- The returned
Flowable
supports backpressure and caches the completion value until the downstream is ready to receive it. - Scheduler:
fromCompletionStage
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the element type of theCompletionStage
- Parameters:
stage
- theCompletionStage
to convert toFlowable
and signal its terminal value or error- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifstage
isnull
- Since:
- 3.0.0
-
fromStream
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public static <@NonNull T> @NonNull Flowable<@NonNull T> fromStream(@NonNull @NonNull java.util.stream.Stream<@NonNull T> stream)
Converts aStream
into a finiteFlowable
and emits its items in the sequence.The operator closes the
Stream
upon cancellation and when it terminates. Any exceptions raised when closing aStream
are routed to the global error handler (RxJavaPlugins.onError(Throwable)
. If aStream
should not be closed, turn it into anIterable
and usefromIterable(Iterable)
:Stream<T> stream = ... Flowable.fromIterable(stream::iterator);
Note that
Stream
s can be consumed only once; any subsequent attempt to consume aStream
will result in anIllegalStateException
.Primitive streams are not supported and items have to be boxed manually (e.g., via
IntStream.boxed()
):IntStream intStream = IntStream.rangeClosed(1, 10); Flowable.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.- Backpressure:
- The operator honors backpressure from downstream and iterates the given
Stream
on demand (i.e., when requested). - Scheduler:
fromStream
does not operate by default on a particularScheduler
.
- Type Parameters:
T
- the element type of the sourceStream
- Parameters:
stream
- theStream
of values to emit- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifstream
isnull
- Since:
- 3.0.0
- See Also:
fromIterable(Iterable)
-
mapOptional
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Flowable<R> mapOptional(@NonNull @NonNull Function<? super @NonNull T,@NonNull java.util.Optional<? extends @NonNull R>> mapper)
Maps each upstream value into anOptional
and emits the contained item if not empty.- Backpressure:
- The operator is a pass-through for downstream requests but issues
request(1)
whenever the mappedOptional
is empty. - Scheduler:
mapOptional
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the non-null
output type- Parameters:
mapper
- the function that receives the upstream item and should return a non-emptyOptional
to emit as the output or an emptyOptional
to skip to the next upstream value- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 3.0.0
- See Also:
map(Function)
,filter(Predicate)
-
collect
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @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 aStream
Collector
callback set and emits it as the success result.- Backpressure:
- The operator consumes the upstream in an unbounded manner.
- Scheduler:
collect
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the non-null
result typeA
- the intermediate container type used for the accumulation- Parameters:
collector
- the interface defining the container supplier, accumulator and finisher functions; seeCollectors
for some standard implementations- Returns:
- the new
Single
instance - Throws:
java.lang.NullPointerException
- ifcollector
isnull
- Since:
- 3.0.0
- See Also:
Collectors
,collect(Supplier, BiConsumer)
-
firstStage
@CheckReturnValue @BackpressureSupport(FULL) @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 aCompletionStage
.The upstream can be canceled by converting the resulting
CompletionStage
intoCompletableFuture
viaCompletionStage.toCompletableFuture()
and callingCompletableFuture.cancel(boolean)
on it. The upstream will be also cancelled if the resultingCompletionStage
is converted to and completed manually byCompletableFuture.complete(Object)
orCompletableFuture.completeExceptionally(Throwable)
.CompletionStage
s don't have a notion of emptiness and allownull
s, therefore, one can either use adefaultItem
ofnull
or turn the flow into a sequence ofOptional
s and default toOptional.empty()
:CompletionStage<Optional<T>> stage = source.map(Optional::of).firstStage(Optional.empty());
- Backpressure:
- The operator requests one item from upstream and then when received, cancels the upstream.
- Scheduler:
firstStage
does not operate by default on a particularScheduler
.
- Parameters:
defaultItem
- the item to signal if the upstream is empty- Returns:
- the new
CompletionStage
instance - Since:
- 3.0.0
- See Also:
firstOrErrorStage()
-
singleStage
@CheckReturnValue @BackpressureSupport(FULL) @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 signalsIllegalArgumentException
if the upstream has more than one item via aCompletionStage
.The upstream can be canceled by converting the resulting
CompletionStage
intoCompletableFuture
viaCompletionStage.toCompletableFuture()
and callingCompletableFuture.cancel(boolean)
on it. The upstream will be also cancelled if the resultingCompletionStage
is converted to and completed manually byCompletableFuture.complete(Object)
orCompletableFuture.completeExceptionally(Throwable)
.CompletionStage
s don't have a notion of emptiness and allownull
s, therefore, one can either use adefaultItem
ofnull
or turn the flow into a sequence ofOptional
s and default toOptional.empty()
:CompletionStage<Optional<T>> stage = source.map(Optional::of).singleStage(Optional.empty());
- Backpressure:
- The operator requests two items from upstream and then when more than one item is received, cancels the upstream.
- Scheduler:
singleStage
does not operate by default on a particularScheduler
.
- Parameters:
defaultItem
- the item to signal if the upstream is empty- Returns:
- the new
CompletionStage
instance - Since:
- 3.0.0
- See Also:
singleOrErrorStage()
-
lastStage
@CheckReturnValue @BackpressureSupport(UNBOUNDED_IN) @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 aCompletionStage
.The upstream can be canceled by converting the resulting
CompletionStage
intoCompletableFuture
viaCompletionStage.toCompletableFuture()
and callingCompletableFuture.cancel(boolean)
on it. The upstream will be also cancelled if the resultingCompletionStage
is converted to and completed manually byCompletableFuture.complete(Object)
orCompletableFuture.completeExceptionally(Throwable)
.CompletionStage
s don't have a notion of emptiness and allownull
s, therefore, one can either use adefaultItem
ofnull
or turn the flow into a sequence ofOptional
s and default toOptional.empty()
:CompletionStage<Optional<T>> stage = source.map(Optional::of).lastStage(Optional.empty());
- Backpressure:
- The operator requests an unbounded number of items from the upstream.
- Scheduler:
lastStage
does not operate by default on a particularScheduler
.
- Parameters:
defaultItem
- the item to signal if the upstream is empty- Returns:
- the new
CompletionStage
instance - Since:
- 3.0.0
- See Also:
lastOrErrorStage()
-
firstOrErrorStage
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull java.util.concurrent.CompletionStage<T> firstOrErrorStage()
Signals the first upstream item or aNoSuchElementException
if the upstream is empty via aCompletionStage
.The upstream can be canceled by converting the resulting
CompletionStage
intoCompletableFuture
viaCompletionStage.toCompletableFuture()
and callingCompletableFuture.cancel(boolean)
on it. The upstream will be also cancelled if the resultingCompletionStage
is converted to and completed manually byCompletableFuture.complete(Object)
orCompletableFuture.completeExceptionally(Throwable)
.- Backpressure:
- The operator requests one item from upstream and then when received, cancels the upstream.
- Scheduler:
firstOrErrorStage
does not operate by default on a particularScheduler
.
- Returns:
- the new
CompletionStage
instance - Since:
- 3.0.0
- See Also:
firstStage(Object)
-
singleOrErrorStage
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull java.util.concurrent.CompletionStage<T> singleOrErrorStage()
Signals the only expected upstream item, aNoSuchElementException
if the upstream is empty or signalsIllegalArgumentException
if the upstream has more than one item via aCompletionStage
.The upstream can be canceled by converting the resulting
CompletionStage
intoCompletableFuture
viaCompletionStage.toCompletableFuture()
and callingCompletableFuture.cancel(boolean)
on it. The upstream will be also cancelled if the resultingCompletionStage
is converted to and completed manually byCompletableFuture.complete(Object)
orCompletableFuture.completeExceptionally(Throwable)
.- Backpressure:
- The operator requests two items from upstream and then when more than one item is received, cancels the upstream.
- Scheduler:
singleOrErrorStage
does not operate by default on a particularScheduler
.
- Returns:
- the new
CompletionStage
instance - Since:
- 3.0.0
- See Also:
singleStage(Object)
-
lastOrErrorStage
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull java.util.concurrent.CompletionStage<T> lastOrErrorStage()
Signals the last upstream item or aNoSuchElementException
if the upstream is empty via aCompletionStage
.The upstream can be canceled by converting the resulting
CompletionStage
intoCompletableFuture
viaCompletionStage.toCompletableFuture()
and callingCompletableFuture.cancel(boolean)
on it. The upstream will be also cancelled if the resultingCompletionStage
is converted to and completed manually byCompletableFuture.complete(Object)
orCompletableFuture.completeExceptionally(Throwable)
.- Backpressure:
- The operator requests an unbounded number of items from the upstream.
- Scheduler:
lastOrErrorStage
does not operate by default on a particularScheduler
.
- Returns:
- the new
CompletionStage
instance - Since:
- 3.0.0
- See Also:
lastStage(Object)
-
blockingStream
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull java.util.stream.Stream<T> blockingStream()
Creates a sequentialStream
to consume or process thisFlowable
in a blocking manner via the JavaStream
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:Flowable<Integer> source = Flowable.range(1, 10) .subscribeOn(Schedulers.computation()); try (Stream<Integer> stream = source.blockingStream()) { stream.limit(3).forEach(System.out::println); }
- Backpressure:
- The operator requests
bufferSize()
amount upfront and 75% of it after each 75% of the amount received. - Scheduler:
blockingStream
does not operate by default on a particularScheduler
.
- Returns:
- the new
Stream
instance - Since:
- 3.0.0
- See Also:
blockingStream(int)
-
blockingStream
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final @NonNull java.util.stream.Stream<T> blockingStream(int prefetch)
Creates a sequentialStream
to consume or process thisFlowable
in a blocking manner via the JavaStream
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:Flowable<Integer> source = Flowable.range(1, 10) .subscribeOn(Schedulers.computation()); try (Stream<Integer> stream = source.blockingStream(4)) { stream.limit(3).forEach(System.out::println); }
- Backpressure:
- The operator requests the given
prefetch
amount upfront and 75% of it after each 75% of the amount received. - Scheduler:
blockingStream
does not operate by default on a particularScheduler
.
- Parameters:
prefetch
- the number of items to request from the upstream to limit the number of in-flight items and item generation.- Returns:
- the new
Stream
instance - Throws:
java.lang.IllegalArgumentException
- ifprefetch
is non-positive- Since:
- 3.0.0
-
concatMapStream
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Flowable<R> concatMapStream(@NonNull @NonNull Function<? super @NonNull T,? extends java.util.stream.Stream<? extends @NonNull R>> mapper)
Maps each upstream item into aStream
and emits theStream
's items to the downstream in a sequential fashion.Due to the blocking and sequential nature of Java
Stream
s, the streams are mapped and consumed in a sequential fashion without interleaving (unlike a more generalflatMap(Function)
). Therefore,flatMapStream
andconcatMapStream
are identical operators and are provided as aliases.The operator closes the
Stream
upon cancellation and when it terminates. Any exceptions raised when closing aStream
are routed to the global error handler (RxJavaPlugins.onError(Throwable)
. If aStream
should not be closed, turn it into anIterable
and useconcatMapIterable(Function)
:source.concatMapIterable(v -> createStream(v)::iterator);
Note that
Stream
s can be consumed only once; any subsequent attempt to consume aStream
will result in anIllegalStateException
.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.- Backpressure:
- The operator honors the downstream backpressure and consumes the inner stream only on demand. The operator
prefetches
bufferSize()
items of the upstream (then 75% of it after the 75% received) and caches them until they are ready to be mapped intoStream
s after the currentStream
has been consumed. - Scheduler:
concatMapStream
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the element type of theStream
s and the result- Parameters:
mapper
- the function that receives an upstream item and should return aStream
whose elements will be emitted to the downstream- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 3.0.0
- See Also:
concatMap(Function)
,concatMapIterable(Function)
,concatMapStream(Function, int)
-
concatMapStream
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Flowable<R> concatMapStream(@NonNull @NonNull Function<? super @NonNull T,? extends java.util.stream.Stream<? extends @NonNull R>> mapper, int prefetch)
Maps each upstream item into aStream
and emits theStream
's items to the downstream in a sequential fashion.Due to the blocking and sequential nature of Java
Stream
s, the streams are mapped and consumed in a sequential fashion without interleaving (unlike a more generalflatMap(Function)
). Therefore,flatMapStream
andconcatMapStream
are identical operators and are provided as aliases.The operator closes the
Stream
upon cancellation and when it terminates. Any exceptions raised when closing aStream
are routed to the global error handler (RxJavaPlugins.onError(Throwable)
. If aStream
should not be closed, turn it into anIterable
and useconcatMapIterable(Function, int)
:source.concatMapIterable(v -> createStream(v)::iterator, 32);
Note that
Stream
s can be consumed only once; any subsequent attempt to consume aStream
will result in anIllegalStateException
.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(), 32);
Stream
does not support concurrent usage so creating and/or consuming the same instance multiple times from multiple threads can lead to undefined behavior.- Backpressure:
- The operator honors the downstream backpressure and consumes the inner stream only on demand. The operator
prefetches the given amount of upstream items and caches them until they are ready to be mapped into
Stream
s after the currentStream
has been consumed. - Scheduler:
concatMapStream
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the element type of theStream
s and the result- Parameters:
mapper
- the function that receives an upstream item and should return aStream
whose elements will be emitted to the downstreamprefetch
- the number of upstream items to request upfront, then 75% of this amount after each 75% upstream items received- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifprefetch
is non-positive- Since:
- 3.0.0
- See Also:
concatMap(Function, int)
,concatMapIterable(Function, int)
,flatMapStream(Function, int)
-
flatMapStream
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Flowable<R> flatMapStream(@NonNull @NonNull Function<? super @NonNull T,? extends java.util.stream.Stream<? extends @NonNull R>> mapper)
Maps each upstream item into aStream
and emits theStream
's items to the downstream in a sequential fashion.Due to the blocking and sequential nature of Java
Stream
s, the streams are mapped and consumed in a sequential fashion without interleaving (unlike a more generalflatMap(Function)
). Therefore,flatMapStream
andconcatMapStream
are identical operators and are provided as aliases.The operator closes the
Stream
upon cancellation and when it terminates. Any exceptions raised when closing aStream
are routed to the global error handler (RxJavaPlugins.onError(Throwable)
. If aStream
should not be closed, turn it into anIterable
and useflatMapIterable(Function)
:source.flatMapIterable(v -> createStream(v)::iterator);
Note that
Stream
s can be consumed only once; any subsequent attempt to consume aStream
will result in anIllegalStateException
.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.- Backpressure:
- The operator honors the downstream backpressure and consumes the inner stream only on demand. The operator
prefetches
bufferSize()
items of the upstream (then 75% of it after the 75% received) and caches them until they are ready to be mapped intoStream
s after the currentStream
has been consumed. - Scheduler:
flatMapStream
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the element type of theStream
s and the result- Parameters:
mapper
- the function that receives an upstream item and should return aStream
whose elements will be emitted to the downstream- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
- Since:
- 3.0.0
- See Also:
flatMap(Function)
,flatMapIterable(Function)
,flatMapStream(Function, int)
-
flatMapStream
@CheckReturnValue @BackpressureSupport(FULL) @SchedulerSupport("none") @NonNull public final <@NonNull R> @NonNull Flowable<R> flatMapStream(@NonNull @NonNull Function<? super @NonNull T,? extends java.util.stream.Stream<? extends @NonNull R>> mapper, int prefetch)
Maps each upstream item into aStream
and emits theStream
's items to the downstream in a sequential fashion.Due to the blocking and sequential nature of Java
Stream
s, the streams are mapped and consumed in a sequential fashion without interleaving (unlike a more generalflatMap(Function)
). Therefore,flatMapStream
andconcatMapStream
are identical operators and are provided as aliases.The operator closes the
Stream
upon cancellation and when it terminates. Any exceptions raised when closing aStream
are routed to the global error handler (RxJavaPlugins.onError(Throwable)
. If aStream
should not be closed, turn it into anIterable
and useflatMapIterable(Function, int)
:source.flatMapIterable(v -> createStream(v)::iterator, 32);
Note that
Stream
s can be consumed only once; any subsequent attempt to consume aStream
will result in anIllegalStateException
.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(), 32);
Stream
does not support concurrent usage so creating and/or consuming the same instance multiple times from multiple threads can lead to undefined behavior.- Backpressure:
- The operator honors the downstream backpressure and consumes the inner stream only on demand. The operator
prefetches the given amount of upstream items and caches them until they are ready to be mapped into
Stream
s after the currentStream
has been consumed. - Scheduler:
flatMapStream
does not operate by default on a particularScheduler
.
- Type Parameters:
R
- the element type of theStream
s and the result- Parameters:
mapper
- the function that receives an upstream item and should return aStream
whose elements will be emitted to the downstreamprefetch
- the number of upstream items to request upfront, then 75% of this amount after each 75% upstream items received- Returns:
- the new
Flowable
instance - Throws:
java.lang.NullPointerException
- ifmapper
isnull
java.lang.IllegalArgumentException
- ifprefetch
is non-positive- Since:
- 3.0.0
- See Also:
flatMap(Function, int)
,flatMapIterable(Function, int)
,concatMapStream(Function, int)
-
-