T - the value typepublic abstract class Maybe<T> extends Object implements MaybeSource<T>
Maybe class represents a deferred computation and emission of a single value, no value at all or an exception.
The Maybe class implements the MaybeSource base interface and the default consumer
type it interacts with is the MaybeObserver via the subscribe(MaybeObserver) method.
The Maybe operates with the following sequential protocol:
onSubscribe (onSuccess | onError | onComplete)?
Note that onSuccess, onError and onComplete are mutually exclusive events; unlike Observable,
onSuccess is never followed by onError or onComplete.
Like Observable, a running Maybe can be stopped through the Disposable instance
provided to consumers through MaybeObserver.onSubscribe(io.reactivex.rxjava3.disposables.Disposable).
Like an Observable, a Maybe is lazy, can be either "hot" or "cold", synchronous or
asynchronous. Maybe instances returned by the methods of this class are cold
and there is a standard hot implementation in the form of a subject:
MaybeSubject.
The documentation for this class makes use of marble diagrams. The following legend explains these diagrams:
See Flowable or Observable for the
implementation of the Reactive Pattern for a stream or vector of values.
Example:
Disposable d = Maybe.just("Hello World")
.delay(10, TimeUnit.SECONDS, Schedulers.io())
.subscribeWith(new DisposableMaybeObserver<String>() {
@Override
public void onStart() {
System.out.println("Started");
}
@Override
public void onSuccess(String value) {
System.out.println("Success: " + value);
}
@Override
public void onError(Throwable error) {
error.printStackTrace();
}
@Override
public void onComplete() {
System.out.println("Done!");
}
});
Thread.sleep(5000);
d.dispose();
Note that by design, subscriptions via subscribe(MaybeObserver) can't be disposed
from the outside (hence the
void return of the subscribe(MaybeObserver) method) and it is the
responsibility of the implementor of the MaybeObserver to allow this to happen.
RxJava supports such usage with the standard
DisposableMaybeObserver instance.
For convenience, the subscribeWith(MaybeObserver) method is provided as well to
allow working with a MaybeObserver (or subclass) instance to be applied with in
a fluent manner (such as in the example above).
DisposableMaybeObserver| Constructor and Description |
|---|
Maybe() |
| Modifier and Type | Method and Description |
|---|---|
static <T> @NonNull Maybe<T> |
amb(@NonNull Iterable<? extends MaybeSource<? extends T>> sources)
Runs multiple
MaybeSources provided by an Iterable sequence and
signals the events of the first one that signals (disposing the rest). |
static <T> @NonNull Maybe<T> |
ambArray(MaybeSource<? extends T>... sources)
Runs multiple
MaybeSources and signals the events of the first one that signals (disposing
the rest). |
@NonNull Maybe<T> |
ambWith(@NonNull MaybeSource<? extends T> other)
Mirrors the
MaybeSource (current or provided) that first signals an event. |
T |
blockingGet()
Waits in a blocking fashion until the current
Maybe signals a success value (which is returned),
null if completed or an exception (which is propagated). |
T |
blockingGet(T defaultValue)
Waits in a blocking fashion until the current
Maybe signals a success value (which is returned),
defaultValue if completed or an exception (which is propagated). |
void |
blockingSubscribe()
Subscribes to the current
Maybe and blocks the current thread until it terminates. |
void |
blockingSubscribe(@NonNull Consumer<? super T> onSuccess)
Subscribes to the current
Maybe and calls given onSuccess callback on the current thread
when it completes normally. |
void |
blockingSubscribe(@NonNull Consumer<? super T> onSuccess,
@NonNull Consumer<? super Throwable> onError)
Subscribes to the current
Maybe and calls the appropriate callback on the current thread
when it terminates. |
void |
blockingSubscribe(@NonNull Consumer<? super T> onSuccess,
@NonNull Consumer<? super Throwable> onError,
@NonNull Action onComplete)
Subscribes to the current
Maybe and calls the appropriate callback on the current thread
when it terminates. |
void |
blockingSubscribe(@NonNull MaybeObserver<? super T> observer)
Subscribes to the current
Maybe and calls the appropriate MaybeObserver method on the current thread. |
@NonNull Maybe<T> |
cache()
Returns a
Maybe that subscribes to this Maybe lazily, caches its event
and replays it, to all the downstream subscribers. |
<U> @NonNull Maybe<U> |
cast(@NonNull Class<? extends U> clazz)
Casts the success value of the current
Maybe into the target type or signals a
ClassCastException if not compatible. |
<R> @NonNull Maybe<R> |
compose(@NonNull MaybeTransformer<? super T,? extends R> transformer)
Transform a
Maybe by applying a particular MaybeTransformer function to it. |
static <T> @NonNull Flowable<T> |
concat(@NonNull Iterable<? extends MaybeSource<? extends T>> sources)
Concatenate the single values, in a non-overlapping fashion, of the
MaybeSource sources provided by
an Iterable sequence as a Flowable sequence. |
static <T> @NonNull Flowable<T> |
concat(@NonNull MaybeSource<? extends T> source1,
@NonNull MaybeSource<? extends T> source2)
Returns a
Flowable that emits the items emitted by two MaybeSources, one after the other. |
static <T> @NonNull Flowable<T> |
concat(@NonNull MaybeSource<? extends T> source1,
@NonNull MaybeSource<? extends T> source2,
@NonNull MaybeSource<? extends T> source3)
Returns a
Flowable that emits the items emitted by three MaybeSources, one after the other. |
static <T> @NonNull Flowable<T> |
concat(@NonNull MaybeSource<? extends T> source1,
@NonNull MaybeSource<? extends T> source2,
@NonNull MaybeSource<? extends T> source3,
@NonNull MaybeSource<? extends T> source4)
Returns a
Flowable that emits the items emitted by four MaybeSources, one after the other. |
static <T> @NonNull Flowable<T> |
concat(@NonNull Publisher<? extends MaybeSource<? extends T>> sources)
Concatenate the single values, in a non-overlapping fashion, of the
MaybeSource sources provided by
a Publisher sequence as a Flowable sequence. |
static <T> @NonNull Flowable<T> |
concat(@NonNull Publisher<? extends MaybeSource<? extends T>> sources,
int prefetch)
Concatenate the single values, in a non-overlapping fashion, of the
MaybeSource sources provided by
a Publisher sequence as a Flowable sequence. |
static <T> @NonNull Flowable<T> |
concatArray(MaybeSource<? extends T>... sources)
Concatenate the single values, in a non-overlapping fashion, of the
MaybeSource sources in the array
as a Flowable sequence. |
static <T> @NonNull Flowable<T> |
concatArrayDelayError(MaybeSource<? extends T>... sources)
Concatenates a variable number of
MaybeSource sources and delays errors from any of them
till all terminate as a Flowable sequence. |
static <T> @NonNull Flowable<T> |
concatArrayEager(MaybeSource<? extends T>... sources)
Concatenates a sequence of
MaybeSource eagerly into a Flowable sequence. |
static <T> @NonNull Flowable<T> |
concatArrayEagerDelayError(MaybeSource<? extends T>... sources)
Concatenates a sequence of
MaybeSource eagerly into a Flowable sequence. |
static <T> @NonNull Flowable<T> |
concatDelayError(@NonNull Iterable<? extends MaybeSource<? extends T>> sources)
Concatenates the
Iterable sequence of MaybeSources into a single sequence by subscribing to each MaybeSource,
one after the other, one at a time and delays any errors till the all inner MaybeSources terminate
as a Flowable sequence. |
static <T> @NonNull Flowable<T> |
concatDelayError(@NonNull Publisher<? extends MaybeSource<? extends T>> sources)
Concatenates the
Publisher sequence of MaybeSources into a single sequence by subscribing to each inner MaybeSource,
one after the other, one at a time and delays any errors till the all inner and the outer Publisher terminate
as a Flowable sequence. |
static <T> @NonNull Flowable<T> |
concatDelayError(@NonNull Publisher<? extends MaybeSource<? extends T>> sources,
int prefetch)
Concatenates the
Publisher sequence of MaybeSources into a single sequence by subscribing to each inner MaybeSource,
one after the other, one at a time and delays any errors till the all inner and the outer Publisher terminate
as a Flowable sequence. |
static <T> @NonNull Flowable<T> |
concatEager(@NonNull Iterable<? extends MaybeSource<? extends T>> sources)
Concatenates a sequence of
MaybeSources eagerly into a Flowable sequence. |
static <T> @NonNull Flowable<T> |
concatEager(@NonNull Iterable<? extends MaybeSource<? extends T>> sources,
int maxConcurrency)
Concatenates a sequence of
MaybeSources eagerly into a Flowable sequence and
runs a limited number of the inner sequences at once. |
static <T> @NonNull Flowable<T> |
concatEager(@NonNull Publisher<? extends MaybeSource<? extends T>> sources)
|
static <T> @NonNull Flowable<T> |
concatEager(@NonNull Publisher<? extends MaybeSource<? extends T>> sources,
int maxConcurrency)
Concatenates a
Publisher sequence of MaybeSources eagerly into a Flowable sequence,
running at most the given number of inner MaybeSources at once. |
static <T> @NonNull Flowable<T> |
concatEagerDelayError(@NonNull Iterable<? extends MaybeSource<? extends T>> sources)
Concatenates a sequence of
MaybeSources eagerly into a Flowable sequence,
delaying errors until all inner MaybeSources terminate. |
static <T> @NonNull Flowable<T> |
concatEagerDelayError(@NonNull Iterable<? extends MaybeSource<? extends T>> sources,
int maxConcurrency)
Concatenates a sequence of
MaybeSources eagerly into a Flowable sequence,
delaying errors until all inner MaybeSources terminate and
runs a limited number of inner MaybeSources at once. |
static <T> @NonNull Flowable<T> |
concatEagerDelayError(@NonNull Publisher<? extends MaybeSource<? extends T>> sources)
Concatenates a
Publisher sequence of MaybeSources eagerly into a Flowable sequence,
delaying errors until all the inner and the outer sequence terminate. |
static <T> @NonNull Flowable<T> |
concatEagerDelayError(@NonNull Publisher<? extends MaybeSource<? extends T>> sources,
int maxConcurrency)
Concatenates a
Publisher sequence of MaybeSources eagerly into a Flowable sequence,
delaying errors until all the inner and the outer sequence terminate and
runs a limited number of the inner MaybeSources at once. |
<R> @NonNull Maybe<R> |
concatMap(@NonNull Function<? super T,? extends MaybeSource<? extends R>> mapper)
Returns a
Maybe that is based on applying a specified function to the item emitted by the current Maybe,
where that function returns a MaybeSource. |
@NonNull Completable |
concatMapCompletable(@NonNull Function<? super T,? extends CompletableSource> mapper)
Returns a
Completable that completes based on applying a specified function to the item emitted by the
current Maybe, where that function returns a Completable. |
<R> @NonNull Maybe<R> |
concatMapSingle(@NonNull Function<? super T,? extends SingleSource<? extends R>> mapper)
Returns a
Maybe based on applying a specified function to the item emitted by the
current Maybe, where that function returns a Single. |
@NonNull Flowable<T> |
concatWith(@NonNull MaybeSource<? extends T> other)
Returns a
Flowable that emits the items emitted from the current Maybe, then the other MaybeSource, one after
the other, without interleaving them. |
@NonNull Single<Boolean> |
contains(@NonNull Object item)
|
@NonNull Single<Long> |
count()
|
static <T> @NonNull Maybe<T> |
create(@NonNull MaybeOnSubscribe<T> onSubscribe)
Provides an API (via a cold
Maybe) that bridges the reactive world with the callback-style world. |
@NonNull Single<T> |
defaultIfEmpty(T defaultItem)
Returns a
Single that emits the item emitted by the current Maybe or a specified default item
if the current Maybe is empty. |
static <T> @NonNull Maybe<T> |
defer(@NonNull Supplier<? extends MaybeSource<? extends T>> supplier)
Calls a
Supplier for each individual MaybeObserver to return the actual MaybeSource source to
be subscribed to. |
@NonNull Maybe<T> |
delay(long time,
@NonNull TimeUnit unit)
Returns a
Maybe that signals the events emitted by the current Maybe shifted forward in time by a
specified delay. |
@NonNull Maybe<T> |
delay(long time,
@NonNull TimeUnit unit,
boolean delayError)
Returns a
Maybe that signals the events emitted by the current Maybe shifted forward in time by a
specified delay. |
@NonNull Maybe<T> |
delay(long time,
@NonNull TimeUnit unit,
@NonNull Scheduler scheduler)
Returns a
Maybe that signals the events emitted by the current Maybe shifted forward in time by a
specified delay. |
@NonNull Maybe<T> |
delay(long time,
@NonNull TimeUnit unit,
@NonNull Scheduler scheduler,
boolean delayError)
Returns a
Maybe that signals the events emitted by the current Maybe shifted forward in time by a
specified delay running on the specified Scheduler. |
<U> @NonNull Maybe<T> |
delay(@NonNull Publisher<U> delayIndicator)
Delays the emission of this
Maybe until the given Publisher signals an item or completes. |
@NonNull Maybe<T> |
delaySubscription(long time,
@NonNull TimeUnit unit)
Returns a
Maybe that delays the subscription to the current Maybe by a given amount of time. |
@NonNull Maybe<T> |
delaySubscription(long time,
@NonNull TimeUnit unit,
@NonNull Scheduler scheduler)
Returns a
Maybe that delays the subscription to the current Maybe by a given amount of time,
both waiting and subscribing on a given Scheduler. |
<U> @NonNull Maybe<T> |
delaySubscription(@NonNull Publisher<U> subscriptionIndicator)
Returns a
Maybe that delays the subscription to this Maybe
until the other Publisher emits an element or completes normally. |
<R> @NonNull Maybe<R> |
dematerialize(@NonNull Function<? super T,Notification<R>> selector)
Maps the
Notification success value of the current Maybe back into normal
onSuccess, onError or onComplete signals. |
@NonNull Maybe<T> |
doAfterSuccess(@NonNull Consumer<? super T> onAfterSuccess)
Calls the specified
Consumer with the success item after this item has been emitted to the downstream. |
@NonNull Maybe<T> |
doAfterTerminate(@NonNull Action onAfterTerminate)
|
@NonNull Maybe<T> |
doFinally(@NonNull Action onFinally)
Calls the specified action after this
Maybe signals onSuccess, onError or onComplete or gets disposed by
the downstream. |
@NonNull Maybe<T> |
doOnComplete(@NonNull Action onComplete)
|
@NonNull Maybe<T> |
doOnDispose(@NonNull Action onDispose)
Calls the shared
Action if a MaybeObserver subscribed to the current Maybe
disposes the common Disposable it received via onSubscribe. |
@NonNull Maybe<T> |
doOnError(@NonNull Consumer<? super Throwable> onError)
Calls the shared
Consumer with the error sent via onError for each
MaybeObserver that subscribes to the current Maybe. |
@NonNull Maybe<T> |
doOnEvent(@NonNull BiConsumer<? super T,? super Throwable> onEvent)
Calls the given
onEvent callback with the (success value, null) for an onSuccess, (null, throwable) for
an onError or (null, null) for an onComplete signal from this Maybe before delivering said
signal to the downstream. |
@NonNull Maybe<T> |
doOnLifecycle(@NonNull Consumer<? super Disposable> onSubscribe,
@NonNull Action onDispose)
Calls the appropriate
onXXX method (shared between all MaybeObservers) for the lifecycle events of
the sequence (subscription, disposal). |
@NonNull Maybe<T> |
doOnSubscribe(@NonNull Consumer<? super Disposable> onSubscribe)
Calls the shared
Consumer with the Disposable sent through the onSubscribe for each
MaybeObserver that subscribes to the current Maybe. |
@NonNull Maybe<T> |
doOnSuccess(@NonNull Consumer<? super T> onSuccess)
Calls the shared
Consumer with the success value sent via onSuccess for each
MaybeObserver that subscribes to the current Maybe. |
@NonNull Maybe<T> |
doOnTerminate(@NonNull Action onTerminate)
Returns a
Maybe instance that calls the given onTerminate callback
just before this Maybe completes normally or with an exception. |
static <T> @NonNull Maybe<T> |
empty()
Returns a (singleton)
Maybe instance that calls onComplete
immediately. |
static <T> @NonNull Maybe<T> |
error(@NonNull Supplier<? extends Throwable> supplier)
Returns a
Maybe that invokes a MaybeObserver's onError method when the
MaybeObserver subscribes to it. |
static <T> @NonNull Maybe<T> |
error(@NonNull Throwable throwable)
Returns a
Maybe that invokes a subscriber's onError method when the
subscriber subscribes to it. |
@NonNull Maybe<T> |
filter(@NonNull Predicate<? super T> predicate)
Filters the success item of the
Maybe via a predicate function and emitting it if the predicate
returns true, completing otherwise. |
<R> @NonNull Maybe<R> |
flatMap(@NonNull Function<? super T,? extends MaybeSource<? extends R>> mapper)
Returns a
Maybe that is based on applying a specified function to the item emitted by the current Maybe,
where that function returns a MaybeSource. |
<R> @NonNull Maybe<R> |
flatMap(@NonNull Function<? super T,? extends MaybeSource<? extends R>> onSuccessMapper,
@NonNull Function<? super Throwable,? extends MaybeSource<? extends R>> onErrorMapper,
@NonNull Supplier<? extends MaybeSource<? extends R>> onCompleteSupplier)
Maps the
onSuccess, onError or onComplete signals of the current Maybe into a MaybeSource and emits that
MaybeSource's signals. |
<U,R> @NonNull Maybe<R> |
flatMap(@NonNull Function<? super T,? extends MaybeSource<? extends U>> mapper,
@NonNull BiFunction<? super T,? super U,? extends R> combiner)
Returns a
Maybe that emits the results of a specified function to the pair of values emitted by the
current Maybe and a specified mapped MaybeSource. |
@NonNull Completable |
flatMapCompletable(@NonNull Function<? super T,? extends CompletableSource> mapper)
Returns a
Completable that completes based on applying a specified function to the item emitted by the
current Maybe, where that function returns a Completable. |
<R> @NonNull Observable<R> |
flatMapObservable(@NonNull Function<? super T,? extends ObservableSource<? extends R>> mapper)
Returns an
Observable that is based on applying a specified function to the item emitted by the current Maybe,
where that function returns an ObservableSource. |
<R> @NonNull Flowable<R> |
flatMapPublisher(@NonNull Function<? super T,? extends Publisher<? extends R>> mapper)
|
<R> @NonNull Maybe<R> |
flatMapSingle(@NonNull Function<? super T,? extends SingleSource<? extends R>> mapper)
Returns a
Maybe based on applying a specified function to the item emitted by the
current Maybe, where that function returns a Single. |
<U> @NonNull Flowable<U> |
flattenAsFlowable(@NonNull Function<? super T,? extends Iterable<? extends U>> mapper)
|
<U> @NonNull Observable<U> |
flattenAsObservable(@NonNull Function<? super T,? extends Iterable<? extends U>> mapper)
Maps the success value of the current
Maybe into an Iterable and emits its items as an
Observable sequence. |
<R> @NonNull Flowable<R> |
flattenStreamAsFlowable(@NonNull Function<? super T,? extends Stream<? extends R>> mapper)
|
<R> @NonNull Observable<R> |
flattenStreamAsObservable(@NonNull Function<? super T,? extends Stream<? extends R>> mapper)
Maps the upstream succecss value into a Java
Stream and emits its
items to the downstream consumer as an Observable. |
static <T> @NonNull Maybe<T> |
fromAction(@NonNull Action action)
Returns a
Maybe instance that runs the given Action for each MaybeObserver and
emits either its exception or simply completes. |
static <T> @NonNull Maybe<T> |
fromCallable(@NonNull Callable<? extends T> callable)
Returns a
Maybe that invokes the given Callable for each individual MaybeObserver that
subscribes and emits the resulting non-null item via onSuccess while
considering a null result from the Callable as indication for valueless completion
via onComplete. |
static <T> @NonNull Maybe<T> |
fromCompletable(@NonNull CompletableSource completableSource)
Wraps a
CompletableSource into a Maybe. |
static <T> @NonNull Maybe<T> |
fromCompletionStage(@NonNull CompletionStage<T> stage)
Signals the completion value or error of the given (hot)
CompletionStage-based asynchronous calculation. |
static <T> @NonNull Maybe<T> |
fromFuture(@NonNull Future<? extends T> future)
|
static <T> @NonNull Maybe<T> |
fromFuture(@NonNull Future<? extends T> future,
long timeout,
@NonNull TimeUnit unit)
|
static <T> @NonNull Maybe<T> |
fromObservable(@NonNull ObservableSource<T> source)
Wraps an
ObservableSource into a Maybe and emits the very first item
or completes if the source is empty. |
static <T> @NonNull Maybe<T> |
fromOptional(@NonNull Optional<T> optional)
Converts the existing value of the provided optional into a
just(Object)
or an empty optional into an empty() Maybe instance. |
static <T> @NonNull Maybe<T> |
fromPublisher(@NonNull Publisher<T> source)
Wraps a
Publisher into a Maybe and emits the very first item
or completes if the source is empty. |
static <T> @NonNull Maybe<T> |
fromRunnable(@NonNull Runnable run)
Returns a
Maybe instance that runs the given Runnable for each MaybeObserver and
emits either its unchecked exception or simply completes. |
static <T> @NonNull Maybe<T> |
fromSingle(@NonNull SingleSource<T> single)
Wraps a
SingleSource into a Maybe. |
static <T> @NonNull Maybe<T> |
fromSupplier(@NonNull Supplier<? extends T> supplier)
Returns a
Maybe that invokes the given Supplier for each individual MaybeObserver that
subscribes and emits the resulting non-null item via onSuccess while
considering a null result from the Supplier as indication for valueless completion
via onComplete. |
@NonNull Maybe<T> |
hide()
Hides the identity of this
Maybe and its Disposable. |
@NonNull Completable |
ignoreElement()
Returns a
Completable that ignores the item emitted by the current Maybe and only calls onComplete or onError. |
@NonNull Single<Boolean> |
isEmpty()
|
static <T> @NonNull Maybe<T> |
just(T item)
Returns a
Maybe that emits a specified item. |
<R> @NonNull Maybe<R> |
lift(@NonNull MaybeOperator<? extends R,? super T> lift)
This method requires advanced knowledge about building operators, please consider
other standard composition methods first;
Returns a
Maybe which, when subscribed to, invokes the apply(MaybeObserver) method
of the provided MaybeOperator for each individual downstream Maybe and allows the
insertion of a custom operator by accessing the downstream's MaybeObserver during this subscription phase
and providing a new MaybeObserver, containing the custom operator's intended business logic, that will be
used in the subscription process going further upstream. |
<R> @NonNull Maybe<R> |
map(@NonNull Function<? super T,? extends R> mapper)
Returns a
Maybe that applies a specified function to the item emitted by the current Maybe and
emits the result of this function application. |
<R> @NonNull Maybe<R> |
mapOptional(@NonNull Function<? super T,Optional<? extends R>> mapper)
Maps the upstream success value into an
Optional and emits the contained item if not empty. |
@NonNull Single<Notification<T>> |
materialize()
Maps the signal types of this
Maybe into a Notification of the same kind
and emits it as a Single's onSuccess value to downstream. |
static <T> @NonNull Flowable<T> |
merge(@NonNull Iterable<? extends MaybeSource<? extends T>> sources)
Merges an
Iterable sequence of MaybeSource instances into a single Flowable sequence,
running all MaybeSources at once. |
static <T> @NonNull Maybe<T> |
merge(@NonNull MaybeSource<? extends MaybeSource<? extends T>> source)
Flattens a
MaybeSource that emits a MaybeSource into a single MaybeSource that emits the item
emitted by the nested MaybeSource, without any transformation. |
static <T> @NonNull Flowable<T> |
merge(@NonNull MaybeSource<? extends T> source1,
@NonNull MaybeSource<? extends T> source2)
Flattens two
MaybeSources into a single Flowable, without any transformation. |
static <T> @NonNull Flowable<T> |
merge(@NonNull MaybeSource<? extends T> source1,
@NonNull MaybeSource<? extends T> source2,
@NonNull MaybeSource<? extends T> source3)
Flattens three
MaybeSources into a single Flowable, without any transformation. |
static <T> @NonNull Flowable<T> |
merge(@NonNull MaybeSource<? extends T> source1,
@NonNull MaybeSource<? extends T> source2,
@NonNull MaybeSource<? extends T> source3,
@NonNull MaybeSource<? extends T> source4)
Flattens four
MaybeSources into a single Flowable, without any transformation. |
static <T> @NonNull Flowable<T> |
merge(@NonNull Publisher<? extends MaybeSource<? extends T>> sources)
Merges a
Publisher sequence of MaybeSource instances into a single Flowable sequence,
running all MaybeSources at once. |
static <T> @NonNull Flowable<T> |
merge(@NonNull Publisher<? extends MaybeSource<? extends T>> sources,
int maxConcurrency)
Merges a
Publisher sequence of MaybeSource instances into a single Flowable sequence,
running at most maxConcurrency MaybeSources at once. |
static <T> @NonNull Flowable<T> |
mergeArray(MaybeSource<? extends T>... sources)
Merges an array of
MaybeSource instances into a single Flowable sequence,
running all MaybeSources at once. |
static <T> @NonNull Flowable<T> |
mergeArrayDelayError(MaybeSource<? extends T>... sources)
Flattens an array of
MaybeSources into one Flowable, in a way that allows a subscriber to receive all
successfully emitted items from each of the source MaybeSources without being interrupted by an error
notification from one of them. |
static <T> @NonNull Flowable<T> |
mergeDelayError(@NonNull Iterable<? extends MaybeSource<? extends T>> sources)
Flattens an
Iterable sequence of MaybeSources into one Flowable, in a way that allows a subscriber to receive all
successfully emitted items from each of the source MaybeSources without being interrupted by an error
notification from one of them. |
static <T> @NonNull Flowable<T> |
mergeDelayError(@NonNull MaybeSource<? extends T> source1,
@NonNull MaybeSource<? extends T> source2)
Flattens two
MaybeSources into one Flowable, in a way that allows a subscriber to receive all
successfully emitted items from each of the source MaybeSources without being interrupted by an error
notification from one of them. |
static <T> @NonNull Flowable<T> |
mergeDelayError(@NonNull MaybeSource<? extends T> source1,
@NonNull MaybeSource<? extends T> source2,
@NonNull MaybeSource<? extends T> source3)
Flattens three
MaybeSource into one Flowable, in a way that allows a subscriber to receive all
successfully emitted items from all of the source MaybeSources without being interrupted by an error
notification from one of them. |
static <T> @NonNull Flowable<T> |
mergeDelayError(@NonNull MaybeSource<? extends T> source1,
@NonNull MaybeSource<? extends T> source2,
@NonNull MaybeSource<? extends T> source3,
@NonNull MaybeSource<? extends T> source4)
Flattens four
MaybeSources into one Flowable, in a way that allows a subscriber to receive all
successfully emitted items from all of the source MaybeSources without being interrupted by an error
notification from one of them. |
static <T> @NonNull Flowable<T> |
mergeDelayError(@NonNull Publisher<? extends MaybeSource<? extends T>> sources)
Flattens a
Publisher that emits MaybeSources into one Flowable, in a way that allows a subscriber to
receive all successfully emitted items from all of the source MaybeSources without being interrupted by
an error notification from one of them or even the main Publisher. |
static <T> @NonNull Flowable<T> |
mergeDelayError(@NonNull Publisher<? extends MaybeSource<? extends T>> sources,
int maxConcurrency)
Flattens a
Publisher that emits MaybeSources into one Flowable, in a way that allows a subscriber to
receive all successfully emitted items from all of the source MaybeSources without being interrupted by
an error notification from one of them or even the main Publisher as well as limiting the total number of active MaybeSources. |
@NonNull Flowable<T> |
mergeWith(@NonNull MaybeSource<? extends T> other)
|
static <T> @NonNull Maybe<T> |
never()
Returns a
Maybe that never sends any items or notifications to a MaybeObserver. |
@NonNull Maybe<T> |
observeOn(@NonNull Scheduler scheduler)
Wraps a
Maybe to emit its item (or notify of its error) on a specified Scheduler,
asynchronously. |
<U> @NonNull Maybe<U> |
ofType(@NonNull Class<U> clazz)
Filters the items emitted by the current
Maybe, only emitting its success value if that
is an instance of the supplied Class. |
@NonNull Maybe<T> |
onErrorComplete()
Returns a
Maybe instance that if this Maybe emits an error, it will emit an onComplete
and swallow the throwable. |
@NonNull Maybe<T> |
onErrorComplete(@NonNull Predicate<? super Throwable> predicate)
Returns a
Maybe instance that if this Maybe emits an error and the predicate returns
true, it will emit an onComplete and swallow the throwable. |
@NonNull Maybe<T> |
onErrorResumeNext(@NonNull Function<? super Throwable,? extends MaybeSource<? extends T>> fallbackSupplier)
Resumes the flow with a
MaybeSource returned for the failure Throwable of the current Maybe by a
function instead of signaling the error via onError. |
@NonNull Maybe<T> |
onErrorResumeWith(@NonNull MaybeSource<? extends T> fallback)
Resumes the flow with the given
MaybeSource when the current Maybe fails instead of
signaling the error via onError. |
@NonNull Maybe<T> |
onErrorReturn(@NonNull Function<? super Throwable,? extends T> itemSupplier)
Ends the flow with a success item returned by a function for the
Throwable error signaled by the current
Maybe instead of signaling the error via onError. |
@NonNull Maybe<T> |
onErrorReturnItem(T item)
Ends the flow with the given success item when the current
Maybe fails instead of signaling the error via onError. |
@NonNull Maybe<T> |
onTerminateDetach()
Nulls out references to the upstream producer and downstream
MaybeObserver if
the sequence is terminated or downstream calls dispose(). |
@NonNull Flowable<T> |
repeat()
Returns a
Flowable that repeats the sequence of items emitted by the current Maybe indefinitely. |
@NonNull Flowable<T> |
repeat(long times)
Returns a
Flowable that repeats the sequence of items emitted by the current Maybe at most
count times. |
@NonNull Flowable<T> |
repeatUntil(@NonNull BooleanSupplier stop)
Returns a
Flowable that repeats the sequence of items emitted by the current Maybe until
the provided stop function returns true. |
@NonNull Flowable<T> |
repeatWhen(@NonNull Function<? super Flowable<Object>,? extends Publisher<?>> handler)
Returns a
Flowable that emits the same values as the current Maybe with the exception of an
onComplete. |
@NonNull Maybe<T> |
retry()
Returns a
Maybe that mirrors the current Maybe, resubscribing to it if it calls onError
(infinite retry count). |
@NonNull Maybe<T> |
retry(@NonNull BiPredicate<? super Integer,? super Throwable> predicate)
Returns a
Maybe that mirrors the current Maybe, resubscribing to it if it calls onError
and the predicate returns true for that specific exception and retry count. |
@NonNull Maybe<T> |
retry(long times)
Returns a
Maybe that mirrors the current Maybe, resubscribing to it if it calls onError
up to a specified number of retries. |
@NonNull Maybe<T> |
retry(long times,
@NonNull Predicate<? super Throwable> predicate)
Retries at most
times or until the predicate returns false, whichever happens first. |
@NonNull Maybe<T> |
retry(@NonNull Predicate<? super Throwable> predicate)
Retries the current
Maybe if it fails and the predicate returns true. |
@NonNull Maybe<T> |
retryUntil(@NonNull BooleanSupplier stop)
Retries until the given stop function returns
true. |
@NonNull Maybe<T> |
retryWhen(@NonNull Function<? super Flowable<Throwable>,? extends Publisher<?>> handler)
Returns a
Maybe that emits the same values as the current Maybe with the exception of an
onError. |
void |
safeSubscribe(@NonNull MaybeObserver<? super T> observer)
Wraps the given
MaybeObserver, catches any RuntimeExceptions thrown by its
MaybeObserver.onSubscribe(Disposable), MaybeObserver.onSuccess(Object),
MaybeObserver.onError(Throwable) or MaybeObserver.onComplete() methods
and routes those to the global error handler via RxJavaPlugins.onError(Throwable). |
static <T> @NonNull Single<Boolean> |
sequenceEqual(@NonNull MaybeSource<? extends T> source1,
@NonNull MaybeSource<? extends T> source2)
Returns a
Single that emits a Boolean value that indicates whether two MaybeSource sequences are the
same by comparing the items emitted by each MaybeSource pairwise. |
static <T> @NonNull Single<Boolean> |
sequenceEqual(@NonNull MaybeSource<? extends T> source1,
@NonNull MaybeSource<? extends T> source2,
@NonNull BiPredicate<? super T,? super T> isEqual)
Returns a
Single that emits a Boolean value that indicates whether two MaybeSources are the
same by comparing the items emitted by each MaybeSource pairwise based on the results of a specified
equality function. |
@NonNull Flowable<T> |
startWith(@NonNull CompletableSource other)
Returns a
Flowable which first runs the other CompletableSource
then the current Maybe if the other completed normally. |
@NonNull Flowable<T> |
startWith(@NonNull MaybeSource<T> other)
Returns a
Flowable which first runs the other MaybeSource
then the current Maybe if the other succeeded or completed normally. |
@NonNull Observable<T> |
startWith(@NonNull ObservableSource<T> other)
Returns an
Observable which first delivers the events
of the other ObservableSource then runs the current Maybe. |
@NonNull Flowable<T> |
startWith(@NonNull Publisher<T> other)
|
@NonNull Flowable<T> |
startWith(@NonNull SingleSource<T> other)
Returns a
Flowable which first runs the other SingleSource
then the current Maybe if the other succeeded normally. |
@NonNull Disposable |
subscribe()
Subscribes to a
Maybe and ignores onSuccess and onComplete emissions. |
@NonNull Disposable |
subscribe(@NonNull Consumer<? super T> onSuccess)
Subscribes to a
Maybe and provides a callback to handle the items it emits. |
@NonNull Disposable |
subscribe(@NonNull Consumer<? super T> onSuccess,
@NonNull Consumer<? super Throwable> onError)
Subscribes to a
Maybe and provides callbacks to handle the items it emits and any error
notification it issues. |
@NonNull Disposable |
subscribe(@NonNull Consumer<? super T> onSuccess,
@NonNull Consumer<? super Throwable> onError,
@NonNull Action onComplete)
Subscribes to a
Maybe and provides callbacks to handle the items it emits and any error or
completion notification it issues. |
@NonNull Disposable |
subscribe(@NonNull Consumer<? super T> onSuccess,
@NonNull Consumer<? super Throwable> onError,
@NonNull Action onComplete,
@NonNull DisposableContainer container)
Wraps the given onXXX callbacks into a
Disposable MaybeObserver,
adds it to the given DisposableContainer and ensures, that if the upstream
terminates or this particular Disposable is disposed, the MaybeObserver is removed
from the given composite. |
void |
subscribe(@NonNull MaybeObserver<? super T> observer)
Subscribes the given
MaybeObserver to this MaybeSource instance. |
protected abstract void |
subscribeActual(@NonNull MaybeObserver<? super T> observer)
Implement this method in subclasses to handle the incoming
MaybeObservers. |
@NonNull Maybe<T> |
subscribeOn(@NonNull Scheduler scheduler)
Asynchronously subscribes subscribers to this
Maybe on the specified Scheduler. |
<E extends MaybeObserver<? super T>> |
subscribeWith(E observer)
Subscribes a given
MaybeObserver (subclass) to this Maybe and returns the given
MaybeObserver as is. |
@NonNull Maybe<T> |
switchIfEmpty(@NonNull MaybeSource<? extends T> other)
Returns a
Maybe that emits the items emitted by the current Maybe or the items of an alternate
MaybeSource if the current Maybe is empty. |
@NonNull Single<T> |
switchIfEmpty(@NonNull SingleSource<? extends T> other)
Returns a
Single that emits the items emitted by the current Maybe or the item of an alternate
SingleSource if the current Maybe is empty. |
static <T> @NonNull Flowable<T> |
switchOnNext(@NonNull Publisher<? extends MaybeSource<? extends T>> sources)
Switches between
MaybeSources emitted by the source Publisher whenever
a new MaybeSource is emitted, disposing the previously running MaybeSource,
exposing the success items as a Flowable sequence. |
static <T> @NonNull Flowable<T> |
switchOnNextDelayError(@NonNull Publisher<? extends MaybeSource<? extends T>> sources)
Switches between
MaybeSources emitted by the source Publisher whenever
a new MaybeSource is emitted, disposing the previously running MaybeSource,
exposing the success items as a Flowable sequence and delaying all errors from
all of them until all terminate. |
<U> @NonNull Maybe<T> |
takeUntil(@NonNull MaybeSource<U> other)
Returns a
Maybe that emits the items emitted by the current Maybe until a second MaybeSource
emits an item. |
<U> @NonNull Maybe<T> |
takeUntil(@NonNull Publisher<U> other)
Returns a
Maybe that emits the item emitted by the current Maybe until a second Publisher
emits an item. |
@NonNull TestObserver<T> |
test()
Creates a
TestObserver and subscribes
it to this Maybe. |
@NonNull TestObserver<T> |
test(boolean dispose)
Creates a
TestObserver optionally in cancelled state, then subscribes it to this Maybe. |
@NonNull Maybe<Timed<T>> |
timeInterval()
Measures the time (in milliseconds) between the subscription and success item emission
of the current
Maybe and signals it as a tuple (Timed)
success value. |
@NonNull Maybe<Timed<T>> |
timeInterval(@NonNull Scheduler scheduler)
Measures the time (in milliseconds) between the subscription and success item emission
of the current
Maybe and signals it as a tuple (Timed)
success value. |
@NonNull Maybe<Timed<T>> |
timeInterval(@NonNull TimeUnit unit)
Measures the time between the subscription and success item emission
of the current
Maybe and signals it as a tuple (Timed)
success value. |
@NonNull Maybe<Timed<T>> |
timeInterval(@NonNull TimeUnit unit,
@NonNull Scheduler scheduler)
Measures the time between the subscription and success item emission
of the current
Maybe and signals it as a tuple (Timed)
success value. |
@NonNull Maybe<T> |
timeout(long timeout,
@NonNull TimeUnit unit)
Returns a
Maybe that mirrors the current Maybe but applies a timeout policy for each emitted
item. |
@NonNull Maybe<T> |
timeout(long timeout,
@NonNull TimeUnit unit,
@NonNull MaybeSource<? extends T> fallback)
Returns a
Maybe that mirrors the current Maybe but applies a timeout policy for each emitted
item. |
@NonNull Maybe<T> |
timeout(long timeout,
@NonNull TimeUnit unit,
@NonNull Scheduler scheduler)
Returns a
Maybe that mirrors the current Maybe but applies a timeout policy for each emitted
item, where this policy is governed on a specified Scheduler. |
@NonNull Maybe<T> |
timeout(long timeout,
@NonNull TimeUnit unit,
@NonNull Scheduler scheduler,
@NonNull MaybeSource<? extends T> fallback)
Returns a
Maybe that mirrors the current Maybe but applies a timeout policy for each emitted
item using a specified Scheduler. |
<U> @NonNull Maybe<T> |
timeout(@NonNull MaybeSource<U> timeoutIndicator)
If the current
Maybe didn't signal an event before the timeoutIndicator MaybeSource signals, a
TimeoutException is signaled instead. |
<U> @NonNull Maybe<T> |
timeout(@NonNull MaybeSource<U> timeoutIndicator,
@NonNull MaybeSource<? extends T> fallback)
If the current
Maybe didn't signal an event before the timeoutIndicator MaybeSource signals,
the current Maybe is disposed and the fallback MaybeSource subscribed to
as a continuation. |
<U> @NonNull Maybe<T> |
timeout(@NonNull Publisher<U> timeoutIndicator)
If the current
Maybe source didn't signal an event before the timeoutIndicator Publisher signals, a
TimeoutException is signaled instead. |
<U> @NonNull Maybe<T> |
timeout(@NonNull Publisher<U> timeoutIndicator,
@NonNull MaybeSource<? extends T> fallback)
If the current
Maybe didn't signal an event before the timeoutIndicator Publisher signals,
the current Maybe is disposed and the fallback MaybeSource subscribed to
as a continuation. |
static @NonNull Maybe<Long> |
timer(long delay,
@NonNull TimeUnit unit)
Returns a
Maybe that emits 0L after a specified delay. |
static @NonNull Maybe<Long> |
timer(long delay,
@NonNull TimeUnit unit,
@NonNull Scheduler scheduler)
|
@NonNull Maybe<Timed<T>> |
timestamp()
|
@NonNull Maybe<Timed<T>> |
timestamp(@NonNull Scheduler scheduler)
|
@NonNull Maybe<Timed<T>> |
timestamp(@NonNull TimeUnit unit)
|
@NonNull Maybe<Timed<T>> |
timestamp(@NonNull TimeUnit unit,
@NonNull Scheduler scheduler)
|
<R> R |
to(@NonNull MaybeConverter<T,? extends R> converter)
Calls the specified converter function during assembly time and returns its resulting value.
|
@NonNull CompletionStage<T> |
toCompletionStage()
Signals the upstream success item (or a
NoSuchElementException if the upstream is empty) via
a CompletionStage. |
@NonNull CompletionStage<T> |
toCompletionStage(T defaultItem)
Signals the upstream success item (or the default item if the upstream is empty) via
a
CompletionStage. |
@NonNull Flowable<T> |
toFlowable()
Converts this
Maybe into a backpressure-aware Flowable instance composing cancellation
through. |
@NonNull Future<T> |
toFuture()
Returns a
Future representing the single value emitted by the current Maybe
or null if the current Maybe is empty. |
@NonNull Observable<T> |
toObservable()
Converts this
Maybe into an Observable instance composing disposal
through. |
@NonNull Single<T> |
toSingle()
Converts this
Maybe into a Single instance composing disposal
through and turning an empty Maybe into a signal of NoSuchElementException. |
static <T> @NonNull Maybe<T> |
unsafeCreate(@NonNull MaybeSource<T> onSubscribe)
Advanced use only: creates a
Maybe instance without
any safeguards by using a callback that is called with a MaybeObserver. |
@NonNull Maybe<T> |
unsubscribeOn(@NonNull Scheduler scheduler)
Returns a
Maybe which makes sure when a MaybeObserver disposes the Disposable,
that call is propagated up on the specified Scheduler. |
static <T,D> @NonNull Maybe<T> |
using(@NonNull Supplier<? extends D> resourceSupplier,
@NonNull Function<? super D,? extends MaybeSource<? extends T>> sourceSupplier,
@NonNull Consumer<? super D> resourceCleanup)
Constructs a
Maybe that creates a dependent resource object which is disposed of when the
generated MaybeSource terminates or the downstream calls dispose(). |
static <T,D> @NonNull Maybe<T> |
using(@NonNull Supplier<? extends D> resourceSupplier,
@NonNull Function<? super D,? extends MaybeSource<? extends T>> sourceSupplier,
@NonNull Consumer<? super D> resourceCleanup,
boolean eager)
Constructs a
Maybe that creates a dependent resource object which is disposed first ({code eager == true})
when the generated MaybeSource terminates or the downstream disposes; or after ({code eager == false}). |
static <T> @NonNull Maybe<T> |
wrap(@NonNull MaybeSource<T> source)
|
static <T,R> @NonNull Maybe<R> |
zip(@NonNull Iterable<? extends MaybeSource<? extends T>> sources,
@NonNull Function<? super Object[],? extends R> zipper)
Returns a
Maybe that emits the results of a specified combiner function applied to combinations of
items emitted, in sequence, by an Iterable of other MaybeSources. |
static <T1,T2,R> @NonNull Maybe<R> |
zip(@NonNull MaybeSource<? extends T1> source1,
@NonNull MaybeSource<? extends T2> source2,
@NonNull BiFunction<? super T1,? super T2,? extends R> zipper)
Returns a
Maybe that emits the results of a specified combiner function applied to combinations of
two items emitted, in sequence, by two other MaybeSources. |
static <T1,T2,T3,R> |
zip(@NonNull MaybeSource<? extends T1> source1,
@NonNull MaybeSource<? extends T2> source2,
@NonNull MaybeSource<? extends T3> source3,
@NonNull Function3<? super T1,? super T2,? super T3,? extends R> zipper)
Returns a
Maybe that emits the results of a specified combiner function applied to combinations of
three items emitted, in sequence, by three other MaybeSources. |
static <T1,T2,T3,T4,R> |
zip(@NonNull MaybeSource<? extends T1> source1,
@NonNull MaybeSource<? extends T2> source2,
@NonNull MaybeSource<? extends T3> source3,
@NonNull MaybeSource<? extends T4> source4,
@NonNull Function4<? super T1,? super T2,? super T3,? super T4,? extends R> zipper)
Returns a
Maybe that emits the results of a specified combiner function applied to combinations of
four items emitted, in sequence, by four other MaybeSources. |
static <T1,T2,T3,T4,T5,R> |
zip(@NonNull MaybeSource<? extends T1> source1,
@NonNull MaybeSource<? extends T2> source2,
@NonNull MaybeSource<? extends T3> source3,
@NonNull MaybeSource<? extends T4> source4,
@NonNull MaybeSource<? extends T5> source5,
@NonNull Function5<? super T1,? super T2,? super T3,? super T4,? super T5,? extends R> zipper)
Returns a
Maybe that emits the results of a specified combiner function applied to combinations of
five items emitted, in sequence, by five other MaybeSources. |
static <T1,T2,T3,T4,T5,T6,R> |
zip(@NonNull MaybeSource<? extends T1> source1,
@NonNull MaybeSource<? extends T2> source2,
@NonNull MaybeSource<? extends T3> source3,
@NonNull MaybeSource<? extends T4> source4,
@NonNull MaybeSource<? extends T5> source5,
@NonNull MaybeSource<? extends T6> source6,
@NonNull Function6<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? extends R> zipper)
Returns a
Maybe that emits the results of a specified combiner function applied to combinations of
six items emitted, in sequence, by six other MaybeSources. |
static <T1,T2,T3,T4,T5,T6,T7,R> |
zip(@NonNull MaybeSource<? extends T1> source1,
@NonNull MaybeSource<? extends T2> source2,
@NonNull MaybeSource<? extends T3> source3,
@NonNull MaybeSource<? extends T4> source4,
@NonNull MaybeSource<? extends T5> source5,
@NonNull MaybeSource<? extends T6> source6,
@NonNull MaybeSource<? extends T7> source7,
@NonNull Function7<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? extends R> zipper)
Returns a
Maybe that emits the results of a specified combiner function applied to combinations of
seven items emitted, in sequence, by seven other MaybeSources. |
static <T1,T2,T3,T4,T5,T6,T7,T8,R> |
zip(@NonNull MaybeSource<? extends T1> source1,
@NonNull MaybeSource<? extends T2> source2,
@NonNull MaybeSource<? extends T3> source3,
@NonNull MaybeSource<? extends T4> source4,
@NonNull MaybeSource<? extends T5> source5,
@NonNull MaybeSource<? extends T6> source6,
@NonNull MaybeSource<? extends T7> source7,
@NonNull MaybeSource<? extends T8> source8,
@NonNull Function8<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? super T8,? extends R> zipper)
Returns a
Maybe that emits the results of a specified combiner function applied to combinations of
eight items emitted, in sequence, by eight other MaybeSources. |
static <T1,T2,T3,T4,T5,T6,T7,T8,T9,R> |
zip(@NonNull MaybeSource<? extends T1> source1,
@NonNull MaybeSource<? extends T2> source2,
@NonNull MaybeSource<? extends T3> source3,
@NonNull MaybeSource<? extends T4> source4,
@NonNull MaybeSource<? extends T5> source5,
@NonNull MaybeSource<? extends T6> source6,
@NonNull MaybeSource<? extends T7> source7,
@NonNull MaybeSource<? extends T8> source8,
@NonNull MaybeSource<? extends T9> source9,
@NonNull Function9<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? super T8,? super T9,? extends R> zipper)
Returns a
Maybe that emits the results of a specified combiner function applied to combinations of
nine items emitted, in sequence, by nine other MaybeSources. |
static <T,R> @NonNull Maybe<R> |
zipArray(@NonNull Function<? super Object[],? extends R> zipper,
MaybeSource<? extends T>... sources)
Returns a
Maybe that emits the results of a specified combiner function applied to combinations of
items emitted, in sequence, by an array of other MaybeSources. |
<U,R> @NonNull Maybe<R> |
zipWith(@NonNull MaybeSource<? extends U> other,
@NonNull BiFunction<? super T,? super U,? extends R> zipper)
Waits until this and the other
MaybeSource signal a success value then applies the given BiFunction
to those values and emits the BiFunction's resulting value to downstream. |
@CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Maybe<T> amb(@NonNull Iterable<? extends MaybeSource<? extends T>> sources)
MaybeSources provided by an Iterable sequence and
signals the events of the first one that signals (disposing the rest).
amb does not operate by default on a particular Scheduler.T - the value typesources - the Iterable sequence of sources. A subscription to each source will
occur in the same order as in the Iterable.Maybe instanceNullPointerException - if sources is null@CheckReturnValue @SchedulerSupport(value="none") @NonNull @SafeVarargs public static <T> @NonNull Maybe<T> ambArray(@NonNull MaybeSource<? extends T>... sources)
MaybeSources and signals the events of the first one that signals (disposing
the rest).
ambArray does not operate by default on a particular Scheduler.T - the value typesources - the array of sources. A subscription to each source will
occur in the same order as in the array.Maybe instanceNullPointerException - if sources is null@BackpressureSupport(value=FULL) @CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Flowable<T> concat(@NonNull Iterable<? extends MaybeSource<? extends T>> sources)
MaybeSource sources provided by
an Iterable sequence as a Flowable sequence.
Flowable honors the backpressure of the downstream consumer.concat does not operate by default on a particular Scheduler.T - the value typesources - the Iterable sequence of MaybeSource instancesFlowable instanceNullPointerException - if sources is null@BackpressureSupport(value=FULL) @CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Flowable<T> concat(@NonNull MaybeSource<? extends T> source1, @NonNull MaybeSource<? extends T> source2)
Flowable that emits the items emitted by two MaybeSources, one after the other.
Flowable honors the backpressure of the downstream consumer.concat does not operate by default on a particular Scheduler.T - the common value typesource1 - a MaybeSource to be concatenatedsource2 - a MaybeSource to be concatenatedFlowable instanceNullPointerException - if source1 or source2 is null@BackpressureSupport(value=FULL) @CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Flowable<T> concat(@NonNull MaybeSource<? extends T> source1, @NonNull MaybeSource<? extends T> source2, @NonNull MaybeSource<? extends T> source3)
Flowable that emits the items emitted by three MaybeSources, one after the other.
Flowable honors the backpressure of the downstream consumer.concat does not operate by default on a particular Scheduler.T - the common value typesource1 - a MaybeSource to be concatenatedsource2 - a MaybeSource to be concatenatedsource3 - a MaybeSource to be concatenatedFlowable instanceNullPointerException - if source1, source2 or source3 is null@BackpressureSupport(value=FULL) @CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Flowable<T> concat(@NonNull MaybeSource<? extends T> source1, @NonNull MaybeSource<? extends T> source2, @NonNull MaybeSource<? extends T> source3, @NonNull MaybeSource<? extends T> source4)
Flowable that emits the items emitted by four MaybeSources, one after the other.
Flowable honors the backpressure of the downstream consumer.concat does not operate by default on a particular Scheduler.T - the common value typesource1 - a MaybeSource to be concatenatedsource2 - a MaybeSource to be concatenatedsource3 - a MaybeSource to be concatenatedsource4 - a MaybeSource to be concatenatedFlowable instanceNullPointerException - if source1, source2, source3 or source4 is null@BackpressureSupport(value=FULL) @CheckReturnValue @SchedulerSupport(value="none") @NonNull public static <T> @NonNull Flowable<T> concat(@NonNull Publisher<? extends MaybeSource<? extends T>> sources)
MaybeSource sources provided by
a Publisher sequence as a Flowable sequence.
Flowable honors the backpressure of the downstream consumer and
expects the Publisher to honor backpressure as well. If the sources Publisher
violates this, a MissingBackpressureException is signaled.concat does not operate by default on a particular Scheduler.T - the value typesources - the Publisher of MaybeSource instancesFlowable instanceNullPointerException - if sources is null@BackpressureSupport(value=FULL) @CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Flowable<T> concat(@NonNull Publisher<? extends MaybeSource<? extends T>> sources, int prefetch)
MaybeSource sources provided by
a Publisher sequence as a Flowable sequence.
Flowable honors the backpressure of the downstream consumer and
expects the Publisher to honor backpressure as well. If the sources Publisher
violates this, a MissingBackpressureException is signaled.concat does not operate by default on a particular Scheduler.T - the value typesources - the Publisher of MaybeSource instancesprefetch - the number of MaybeSources to prefetch from the PublisherFlowable instanceNullPointerException - if sources is nullIllegalArgumentException - if prefetch is non-positive@BackpressureSupport(value=FULL) @CheckReturnValue @NonNull @SchedulerSupport(value="none") @SafeVarargs public static <T> @NonNull Flowable<T> concatArray(@NonNull MaybeSource<? extends T>... sources)
MaybeSource sources in the array
as a Flowable sequence.
Flowable honors the backpressure of the downstream consumer.concatArray does not operate by default on a particular Scheduler.T - the value typesources - the array of MaybeSource instancesFlowable instanceNullPointerException - if sources is null@BackpressureSupport(value=FULL) @CheckReturnValue @SchedulerSupport(value="none") @SafeVarargs @NonNull public static <T> @NonNull Flowable<T> concatArrayDelayError(@NonNull MaybeSource<? extends T>... sources)
MaybeSource sources and delays errors from any of them
till all terminate as a Flowable sequence.
concatArrayDelayError does not operate by default on a particular Scheduler.T - the common base value typesources - the array of sourcesFlowable instanceNullPointerException - if sources is null@BackpressureSupport(value=FULL) @CheckReturnValue @SchedulerSupport(value="none") @NonNull @SafeVarargs public static <T> @NonNull Flowable<T> concatArrayEager(@NonNull MaybeSource<? extends T>... sources)
MaybeSource eagerly into a Flowable sequence.
Eager concatenation means that once an observer subscribes, this operator subscribes to all of the
source MaybeSources. The operator buffers the value emitted by these MaybeSources and then drains them
in order, each one after the previous one completes.
Scheduler.T - the value typesources - a sequence of MaybeSources that need to be eagerly concatenatedFlowable instance with the specified concatenation behaviorNullPointerException - if sources is null@BackpressureSupport(value=FULL) @CheckReturnValue @SchedulerSupport(value="none") @NonNull @SafeVarargs public static <T> @NonNull Flowable<T> concatArrayEagerDelayError(@NonNull MaybeSource<? extends T>... sources)
MaybeSource eagerly into a Flowable sequence.
Eager concatenation means that once an observer subscribes, this operator subscribes to all of the
source MaybeSources. The operator buffers the value emitted by these MaybeSources and then drains them
in order, each one after the previous one completes.
Scheduler.T - the value typesources - a sequence of MaybeSources that need to be eagerly concatenatedFlowable instance with the specified concatenation behaviorNullPointerException - if sources is null@BackpressureSupport(value=FULL) @CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Flowable<T> concatDelayError(@NonNull Iterable<? extends MaybeSource<? extends T>> sources)
Iterable sequence of MaybeSources into a single sequence by subscribing to each MaybeSource,
one after the other, one at a time and delays any errors till the all inner MaybeSources terminate
as a Flowable sequence.
concatDelayError does not operate by default on a particular Scheduler.T - the common element base typesources - the Iterable sequence of MaybeSourcesFlowable with the concatenating behaviorNullPointerException - if sources is null@BackpressureSupport(value=FULL) @CheckReturnValue @SchedulerSupport(value="none") @NonNull public static <T> @NonNull Flowable<T> concatDelayError(@NonNull Publisher<? extends MaybeSource<? extends T>> sources)
Publisher sequence of MaybeSources into a single sequence by subscribing to each inner MaybeSource,
one after the other, one at a time and delays any errors till the all inner and the outer Publisher terminate
as a Flowable sequence.
concatDelayError fully supports backpressure.concatDelayError does not operate by default on a particular Scheduler.T - the common element base typesources - the Publisher sequence of MaybeSourcesFlowable with the concatenating behaviorNullPointerException - if sources is null@BackpressureSupport(value=FULL) @CheckReturnValue @SchedulerSupport(value="none") @NonNull public static <T> @NonNull Flowable<T> concatDelayError(@NonNull Publisher<? extends MaybeSource<? extends T>> sources, int prefetch)
Publisher sequence of MaybeSources into a single sequence by subscribing to each inner MaybeSource,
one after the other, one at a time and delays any errors till the all inner and the outer Publisher terminate
as a Flowable sequence.
concatDelayError fully supports backpressure.concatDelayError does not operate by default on a particular Scheduler.T - the common element base typesources - the Publisher sequence of MaybeSourcesprefetch - The number of upstream items to prefetch so that fresh items are
ready to be mapped when a previous MaybeSource terminates.
The operator replenishes after half of the prefetch amount has been consumed
and turned into MaybeSources.Flowable with the concatenating behaviorNullPointerException - if sources is nullIllegalArgumentException - if prefetch is non-positive@BackpressureSupport(value=FULL) @CheckReturnValue @SchedulerSupport(value="none") @NonNull public static <T> @NonNull Flowable<T> concatEager(@NonNull Iterable<? extends MaybeSource<? extends T>> sources)
MaybeSources eagerly into a Flowable sequence.
Eager concatenation means that once an observer subscribes, this operator subscribes to all of the
source MaybeSources. The operator buffers the values emitted by these MaybeSources and then drains them
in order, each one after the previous one completes.
Scheduler.T - the value typesources - a sequence of MaybeSource that need to be eagerly concatenatedFlowable instance with the specified concatenation behaviorNullPointerException - if sources is null@BackpressureSupport(value=FULL) @CheckReturnValue @SchedulerSupport(value="none") @NonNull public static <T> @NonNull Flowable<T> concatEager(@NonNull Iterable<? extends MaybeSource<? extends T>> sources, int maxConcurrency)
MaybeSources eagerly into a Flowable sequence and
runs a limited number of the inner sequences at once.
Eager concatenation means that once an observer subscribes, this operator subscribes to all of the
source MaybeSources. The operator buffers the values emitted by these MaybeSources and then drains them
in order, each one after the previous one completes.
Scheduler.T - the value typesources - a sequence of MaybeSource that need to be eagerly concatenatedmaxConcurrency - the maximum number of concurrently running inner MaybeSources; Integer.MAX_VALUE
is interpreted as all inner MaybeSources can be active at the same timeFlowable instance with the specified concatenation behaviorNullPointerException - if sources is nullIllegalArgumentException - if maxConcurrency is non-positive@BackpressureSupport(value=FULL) @CheckReturnValue @SchedulerSupport(value="none") @NonNull public static <T> @NonNull Flowable<T> concatEager(@NonNull Publisher<? extends MaybeSource<? extends T>> sources)
Publisher sequence of MaybeSources eagerly into a Flowable sequence.
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the
emitted source MaybeSources as they are observed. The operator buffers the values emitted by these
MaybeSources and then drains them in order, each one after the previous one completes.
Publisher is
expected to support backpressure. Violating this assumption, the operator will
signal MissingBackpressureException.Scheduler.T - the value typesources - a sequence of MaybeSources that need to be eagerly concatenatedFlowable instance with the specified concatenation behaviorNullPointerException - if sources is null@BackpressureSupport(value=FULL) @CheckReturnValue @SchedulerSupport(value="none") @NonNull public static <T> @NonNull Flowable<T> concatEager(@NonNull Publisher<? extends MaybeSource<? extends T>> sources, int maxConcurrency)
Publisher sequence of MaybeSources eagerly into a Flowable sequence,
running at most the given number of inner MaybeSources at once.
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the
emitted source MaybeSources as they are observed. The operator buffers the values emitted by these
MaybeSources and then drains them in order, each one after the previous one completes.
Publisher is
expected to support backpressure. Violating this assumption, the operator will
signal MissingBackpressureException.Scheduler.T - the value typesources - a sequence of MaybeSources that need to be eagerly concatenatedmaxConcurrency - the maximum number of concurrently running inner MaybeSources; Integer.MAX_VALUE
is interpreted as all inner MaybeSources can be active at the same timeFlowable instance with the specified concatenation behaviorNullPointerException - if sources is nullIllegalArgumentException - if maxConcurrency is non-positive@BackpressureSupport(value=FULL) @CheckReturnValue @SchedulerSupport(value="none") @NonNull public static <T> @NonNull Flowable<T> concatEagerDelayError(@NonNull Iterable<? extends MaybeSource<? extends T>> sources)
MaybeSources eagerly into a Flowable sequence,
delaying errors until all inner MaybeSources terminate.
Eager concatenation means that once an observer subscribes, this operator subscribes to all of the
source MaybeSources. The operator buffers the values emitted by these MaybeSources and then drains them
in order, each one after the previous one completes.
Scheduler.T - the value typesources - a sequence of MaybeSource that need to be eagerly concatenatedFlowable instance with the specified concatenation behaviorNullPointerException - if sources is null@BackpressureSupport(value=FULL) @CheckReturnValue @SchedulerSupport(value="none") @NonNull public static <T> @NonNull Flowable<T> concatEagerDelayError(@NonNull Iterable<? extends MaybeSource<? extends T>> sources, int maxConcurrency)
MaybeSources eagerly into a Flowable sequence,
delaying errors until all inner MaybeSources terminate and
runs a limited number of inner MaybeSources at once.
Eager concatenation means that once an observer subscribes, this operator subscribes to all of the
source MaybeSources. The operator buffers the values emitted by these MaybeSources and then drains them
in order, each one after the previous one completes.
Scheduler.T - the value typesources - a sequence of MaybeSource that need to be eagerly concatenatedmaxConcurrency - the maximum number of concurrently running inner MaybeSources; Integer.MAX_VALUE
is interpreted as all inner MaybeSources can be active at the same timeFlowable instance with the specified concatenation behaviorNullPointerException - if sources is nullIllegalArgumentException - if maxConcurrency is non-positive@BackpressureSupport(value=FULL) @CheckReturnValue @SchedulerSupport(value="none") @NonNull public static <T> @NonNull Flowable<T> concatEagerDelayError(@NonNull Publisher<? extends MaybeSource<? extends T>> sources)
Publisher sequence of MaybeSources eagerly into a Flowable sequence,
delaying errors until all the inner and the outer sequence terminate.
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the
emitted source MaybeSources as they are observed. The operator buffers the values emitted by these
MaybeSources and then drains them in order, each one after the previous one completes.
Publisher is
expected to support backpressure. Violating this assumption, the operator will
signal MissingBackpressureException.Scheduler.T - the value typesources - a sequence of MaybeSources that need to be eagerly concatenatedFlowable instance with the specified concatenation behaviorNullPointerException - if sources is null@BackpressureSupport(value=FULL) @CheckReturnValue @SchedulerSupport(value="none") @NonNull public static <T> @NonNull Flowable<T> concatEagerDelayError(@NonNull Publisher<? extends MaybeSource<? extends T>> sources, int maxConcurrency)
Publisher sequence of MaybeSources eagerly into a Flowable sequence,
delaying errors until all the inner and the outer sequence terminate and
runs a limited number of the inner MaybeSources at once.
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the
emitted source MaybeSources as they are observed. The operator buffers the values emitted by these
MaybeSources and then drains them in order, each one after the previous one completes.
Publisher is
expected to support backpressure. Violating this assumption, the operator will
signal MissingBackpressureException.Scheduler.T - the value typesources - a sequence of MaybeSources that need to be eagerly concatenatedmaxConcurrency - the maximum number of concurrently running inner MaybeSources; Integer.MAX_VALUE
is interpreted as all inner MaybeSources can be active at the same timeFlowable instance with the specified concatenation behaviorNullPointerException - if sources is nullIllegalArgumentException - if maxConcurrency is non-positive@CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Maybe<T> create(@NonNull MaybeOnSubscribe<T> onSubscribe)
Maybe) that bridges the reactive world with the callback-style world.
Example:
Maybe.<Event>create(emitter -> {
Callback listener = new Callback() {
@Override
public void onEvent(Event e) {
if (e.isNothing()) {
emitter.onComplete();
} else {
emitter.onSuccess(e);
}
}
@Override
public void onFailure(Exception e) {
emitter.onError(e);
}
};
AutoCloseable c = api.someMethod(listener);
emitter.setCancellable(c::close);
});
Whenever a MaybeObserver subscribes to the returned Maybe, the provided
MaybeOnSubscribe callback is invoked with a fresh instance of a MaybeEmitter
that will interact only with that specific MaybeObserver. If this MaybeObserver
disposes the flow (making MaybeEmitter.isDisposed() return true),
other observers subscribed to the same returned Maybe are not affected.
create does not operate by default on a particular Scheduler.T - the value typeonSubscribe - the emitter that is called when a MaybeObserver subscribes to the returned MaybeMaybe instanceNullPointerException - if onSubscribe is nullMaybeOnSubscribe,
Cancellable@CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Maybe<T> defer(@NonNull Supplier<? extends MaybeSource<? extends T>> supplier)
Supplier for each individual MaybeObserver to return the actual MaybeSource source to
be subscribed to.
defer does not operate by default on a particular Scheduler.T - the value typesupplier - the Supplier that is called for each individual MaybeObserver and
returns a MaybeSource instance to subscribe toMaybe instanceNullPointerException - if supplier is null@CheckReturnValue @SchedulerSupport(value="none") @NonNull public static <T> @NonNull Maybe<T> empty()
Maybe instance that calls onComplete
immediately.
empty does not operate by default on a particular Scheduler.T - the value typeMaybe instance@CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Maybe<T> error(@NonNull Throwable throwable)
Maybe that invokes a subscriber's onError method when the
subscriber subscribes to it.
error does not operate by default on a particular Scheduler.T - the type of the item (ostensibly) emitted by the Maybethrowable - the particular Throwable to pass to onErrorMaybe instanceNullPointerException - if throwable is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Maybe<T> error(@NonNull Supplier<? extends Throwable> supplier)
Maybe that invokes a MaybeObserver's onError method when the
MaybeObserver subscribes to it.
error does not operate by default on a particular Scheduler.T - the type of the items (ostensibly) emitted by the Maybesupplier - a Supplier factory to return a Throwable for each individual MaybeObserverMaybe instanceNullPointerException - if supplier is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Maybe<T> fromAction(@NonNull Action action)
Maybe instance that runs the given Action for each MaybeObserver and
emits either its exception or simply completes.
fromAction does not operate by default on a particular Scheduler.Action throws an exception, the respective Throwable is
delivered to the downstream via MaybeObserver.onError(Throwable),
except when the downstream has disposed the resulting Maybe source.
In this latter case, the Throwable is delivered to the global error handler via
RxJavaPlugins.onError(Throwable) as an UndeliverableException.
T - the target typeaction - the Action to run for each MaybeObserverMaybe instanceNullPointerException - if action is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Maybe<T> fromCompletable(@NonNull CompletableSource completableSource)
CompletableSource into a Maybe.
fromCompletable does not operate by default on a particular Scheduler.T - the target typecompletableSource - the CompletableSource to convert fromMaybe instanceNullPointerException - if completableSource is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Maybe<T> fromSingle(@NonNull SingleSource<T> single)
SingleSource into a Maybe.
fromSingle does not operate by default on a particular Scheduler.T - the target typesingle - the SingleSource to convert fromMaybe instanceNullPointerException - if single is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Maybe<T> fromCallable(@NonNull Callable<? extends T> callable)
Maybe that invokes the given Callable for each individual MaybeObserver that
subscribes and emits the resulting non-null item via onSuccess while
considering a null result from the Callable as indication for valueless completion
via onComplete.
This operator allows you to defer the execution of the given Callable until a MaybeObserver
subscribes to the returned Maybe. In other terms, this source operator evaluates the given
Callable "lazily".
Note that the null handling of this operator differs from the similar source operators in the other
base reactive classes. Those operators signal a NullPointerException if the value returned by their
Callable is null while this fromCallable considers it to indicate the
returned Maybe is empty.
fromCallable does not operate by default on a particular Scheduler.Callable.call() will be forwarded to onError,
except if the MaybeObserver disposed the subscription in the meantime. In this latter case,
the exception is forwarded to the global error handler via
RxJavaPlugins.onError(Throwable) wrapped into a
UndeliverableException.
Fatal exceptions are rethrown and usually will end up in the executing thread's
Thread.UncaughtExceptionHandler.uncaughtException(Thread, Throwable) handler.T - the type of the item emitted by the Maybe.callable - a Callable instance whose execution should be deferred and performed for each individual
MaybeObserver that subscribes to the returned Maybe.Maybe instanceNullPointerException - if callable is nulldefer(Supplier),
fromSupplier(Supplier)@CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Maybe<T> fromFuture(@NonNull Future<? extends T> future)
Future into a Maybe, treating a null result as an indication of emptiness.
The operator calls Future.get(), which is a blocking method, on the subscription thread.
It is recommended applying subscribeOn(Scheduler) to move this blocking wait to a
background thread, and if the Scheduler supports it, interrupt the wait when the flow
is disposed.
Unlike 1.x, disposing the Maybe won't cancel the future. If necessary, one can use composition to achieve the
cancellation effect: futureMaybe.doOnDispose(() -> future.cancel(true));.
fromFuture does not operate by default on a particular Scheduler.T - the type of object that the Future returns, and also the type of item to be emitted by
the resulting Maybefuture - the source FutureMaybe instanceNullPointerException - if future is nullfromCompletionStage(CompletionStage)@CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Maybe<T> fromFuture(@NonNull Future<? extends T> future, long timeout, @NonNull TimeUnit unit)
Future into a Maybe, with a timeout on the Future.
The operator calls Future.get(long, TimeUnit), which is a blocking method, on the subscription thread.
It is recommended applying subscribeOn(Scheduler) to move this blocking wait to a
background thread, and if the Scheduler supports it, interrupt the wait when the flow
is disposed.
Unlike 1.x, disposing the Maybe won't cancel the future. If necessary, one can use composition to achieve the
cancellation effect: futureMaybe.doOnCancel(() -> future.cancel(true));.
fromFuture does not operate by default on a particular Scheduler.T - the type of object that the Future returns, and also the type of item to be emitted by
the resulting Maybefuture - the source Futuretimeout - the maximum time to wait before calling getunit - the TimeUnit of the timeout argumentMaybe instanceNullPointerException - if future or unit is nullfromCompletionStage(CompletionStage)@CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Maybe<T> fromObservable(@NonNull ObservableSource<T> source)
ObservableSource into a Maybe and emits the very first item
or completes if the source is empty.
fromObservable does not operate by default on a particular Scheduler.T - the target typesource - the ObservableSource to convert fromMaybe instanceNullPointerException - if source is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") @BackpressureSupport(value=UNBOUNDED_IN) public static <T> @NonNull Maybe<T> fromPublisher(@NonNull Publisher<T> source)
Publisher into a Maybe and emits the very first item
or completes if the source is empty.
Publisher in an unbounded manner
(requesting Long.MAX_VALUE) but cancels it after one item received.fromPublisher does not operate by default on a particular Scheduler.T - the target typesource - the Publisher to convert fromMaybe instanceNullPointerException - if source is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Maybe<T> fromRunnable(@NonNull Runnable run)
Maybe instance that runs the given Runnable for each MaybeObserver and
emits either its unchecked exception or simply completes.
If the code to be wrapped needs to throw a checked or more broader Throwable exception, that
exception has to be converted to an unchecked exception by the wrapped code itself. Alternatively,
use the fromAction(Action) method which allows the wrapped code to throw any Throwable
exception and will signal it to observers as-is.
fromRunnable does not operate by default on a particular Scheduler.Runnable throws an exception, the respective Throwable is
delivered to the downstream via MaybeObserver.onError(Throwable),
except when the downstream has disposed this Maybe source.
In this latter case, the Throwable is delivered to the global error handler via
RxJavaPlugins.onError(Throwable) as an UndeliverableException.
T - the target typerun - the Runnable to run for each MaybeObserverMaybe instanceNullPointerException - if run is nullfromAction(Action)@CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Maybe<T> fromSupplier(@NonNull Supplier<? extends T> supplier)
Maybe that invokes the given Supplier for each individual MaybeObserver that
subscribes and emits the resulting non-null item via onSuccess while
considering a null result from the Supplier as indication for valueless completion
via onComplete.
This operator allows you to defer the execution of the given Supplier until a MaybeObserver
subscribes to the returned Maybe. In other terms, this source operator evaluates the given
Supplier "lazily".
Note that the null handling of this operator differs from the similar source operators in the other
base reactive classes. Those operators signal a NullPointerException if the value returned by their
Supplier is null while this fromSupplier considers it to indicate the
returned Maybe is empty.
fromSupplier does not operate by default on a particular Scheduler.Supplier.get() will be forwarded to onError,
except if the MaybeObserver disposed the subscription in the meantime. In this latter case,
the exception is forwarded to the global error handler via
RxJavaPlugins.onError(Throwable) wrapped into a
UndeliverableException.
Fatal exceptions are rethrown and usually will end up in the executing thread's
Thread.UncaughtExceptionHandler.uncaughtException(Thread, Throwable) handler.T - the type of the item emitted by the Maybe.supplier - a Supplier instance whose execution should be deferred and performed for each individual
MaybeObserver that subscribes to the returned Maybe.Maybe instanceNullPointerException - if supplier is nulldefer(Supplier),
fromCallable(Callable)@CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Maybe<T> just(T item)
Maybe that emits a specified item.
To convert any object into a Maybe that emits that object, pass that object into the
just method.
just does not operate by default on a particular Scheduler.T - the type of that itemitem - the item to emitMaybe instanceNullPointerException - if item is null@BackpressureSupport(value=FULL) @CheckReturnValue @SchedulerSupport(value="none") @NonNull public static <T> @NonNull Flowable<T> merge(@NonNull Iterable<? extends MaybeSource<? extends T>> sources)
Iterable sequence of MaybeSource instances into a single Flowable sequence,
running all MaybeSources at once.
merge does not operate by default on a particular Scheduler.MaybeSources signal a Throwable via onError, the resulting
Flowable terminates with that Throwable and all other source MaybeSources are disposed.
If more than one MaybeSource signals an error, the resulting Flowable may terminate with the
first one's error or, depending on the concurrency of the sources, may terminate with a
CompositeException containing two or more of the various error signals.
Throwables that didn't make into the composite will be sent (individually) to the global error handler via
RxJavaPlugins.onError(Throwable) method as UndeliverableException errors. Similarly, Throwables
signaled by source(s) after the returned Flowable has been cancelled or terminated with a
(composite) error will be sent to the same global error handler.
Use mergeDelayError(Iterable) to merge sources and terminate only when all source MaybeSources
have completed or failed with an error.
T - the common and resulting value typesources - the Iterable sequence of MaybeSource sourcesFlowable instanceNullPointerException - if sources is nullmergeDelayError(Iterable)@BackpressureSupport(value=FULL) @CheckReturnValue @SchedulerSupport(value="none") @NonNull public static <T> @NonNull Flowable<T> merge(@NonNull Publisher<? extends MaybeSource<? extends T>> sources)
Publisher sequence of MaybeSource instances into a single Flowable sequence,
running all MaybeSources at once.
merge does not operate by default on a particular Scheduler.MaybeSources signal a Throwable via onError, the resulting
Flowable terminates with that Throwable and all other source MaybeSources are disposed.
If more than one MaybeSource signals an error, the resulting Flowable may terminate with the
first one's error or, depending on the concurrency of the sources, may terminate with a
CompositeException containing two or more of the various error signals.
Throwables that didn't make into the composite will be sent (individually) to the global error handler via
RxJavaPlugins.onError(Throwable) method as UndeliverableException errors. Similarly, Throwables
signaled by source(s) after the returned Flowable has been cancelled or terminated with a
(composite) error will be sent to the same global error handler.
Use mergeDelayError(Publisher) to merge sources and terminate only when all source MaybeSources
have completed or failed with an error.
T - the common and resulting value typesources - the Flowable sequence of MaybeSource sourcesFlowable instanceNullPointerException - if sources is nullmergeDelayError(Publisher)@BackpressureSupport(value=FULL) @CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Flowable<T> merge(@NonNull Publisher<? extends MaybeSource<? extends T>> sources, int maxConcurrency)
Publisher sequence of MaybeSource instances into a single Flowable sequence,
running at most maxConcurrency MaybeSources at once.
merge does not operate by default on a particular Scheduler.MaybeSources signal a Throwable via onError, the resulting
Flowable terminates with that Throwable and all other source MaybeSources are disposed.
If more than one MaybeSource signals an error, the resulting Flowable may terminate with the
first one's error or, depending on the concurrency of the sources, may terminate with a
CompositeException containing two or more of the various error signals.
Throwables that didn't make into the composite will be sent (individually) to the global error handler via
RxJavaPlugins.onError(Throwable) method as UndeliverableException errors. Similarly, Throwables
signaled by source(s) after the returned Flowable has been cancelled or terminated with a
(composite) error will be sent to the same global error handler.
Use mergeDelayError(Publisher, int) to merge sources and terminate only when all source MaybeSources
have completed or failed with an error.
T - the common and resulting value typesources - the Flowable sequence of MaybeSource sourcesmaxConcurrency - the maximum number of concurrently running MaybeSourcesFlowable instanceNullPointerException - if sources is nullIllegalArgumentException - if maxConcurrency is non-positivemergeDelayError(Publisher, int)@CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Maybe<T> merge(@NonNull MaybeSource<? extends MaybeSource<? extends T>> source)
MaybeSource that emits a MaybeSource into a single MaybeSource that emits the item
emitted by the nested MaybeSource, without any transformation.
merge does not operate by default on a particular Scheduler.Maybe emits the outer source's or the inner MaybeSource's Throwable as is.
Unlike the other merge() operators, this operator won't and can't produce a CompositeException because there is
only one possibility for the outer or the inner MaybeSource to emit an onError signal.
Therefore, there is no need for a mergeDelayError(MaybeSource<MaybeSource<T>>) operator.
T - the value type of the sources and the outputsource - a MaybeSource that emits a MaybeSourceMaybe instanceNullPointerException - if source is null@BackpressureSupport(value=FULL) @CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Flowable<T> merge(@NonNull MaybeSource<? extends T> source1, @NonNull MaybeSource<? extends T> source2)
MaybeSources into a single Flowable, without any transformation.
You can combine items emitted by multiple MaybeSources so that they appear as a single Flowable, by
using the merge method.
merge does not operate by default on a particular Scheduler.MaybeSources signal a Throwable via onError, the resulting
Flowable terminates with that Throwable and all other source MaybeSources are disposed.
If more than one MaybeSource signals an error, the resulting Flowable may terminate with the
first one's error or, depending on the concurrency of the sources, may terminate with a
CompositeException containing two or more of the various error signals.
Throwables that didn't make into the composite will be sent (individually) to the global error handler via
RxJavaPlugins.onError(Throwable) method as UndeliverableException errors. Similarly, Throwables
signaled by source(s) after the returned Flowable has been cancelled or terminated with a
(composite) error will be sent to the same global error handler.
Use mergeDelayError(MaybeSource, MaybeSource) to merge sources and terminate only when all source MaybeSources
have completed or failed with an error.
T - the common value typesource1 - a MaybeSource to be mergedsource2 - a MaybeSource to be mergedFlowable instanceNullPointerException - if source1 or source2 is nullmergeDelayError(MaybeSource, MaybeSource)@BackpressureSupport(value=FULL) @CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Flowable<T> merge(@NonNull MaybeSource<? extends T> source1, @NonNull MaybeSource<? extends T> source2, @NonNull MaybeSource<? extends T> source3)
MaybeSources into a single Flowable, without any transformation.
You can combine items emitted by multiple MaybeSources so that they appear as a single Flowable, by using
the merge method.
merge does not operate by default on a particular Scheduler.MaybeSources signal a Throwable via onError, the resulting
Flowable terminates with that Throwable and all other source MaybeSources are disposed.
If more than one MaybeSource signals an error, the resulting Flowable may terminate with the
first one's error or, depending on the concurrency of the sources, may terminate with a
CompositeException containing two or more of the various error signals.
Throwables that didn't make into the composite will be sent (individually) to the global error handler via
RxJavaPlugins.onError(Throwable) method as UndeliverableException errors. Similarly, Throwables
signaled by source(s) after the returned Flowable has been cancelled or terminated with a
(composite) error will be sent to the same global error handler.
Use mergeDelayError(MaybeSource, MaybeSource, MaybeSource) to merge sources and terminate only when all source MaybeSources
have completed or failed with an error.
T - the common value typesource1 - a MaybeSource to be mergedsource2 - a MaybeSource to be mergedsource3 - a MaybeSource to be mergedFlowable instanceNullPointerException - if source1, source2 or source3 is nullmergeDelayError(MaybeSource, MaybeSource, MaybeSource)@BackpressureSupport(value=FULL) @CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Flowable<T> merge(@NonNull MaybeSource<? extends T> source1, @NonNull MaybeSource<? extends T> source2, @NonNull MaybeSource<? extends T> source3, @NonNull MaybeSource<? extends T> source4)
MaybeSources into a single Flowable, without any transformation.
You can combine items emitted by multiple MaybeSources so that they appear as a single Flowable, by using
the merge method.
merge does not operate by default on a particular Scheduler.MaybeSources signal a Throwable via onError, the resulting
Flowable terminates with that Throwable and all other source MaybeSources are disposed.
If more than one MaybeSource signals an error, the resulting Flowable may terminate with the
first one's error or, depending on the concurrency of the sources, may terminate with a
CompositeException containing two or more of the various error signals.
Throwables that didn't make into the composite will be sent (individually) to the global error handler via
RxJavaPlugins.onError(Throwable) method as UndeliverableException errors. Similarly, Throwables
signaled by source(s) after the returned Flowable has been cancelled or terminated with a
(composite) error will be sent to the same global error handler.
Use mergeDelayError(MaybeSource, MaybeSource, MaybeSource, MaybeSource) to merge sources and terminate only when all source MaybeSources
have completed or failed with an error.
T - the common value typesource1 - a MaybeSource to be mergedsource2 - a MaybeSource to be mergedsource3 - a MaybeSource to be mergedsource4 - a MaybeSource to be mergedFlowable instanceNullPointerException - if source1, source2, source3 or source4 is nullmergeDelayError(MaybeSource, MaybeSource, MaybeSource, MaybeSource)@BackpressureSupport(value=FULL) @CheckReturnValue @NonNull @SchedulerSupport(value="none") @SafeVarargs public static <T> @NonNull Flowable<T> mergeArray(MaybeSource<? extends T>... sources)
MaybeSource instances into a single Flowable sequence,
running all MaybeSources at once.
mergeArray does not operate by default on a particular Scheduler.MaybeSources signal a Throwable via onError, the resulting
Flowable terminates with that Throwable and all other source MaybeSources are disposed.
If more than one MaybeSource signals an error, the resulting Flowable may terminate with the
first one's error or, depending on the concurrency of the sources, may terminate with a
CompositeException containing two or more of the various error signals.
Throwables that didn't make into the composite will be sent (individually) to the global error handler via
RxJavaPlugins.onError(Throwable) method as UndeliverableException errors. Similarly, Throwables
signaled by source(s) after the returned Flowable has been cancelled or terminated with a
(composite) error will be sent to the same global error handler.
Use mergeArrayDelayError(MaybeSource...) to merge sources and terminate only when all source MaybeSources
have completed or failed with an error.
T - the common and resulting value typesources - the array sequence of MaybeSource sourcesFlowable instanceNullPointerException - if sources is nullmergeArrayDelayError(MaybeSource...)@BackpressureSupport(value=FULL) @CheckReturnValue @SchedulerSupport(value="none") @SafeVarargs @NonNull public static <T> @NonNull Flowable<T> mergeArrayDelayError(@NonNull MaybeSource<? extends T>... sources)
MaybeSources into one Flowable, in a way that allows a subscriber to receive all
successfully emitted items from each of the source MaybeSources without being interrupted by an error
notification from one of them.
This behaves like merge(Publisher) except that if any of the merged MaybeSources notify of an
error via onError, mergeArrayDelayError will refrain from propagating that
error notification until all of the merged MaybeSources have finished emitting items.
Even if multiple merged MaybeSources send onError notifications, mergeArrayDelayError will only
invoke the onError method of its subscribers once.
mergeArrayDelayError does not operate by default on a particular Scheduler.T - the common element base typesources - the array of MaybeSourcesFlowable instanceNullPointerException - if sources is null@BackpressureSupport(value=FULL) @CheckReturnValue @SchedulerSupport(value="none") @NonNull public static <T> @NonNull Flowable<T> mergeDelayError(@NonNull Iterable<? extends MaybeSource<? extends T>> sources)
Iterable sequence of MaybeSources into one Flowable, in a way that allows a subscriber to receive all
successfully emitted items from each of the source MaybeSources without being interrupted by an error
notification from one of them.
This behaves like merge(Publisher) except that if any of the merged MaybeSources notify of an
error via onError, mergeDelayError will refrain from propagating that
error notification until all of the merged MaybeSources have finished emitting items.
Even if multiple merged MaybeSources send onError notifications, mergeDelayError will only
invoke the onError method of its subscribers once.
mergeDelayError does not operate by default on a particular Scheduler.T - the common element base typesources - the Iterable of MaybeSourcesFlowable instanceNullPointerException - if sources is null@BackpressureSupport(value=FULL) @CheckReturnValue @SchedulerSupport(value="none") @NonNull public static <T> @NonNull Flowable<T> mergeDelayError(@NonNull Publisher<? extends MaybeSource<? extends T>> sources)
Publisher that emits MaybeSources into one Flowable, in a way that allows a subscriber to
receive all successfully emitted items from all of the source MaybeSources without being interrupted by
an error notification from one of them or even the main Publisher.
This behaves like merge(Publisher) except that if any of the merged MaybeSources notify of an
error via onError, mergeDelayError will refrain from propagating that
error notification until all of the merged MaybeSources and the main Publisher have finished emitting items.
Even if multiple merged MaybeSources send onError notifications, mergeDelayError will only
invoke the onError method of its subscribers once.
Publisher is consumed
in unbounded mode (i.e., no backpressure is applied to it).mergeDelayError does not operate by default on a particular Scheduler.T - the common element base typesources - a Publisher that emits MaybeSourcesFlowable instanceNullPointerException - if sources is null@BackpressureSupport(value=FULL) @CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Flowable<T> mergeDelayError(@NonNull Publisher<? extends MaybeSource<? extends T>> sources, int maxConcurrency)
Publisher that emits MaybeSources into one Flowable, in a way that allows a subscriber to
receive all successfully emitted items from all of the source MaybeSources without being interrupted by
an error notification from one of them or even the main Publisher as well as limiting the total number of active MaybeSources.
This behaves like merge(Publisher, int) except that if any of the merged MaybeSources notify of an
error via onError, mergeDelayError will refrain from propagating that
error notification until all of the merged MaybeSources and the main Publisher have finished emitting items.
Even if multiple merged MaybeSources send onError notifications, mergeDelayError will only
invoke the onError method of its subscribers once.
Publisher is consumed
in unbounded mode (i.e., no backpressure is applied to it).mergeDelayError does not operate by default on a particular Scheduler.History: 2.1.9 - experimental
T - the common element base typesources - a Publisher that emits MaybeSourcesmaxConcurrency - the maximum number of active inner MaybeSources to be merged at a timeFlowable instanceNullPointerException - if sources is nullIllegalArgumentException - if maxConcurrency is non-positive@BackpressureSupport(value=FULL) @CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Flowable<T> mergeDelayError(@NonNull MaybeSource<? extends T> source1, @NonNull MaybeSource<? extends T> source2)
MaybeSources into one Flowable, in a way that allows a subscriber to receive all
successfully emitted items from each of the source MaybeSources without being interrupted by an error
notification from one of them.
This behaves like merge(MaybeSource, MaybeSource) except that if any of the merged MaybeSources
notify of an error via onError, mergeDelayError will refrain from
propagating that error notification until all of the merged MaybeSources have finished emitting items.
Even if both merged MaybeSources send onError notifications, mergeDelayError will only
invoke the onError method of its subscribers once.
mergeDelayError does not operate by default on a particular Scheduler.T - the common element base typesource1 - a MaybeSource to be mergedsource2 - a MaybeSource to be mergedFlowable instanceNullPointerException - if source1 or source2 is null@BackpressureSupport(value=FULL) @CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Flowable<T> mergeDelayError(@NonNull MaybeSource<? extends T> source1, @NonNull MaybeSource<? extends T> source2, @NonNull MaybeSource<? extends T> source3)
MaybeSource into one Flowable, in a way that allows a subscriber to receive all
successfully emitted items from all of the source MaybeSources without being interrupted by an error
notification from one of them.
This behaves like merge(MaybeSource, MaybeSource, MaybeSource) except that if any of the merged
MaybeSources notify of an error via onError, mergeDelayError will refrain
from propagating that error notification until all of the merged MaybeSources have finished emitting
items.
Even if multiple merged MaybeSources send onError notifications, mergeDelayError will only
invoke the onError method of its subscribers once.
mergeDelayError does not operate by default on a particular Scheduler.T - the common element base typesource1 - a MaybeSource to be mergedsource2 - a MaybeSource to be mergedsource3 - a MaybeSource to be mergedFlowable instanceNullPointerException - if source1, source2 or source3 is null@BackpressureSupport(value=FULL) @CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Flowable<T> mergeDelayError(@NonNull MaybeSource<? extends T> source1, @NonNull MaybeSource<? extends T> source2, @NonNull MaybeSource<? extends T> source3, @NonNull MaybeSource<? extends T> source4)
MaybeSources into one Flowable, in a way that allows a subscriber to receive all
successfully emitted items from all of the source MaybeSources without being interrupted by an error
notification from one of them.
This behaves like merge(MaybeSource, MaybeSource, MaybeSource, MaybeSource) except that if any of
the merged MaybeSources notify of an error via onError, mergeDelayError
will refrain from propagating that error notification until all of the merged MaybeSources have finished
emitting items.
Even if multiple merged MaybeSources send onError notifications, mergeDelayError will only
invoke the onError method of its subscribers once.
mergeDelayError does not operate by default on a particular Scheduler.T - the common element base typesource1 - a MaybeSource to be mergedsource2 - a MaybeSource to be mergedsource3 - a MaybeSource to be mergedsource4 - a MaybeSource to be mergedFlowable instanceNullPointerException - if source1, source2, source3 or source4 is null@CheckReturnValue @SchedulerSupport(value="none") @NonNull public static <T> @NonNull Maybe<T> never()
Maybe that never sends any items or notifications to a MaybeObserver.
This Maybe is useful primarily for testing purposes.
never does not operate by default on a particular Scheduler.T - the type of items (not) emitted by the MaybeMaybe instance@CheckReturnValue @SchedulerSupport(value="none") @NonNull public static <T> @NonNull Single<Boolean> sequenceEqual(@NonNull MaybeSource<? extends T> source1, @NonNull MaybeSource<? extends T> source2)
Single that emits a Boolean value that indicates whether two MaybeSource sequences are the
same by comparing the items emitted by each MaybeSource pairwise.
sequenceEqual does not operate by default on a particular Scheduler.T - the type of items emitted by each MaybeSourcesource1 - the first MaybeSource to comparesource2 - the second MaybeSource to compareSingle instanceNullPointerException - if source1 or source2 is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Single<Boolean> sequenceEqual(@NonNull MaybeSource<? extends T> source1, @NonNull MaybeSource<? extends T> source2, @NonNull BiPredicate<? super T,? super T> isEqual)
Single that emits a Boolean value that indicates whether two MaybeSources are the
same by comparing the items emitted by each MaybeSource pairwise based on the results of a specified
equality function.
sequenceEqual does not operate by default on a particular Scheduler.T - the type of items emitted by each MaybeSourcesource1 - the first MaybeSource to comparesource2 - the second MaybeSource to compareisEqual - a function used to compare items emitted by each MaybeSourceSingle instanceNullPointerException - if source1, source2 or isEqual is null@BackpressureSupport(value=UNBOUNDED_IN) @CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Flowable<T> switchOnNext(@NonNull Publisher<? extends MaybeSource<? extends T>> sources)
MaybeSources emitted by the source Publisher whenever
a new MaybeSource is emitted, disposing the previously running MaybeSource,
exposing the success items as a Flowable sequence.
sources Publisher is consumed in an unbounded manner (requesting Long.MAX_VALUE).
The returned Flowable respects the backpressure from the downstream.switchOnNext does not operate by default on a particular Scheduler.sources Publisher
or the currently running MaybeSource, disposing the rest. Late errors are
forwarded to the global error handler via RxJavaPlugins.onError(Throwable).T - the element type of the MaybeSourcessources - the Publisher sequence of inner MaybeSources to switch betweenFlowable instanceNullPointerException - if sources is nullswitchOnNextDelayError(Publisher),
ReactiveX operators documentation: Switch@BackpressureSupport(value=FULL) @CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Flowable<T> switchOnNextDelayError(@NonNull Publisher<? extends MaybeSource<? extends T>> sources)
MaybeSources emitted by the source Publisher whenever
a new MaybeSource is emitted, disposing the previously running MaybeSource,
exposing the success items as a Flowable sequence and delaying all errors from
all of them until all terminate.
sources Publisher is consumed in an unbounded manner (requesting Long.MAX_VALUE).
The returned Flowable respects the backpressure from the downstream.switchOnNextDelayError does not operate by default on a particular Scheduler.Flowable collects all errors emitted by either the sources
Publisher or any inner MaybeSource and emits them as a CompositeException
when all sources terminate. If only one source ever failed, its error is emitted as-is at the end.T - the element type of the MaybeSourcessources - the Publisher sequence of inner MaybeSources to switch betweenFlowable instanceNullPointerException - if sources is nullswitchOnNext(Publisher),
ReactiveX operators documentation: Switch@CheckReturnValue @SchedulerSupport(value="io.reactivex:computation") @NonNull public static @NonNull Maybe<Long> timer(long delay, @NonNull TimeUnit unit)
Maybe that emits 0L after a specified delay.
timer operates by default on the computation Scheduler.delay - the initial delay before emitting a single 0Lunit - time units to use for delayMaybe instanceNullPointerException - if unit is null@CheckReturnValue @NonNull @SchedulerSupport(value="custom") public static @NonNull Maybe<Long> timer(long delay, @NonNull TimeUnit unit, @NonNull Scheduler scheduler)
Maybe that emits 0L after a specified delay on a specified Scheduler.
Scheduler this operator will use.delay - the initial delay before emitting a single 0Lunit - time units to use for delayscheduler - the Scheduler to use for scheduling the itemMaybe instanceNullPointerException - if unit or scheduler is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Maybe<T> unsafeCreate(@NonNull MaybeSource<T> onSubscribe)
Maybe instance without
any safeguards by using a callback that is called with a MaybeObserver.
unsafeCreate does not operate by default on a particular Scheduler.T - the value typeonSubscribe - the function that is called with the subscribing MaybeObserverMaybe instanceIllegalArgumentException - if onSubscribe is a MaybeNullPointerException - if onSubscribe is null@CheckReturnValue @SchedulerSupport(value="none") @NonNull public static <T,D> @NonNull Maybe<T> using(@NonNull Supplier<? extends D> resourceSupplier, @NonNull Function<? super D,? extends MaybeSource<? extends T>> sourceSupplier, @NonNull Consumer<? super D> resourceCleanup)
Maybe that creates a dependent resource object which is disposed of when the
generated MaybeSource terminates or the downstream calls dispose().
using does not operate by default on a particular Scheduler.T - the element type of the generated MaybeSourceD - the type of the resource associated with the output sequenceresourceSupplier - the factory function to create a resource object that depends on the MaybesourceSupplier - the factory function to create a MaybeSourceresourceCleanup - the function that will dispose of the resourceMaybe instanceNullPointerException - if resourceSupplier, sourceSupplier or resourceCleanup is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T,D> @NonNull Maybe<T> using(@NonNull Supplier<? extends D> resourceSupplier, @NonNull Function<? super D,? extends MaybeSource<? extends T>> sourceSupplier, @NonNull Consumer<? super D> resourceCleanup, boolean eager)
Maybe that creates a dependent resource object which is disposed first ({code eager == true})
when the generated MaybeSource terminates or the downstream disposes; or after ({code eager == false}).
Eager disposal is particularly appropriate for a synchronous Maybe that reuses resources. disposeAction will
only be called once per subscription.
using does not operate by default on a particular Scheduler.T - the element type of the generated MaybeSourceD - the type of the resource associated with the output sequenceresourceSupplier - the factory function to create a resource object that depends on the MaybesourceSupplier - the factory function to create a MaybeSourceresourceCleanup - the function that will dispose of the resourceeager - If true then resource disposal will happen either on a dispose() call before the upstream is disposed
or just before the emission of a terminal event (onSuccess, onComplete or onError).
If false the resource disposal will happen either on a dispose() call after the upstream is disposed
or just after the emission of a terminal event (onSuccess, onComplete or onError).Maybe instanceNullPointerException - if resourceSupplier, sourceSupplier or resourceCleanup is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T> @NonNull Maybe<T> wrap(@NonNull MaybeSource<T> source)
MaybeSource instance into a new Maybe instance if not already a Maybe
instance.
wrap does not operate by default on a particular Scheduler.T - the value typesource - the source to wrapMaybe instanceNullPointerException - if source is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T,R> @NonNull Maybe<R> zip(@NonNull Iterable<? extends MaybeSource<? extends T>> sources, @NonNull Function<? super Object[],? extends R> zipper)
Maybe that emits the results of a specified combiner function applied to combinations of
items emitted, in sequence, by an Iterable of other MaybeSources.
Note on method signature: since Java doesn't allow creating a generic array with new T[], the
implementation of this operator has to create an Object[] instead. Unfortunately, a
Function<Integer[], R> passed to the method would trigger a ClassCastException.
This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This
also means it is possible some sources may not get subscribed to at all.
zip does not operate by default on a particular Scheduler.T - the common value typeR - the zipped result typesources - an Iterable of source MaybeSourceszipper - a function that, when applied to an item emitted by each of the source MaybeSources, results in
an item that will be emitted by the resulting MaybeMaybe instanceNullPointerException - if zipper or sources is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T1,T2,R> @NonNull Maybe<R> zip(@NonNull MaybeSource<? extends T1> source1, @NonNull MaybeSource<? extends T2> source2, @NonNull BiFunction<? super T1,? super T2,? extends R> zipper)
Maybe that emits the results of a specified combiner function applied to combinations of
two items emitted, in sequence, by two other MaybeSources.
This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This
also means it is possible some sources may not get subscribed to at all.
zip does not operate by default on a particular Scheduler.T1 - the value type of the first sourceT2 - the value type of the second sourceR - the zipped result typesource1 - the first source MaybeSourcesource2 - a second source MaybeSourcezipper - a function that, when applied to an item emitted by each of the source MaybeSources, results
in an item that will be emitted by the resulting MaybeMaybe instanceNullPointerException - if source1, source2 or zipper is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T1,T2,T3,R> @NonNull Maybe<R> zip(@NonNull MaybeSource<? extends T1> source1, @NonNull MaybeSource<? extends T2> source2, @NonNull MaybeSource<? extends T3> source3, @NonNull Function3<? super T1,? super T2,? super T3,? extends R> zipper)
Maybe that emits the results of a specified combiner function applied to combinations of
three items emitted, in sequence, by three other MaybeSources.
This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This
also means it is possible some sources may not get subscribed to at all.
zip does not operate by default on a particular Scheduler.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 typesource1 - the first source MaybeSourcesource2 - a second source MaybeSourcesource3 - a third source MaybeSourcezipper - a function that, when applied to an item emitted by each of the source MaybeSources, results in
an item that will be emitted by the resulting MaybeMaybe instanceNullPointerException - if source1, source2, source3 or zipper is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T1,T2,T3,T4,R> @NonNull Maybe<R> zip(@NonNull MaybeSource<? extends T1> source1, @NonNull MaybeSource<? extends T2> source2, @NonNull MaybeSource<? extends T3> source3, @NonNull MaybeSource<? extends T4> source4, @NonNull Function4<? super T1,? super T2,? super T3,? super T4,? extends R> zipper)
Maybe that emits the results of a specified combiner function applied to combinations of
four items emitted, in sequence, by four other MaybeSources.
This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This
also means it is possible some sources may not get subscribed to at all.
zip does not operate by default on a particular Scheduler.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 typesource1 - the first source MaybeSourcesource2 - a second source MaybeSourcesource3 - a third source MaybeSourcesource4 - a fourth source MaybeSourcezipper - a function that, when applied to an item emitted by each of the source MaybeSources, results in
an item that will be emitted by the resulting MaybeMaybe instanceNullPointerException - if source1, source2, source3,
source4 or zipper is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T1,T2,T3,T4,T5,R> @NonNull Maybe<R> zip(@NonNull MaybeSource<? extends T1> source1, @NonNull MaybeSource<? extends T2> source2, @NonNull MaybeSource<? extends T3> source3, @NonNull MaybeSource<? extends T4> source4, @NonNull MaybeSource<? extends T5> source5, @NonNull Function5<? super T1,? super T2,? super T3,? super T4,? super T5,? extends R> zipper)
Maybe that emits the results of a specified combiner function applied to combinations of
five items emitted, in sequence, by five other MaybeSources.
This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This
also means it is possible some sources may not get subscribed to at all.
zip does not operate by default on a particular Scheduler.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 typesource1 - the first source MaybeSourcesource2 - a second source MaybeSourcesource3 - a third source MaybeSourcesource4 - a fourth source MaybeSourcesource5 - a fifth source MaybeSourcezipper - a function that, when applied to an item emitted by each of the source MaybeSources, results in
an item that will be emitted by the resulting MaybeMaybe instanceNullPointerException - if source1, source2, source3,
source4, source5 or zipper is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T1,T2,T3,T4,T5,T6,R> @NonNull Maybe<R> zip(@NonNull MaybeSource<? extends T1> source1, @NonNull MaybeSource<? extends T2> source2, @NonNull MaybeSource<? extends T3> source3, @NonNull MaybeSource<? extends T4> source4, @NonNull MaybeSource<? extends T5> source5, @NonNull MaybeSource<? extends T6> source6, @NonNull Function6<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? extends R> zipper)
Maybe that emits the results of a specified combiner function applied to combinations of
six items emitted, in sequence, by six other MaybeSources.
This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This
also means it is possible some sources may not get subscribed to at all.
zip does not operate by default on a particular Scheduler.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 typesource1 - the first source MaybeSourcesource2 - a second source MaybeSourcesource3 - a third source MaybeSourcesource4 - a fourth source MaybeSourcesource5 - a fifth source MaybeSourcesource6 - a sixth source MaybeSourcezipper - a function that, when applied to an item emitted by each of the source MaybeSources, results in
an item that will be emitted by the resulting MaybeMaybe instanceNullPointerException - if source1, source2, source3,
source4, source5, source6 or zipper is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T1,T2,T3,T4,T5,T6,T7,R> @NonNull Maybe<R> zip(@NonNull MaybeSource<? extends T1> source1, @NonNull MaybeSource<? extends T2> source2, @NonNull MaybeSource<? extends T3> source3, @NonNull MaybeSource<? extends T4> source4, @NonNull MaybeSource<? extends T5> source5, @NonNull MaybeSource<? extends T6> source6, @NonNull MaybeSource<? extends T7> source7, @NonNull Function7<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? extends R> zipper)
Maybe that emits the results of a specified combiner function applied to combinations of
seven items emitted, in sequence, by seven other MaybeSources.
This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This
also means it is possible some sources may not get subscribed to at all.
zip does not operate by default on a particular Scheduler.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 typesource1 - the first source MaybeSourcesource2 - a second source MaybeSourcesource3 - a third source MaybeSourcesource4 - a fourth source MaybeSourcesource5 - a fifth source MaybeSourcesource6 - a sixth source MaybeSourcesource7 - a seventh source MaybeSourcezipper - a function that, when applied to an item emitted by each of the source MaybeSources, results in
an item that will be emitted by the resulting MaybeMaybe instanceNullPointerException - if source1, source2, source3,
source4, source5, source6,
source7 or zipper is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T1,T2,T3,T4,T5,T6,T7,T8,R> @NonNull Maybe<R> zip(@NonNull MaybeSource<? extends T1> source1, @NonNull MaybeSource<? extends T2> source2, @NonNull MaybeSource<? extends T3> source3, @NonNull MaybeSource<? extends T4> source4, @NonNull MaybeSource<? extends T5> source5, @NonNull MaybeSource<? extends T6> source6, @NonNull MaybeSource<? extends T7> source7, @NonNull MaybeSource<? extends T8> source8, @NonNull Function8<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? super T8,? extends R> zipper)
Maybe that emits the results of a specified combiner function applied to combinations of
eight items emitted, in sequence, by eight other MaybeSources.
This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This
also means it is possible some sources may not get subscribed to at all.
zip does not operate by default on a particular Scheduler.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 typesource1 - the first source MaybeSourcesource2 - a second source MaybeSourcesource3 - a third source MaybeSourcesource4 - a fourth source MaybeSourcesource5 - a fifth source MaybeSourcesource6 - a sixth source MaybeSourcesource7 - a seventh source MaybeSourcesource8 - an eighth source MaybeSourcezipper - a function that, when applied to an item emitted by each of the source MaybeSources, results in
an item that will be emitted by the resulting MaybeMaybe instanceNullPointerException - if source1, source2, source3,
source4, source5, source6,
source7, source8 or zipper is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public static <T1,T2,T3,T4,T5,T6,T7,T8,T9,R> @NonNull Maybe<R> zip(@NonNull MaybeSource<? extends T1> source1, @NonNull MaybeSource<? extends T2> source2, @NonNull MaybeSource<? extends T3> source3, @NonNull MaybeSource<? extends T4> source4, @NonNull MaybeSource<? extends T5> source5, @NonNull MaybeSource<? extends T6> source6, @NonNull MaybeSource<? extends T7> source7, @NonNull MaybeSource<? extends T8> source8, @NonNull MaybeSource<? extends T9> source9, @NonNull Function9<? super T1,? super T2,? super T3,? super T4,? super T5,? super T6,? super T7,? super T8,? super T9,? extends R> zipper)
Maybe that emits the results of a specified combiner function applied to combinations of
nine items emitted, in sequence, by nine other MaybeSources.
This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This
also means it is possible some sources may not get subscribed to at all.
zip does not operate by default on a particular Scheduler.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 typesource1 - the first source MaybeSourcesource2 - a second source MaybeSourcesource3 - a third source MaybeSourcesource4 - a fourth source MaybeSourcesource5 - a fifth source MaybeSourcesource6 - a sixth source MaybeSourcesource7 - a seventh source MaybeSourcesource8 - an eighth source MaybeSourcesource9 - a ninth source MaybeSourcezipper - a function that, when applied to an item emitted by each of the source MaybeSources, results in
an item that will be emitted by the resulting MaybeMaybe instanceNullPointerException - if source1, source2, source3,
source4, source5, source6,
source7, source8, source9 or zipper is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") @SafeVarargs public static <T,R> @NonNull Maybe<R> zipArray(@NonNull Function<? super Object[],? extends R> zipper, @NonNull MaybeSource<? extends T>... sources)
Maybe that emits the results of a specified combiner function applied to combinations of
items emitted, in sequence, by an array of other MaybeSources.
Note on method signature: since Java doesn't allow creating a generic array with new T[], the
implementation of this operator has to create an Object[] instead. Unfortunately, a
Function<Integer[], R> passed to the method would trigger a ClassCastException.
This operator terminates eagerly if any of the source MaybeSources signal an onError or onComplete. This
also means it is possible some sources may not get subscribed to at all.
zipArray does not operate by default on a particular Scheduler.T - the common element typeR - the result typesources - an array of source MaybeSourceszipper - a function that, when applied to an item emitted by each of the source MaybeSources, results in
an item that will be emitted by the resulting MaybeMaybe instanceNullPointerException - if sources or zipper is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final @NonNull Maybe<T> ambWith(@NonNull MaybeSource<? extends T> other)
MaybeSource (current or provided) that first signals an event.
ambWith does not operate by default on a particular Scheduler.other - a MaybeSource competing to react first. A subscription to this provided source will occur after
subscribing to the current source.Maybe instanceNullPointerException - if other is null@CheckReturnValue @SchedulerSupport(value="none") @Nullable public final T blockingGet()
Maybe signals a success value (which is returned),
null if completed or an exception (which is propagated).
blockingGet does not operate by default on a particular Scheduler.Exception
into RuntimeException and throws that. Otherwise, RuntimeExceptions and
Errors are rethrown as they are.@CheckReturnValue @SchedulerSupport(value="none") @NonNull public final T blockingGet(@NonNull T defaultValue)
Maybe signals a success value (which is returned),
defaultValue if completed or an exception (which is propagated).
blockingGet does not operate by default on a particular Scheduler.Exception
into RuntimeException and throws that. Otherwise, RuntimeExceptions and
Errors are rethrown as they are.defaultValue - the default item to return if this Maybe is emptyNullPointerException - if defaultValue is null@SchedulerSupport(value="none") public final void blockingSubscribe()
Maybe and blocks the current thread until it terminates.
blockingSubscribe does not operate by default on a particular Scheduler.Maybe signals an error,
the Throwable is routed to the global error handler via RxJavaPlugins.onError(Throwable).
If the current thread is interrupted, an InterruptedException is routed to the same global error handler.
@SchedulerSupport(value="none") public final void blockingSubscribe(@NonNull Consumer<? super T> onSuccess)
Maybe and calls given onSuccess callback on the current thread
when it completes normally.
blockingSubscribe does not operate by default on a particular Scheduler.Maybe signals an error or onSuccess throws,
the respective Throwable is routed to the global error handler via RxJavaPlugins.onError(Throwable).
If the current thread is interrupted, an InterruptedException is routed to the same global error handler.
onSuccess - the Consumer to call if the current Maybe succeedsNullPointerException - if onSuccess is nullblockingSubscribe(Consumer, Consumer),
blockingSubscribe(Consumer, Consumer, Action)@SchedulerSupport(value="none") public final void blockingSubscribe(@NonNull Consumer<? super T> onSuccess, @NonNull Consumer<? super Throwable> onError)
Maybe and calls the appropriate callback on the current thread
when it terminates.
blockingSubscribe does not operate by default on a particular Scheduler.onSuccess or onError throw, the Throwable is routed to the
global error handler via RxJavaPlugins.onError(Throwable).
If the current thread is interrupted, the onError consumer is called with an InterruptedException.
onSuccess - the Consumer to call if the current Maybe succeedsonError - the Consumer to call if the current Maybe signals an errorNullPointerException - if onSuccess or onError is nullblockingSubscribe(Consumer, Consumer, Action)@SchedulerSupport(value="none") public final void blockingSubscribe(@NonNull Consumer<? super T> onSuccess, @NonNull Consumer<? super Throwable> onError, @NonNull Action onComplete)
Maybe and calls the appropriate callback on the current thread
when it terminates.
blockingSubscribe does not operate by default on a particular Scheduler.onSuccess, onError or onComplete throw, the Throwable is routed to the
global error handler via RxJavaPlugins.onError(Throwable).
If the current thread is interrupted, the onError consumer is called with an InterruptedException.
onSuccess - the Consumer to call if the current Maybe succeedsonError - the Consumer to call if the current Maybe signals an erroronComplete - the Action to call if the current Maybe completes without a valueNullPointerException - if onSuccess, onError or onComplete is null@SchedulerSupport(value="none") public final void blockingSubscribe(@NonNull MaybeObserver<? super T> observer)
Maybe and calls the appropriate MaybeObserver method on the current thread.
blockingSubscribe does not operate by default on a particular Scheduler.onError signal is delivered to the MaybeObserver.onError(Throwable) method.
If any of the MaybeObserver's methods throw, the RuntimeException is propagated to the caller of this method.
If the current thread is interrupted, an InterruptedException is delivered to observer.onError.
observer - the MaybeObserver to call methods on the current threadNullPointerException - if observer is null@CheckReturnValue @SchedulerSupport(value="none") @NonNull public final @NonNull Maybe<T> cache()
Maybe that subscribes to this Maybe lazily, caches its event
and replays it, to all the downstream subscribers.
The operator subscribes only when the first downstream subscriber subscribes and maintains
a single subscription towards this Maybe.
Note: You sacrifice the ability to dispose the origin when you use the cache.
cache does not operate by default on a particular Scheduler.Maybe instance@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final <U> @NonNull Maybe<U> cast(@NonNull Class<? extends U> clazz)
Maybe into the target type or signals a
ClassCastException if not compatible.
cast does not operate by default on a particular Scheduler.U - the target typeclazz - the type token to use for casting the success result from the current MaybeMaybe instanceNullPointerException - if clazz is null@CheckReturnValue @SchedulerSupport(value="none") @NonNull public final <R> @NonNull Maybe<R> compose(@NonNull MaybeTransformer<? super T,? extends R> transformer)
Maybe by applying a particular MaybeTransformer function to it.
This method operates on the Maybe itself whereas lift(io.reactivex.rxjava3.core.MaybeOperator<? extends R, ? super T>) operates on the Maybe's MaybeObservers.
If the operator you are creating is designed to act on the individual item emitted by a Maybe, use
lift(io.reactivex.rxjava3.core.MaybeOperator<? extends R, ? super T>). If your operator is designed to transform the current Maybe as a whole (for instance, by
applying a particular set of existing RxJava operators to it) use compose.
compose does not operate by default on a particular Scheduler.R - the value type of the Maybe returned by the transformer functiontransformer - the transformer function, not nullMaybe instanceNullPointerException - if transformer is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final <R> @NonNull Maybe<R> concatMap(@NonNull Function<? super T,? extends MaybeSource<? extends R>> mapper)
Maybe that is based on applying a specified function to the item emitted by the current Maybe,
where that function returns a MaybeSource.
Note that flatMap and concatMap for Maybe is the same operation.
concatMap does not operate by default on a particular Scheduler.R - the result value typemapper - a function that, when applied to the item emitted by the current Maybe, returns a MaybeSourceMaybe instanceNullPointerException - if mapper is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final @NonNull Completable concatMapCompletable(@NonNull Function<? super T,? extends CompletableSource> mapper)
Completable that completes based on applying a specified function to the item emitted by the
current Maybe, where that function returns a Completable.
This operator is an alias for flatMapCompletable(Function).
concatMapCompletable does not operate by default on a particular Scheduler.mapper - a function that, when applied to the item emitted by the current Maybe, returns a
CompletableCompletable instanceNullPointerException - if mapper is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final <R> @NonNull Maybe<R> concatMapSingle(@NonNull Function<? super T,? extends SingleSource<? extends R>> mapper)
Maybe based on applying a specified function to the item emitted by the
current Maybe, where that function returns a Single.
When this Maybe just completes the resulting Maybe completes as well.
This operator is an alias for flatMapSingle(Function).
concatMapSingle does not operate by default on a particular Scheduler.R - the result value typemapper - a function that, when applied to the item emitted by the current Maybe, returns a
SingleMaybe instanceNullPointerException - if mapper is null@BackpressureSupport(value=FULL) @CheckReturnValue @NonNull @SchedulerSupport(value="none") public final @NonNull Flowable<T> concatWith(@NonNull MaybeSource<? extends T> other)
Flowable that emits the items emitted from the current Maybe, then the other MaybeSource, one after
the other, without interleaving them.
concatWith does not operate by default on a particular Scheduler.other - a MaybeSource to be concatenated after the currentFlowable instanceNullPointerException - if other is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final @NonNull Single<Boolean> contains(@NonNull Object item)
Single that emits a Boolean that indicates whether the current Maybe emitted a
specified item.
contains does not operate by default on a particular Scheduler.item - the item to search for in the emissions from the current Maybe, not nullSingle instanceNullPointerException - if item is null@CheckReturnValue @SchedulerSupport(value="none") @NonNull public final @NonNull Single<Long> count()
Single that counts the total number of items emitted (0 or 1) by the current Maybe and emits
this count as a 64-bit Long.
count does not operate by default on a particular Scheduler.Single instance@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final @NonNull Single<T> defaultIfEmpty(@NonNull T defaultItem)
Single that emits the item emitted by the current Maybe or a specified default item
if the current Maybe is empty.
defaultIfEmpty does not operate by default on a particular Scheduler.defaultItem - the item to emit if the current Maybe emits no itemsSingle instanceNullPointerException - if defaultItem is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final <R> @NonNull Maybe<R> dematerialize(@NonNull Function<? super T,Notification<R>> selector)
Notification success value of the current Maybe back into normal
onSuccess, onError or onComplete signals.
The intended use of the selector function is to perform a
type-safe identity mapping (see example) on a source that is already of type
Notification<T>. The Java language doesn't allow
limiting instance methods to a certain generic argument shape, therefore,
a function is used to ensure the conversion remains type safe.
Regular onError or onComplete signals from the current Maybe are passed along to the downstream.
dematerialize does not operate by default on a particular Scheduler.Example:
Maybe.just(Notification.createOnNext(1))
.dematerialize(notification -> notification)
.test()
.assertResult(1);
R - the result typeselector - the function called with the success item and should
return a Notification instance.Maybe instanceNullPointerException - if selector is nullmaterialize()@CheckReturnValue @SchedulerSupport(value="io.reactivex:computation") @NonNull public final @NonNull Maybe<T> delay(long time, @NonNull TimeUnit unit)
Maybe that signals the events emitted by the current Maybe shifted forward in time by a
specified delay.
An error signal will not be delayed.
delay operates by default on the computation Scheduler.time - the delay to shift the source byunit - the TimeUnit in which time is definedMaybe instanceNullPointerException - if unit is nulldelay(long, TimeUnit, Scheduler, boolean)@CheckReturnValue @SchedulerSupport(value="io.reactivex:computation") @NonNull public final @NonNull Maybe<T> delay(long time, @NonNull TimeUnit unit, boolean delayError)
Maybe that signals the events emitted by the current Maybe shifted forward in time by a
specified delay.
delay operates by default on the computation Scheduler.time - the delay to shift the source byunit - the TimeUnit in which time is defineddelayError - if true, both success and error signals are delayed. if false, only success signals are delayed.Maybe instanceNullPointerException - if unit is nulldelay(long, TimeUnit, Scheduler, boolean)@CheckReturnValue @SchedulerSupport(value="custom") @NonNull public final @NonNull Maybe<T> delay(long time, @NonNull TimeUnit unit, @NonNull Scheduler scheduler)
Maybe that signals the events emitted by the current Maybe shifted forward in time by a
specified delay.
An error signal will not be delayed.
Scheduler where the non-blocking wait and emission happenstime - the delay to shift the source byunit - the TimeUnit in which time is definedscheduler - the Scheduler to use for delayingMaybe instanceNullPointerException - if unit or scheduler is nulldelay(long, TimeUnit, Scheduler, boolean)@CheckReturnValue @NonNull @SchedulerSupport(value="custom") public final @NonNull Maybe<T> delay(long time, @NonNull TimeUnit unit, @NonNull Scheduler scheduler, boolean delayError)
Maybe that signals the events emitted by the current Maybe shifted forward in time by a
specified delay running on the specified Scheduler.
Scheduler this operator will use.time - the delay to shift the source byunit - the TimeUnit in which time is definedscheduler - the Scheduler to use for delayingdelayError - if true, both success and error signals are delayed. if false, only success signals are delayed.Maybe instanceNullPointerException - if unit or scheduler is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") @BackpressureSupport(value=UNBOUNDED_IN) public final <U> @NonNull Maybe<T> delay(@NonNull Publisher<U> delayIndicator)
Maybe until the given Publisher signals an item or completes.
delayIndicator is consumed in an unbounded manner but is cancelled after
the first item it produces.delay does not operate by default on a particular Scheduler.U - the subscription delay value type (ignored)delayIndicator - the Publisher that gets subscribed to when this Maybe signals an event and that
signal is emitted when the Publisher signals an item or completesMaybe instanceNullPointerException - if delayIndicator is null@BackpressureSupport(value=UNBOUNDED_IN) @CheckReturnValue @NonNull @SchedulerSupport(value="none") public final <U> @NonNull Maybe<T> delaySubscription(@NonNull Publisher<U> subscriptionIndicator)
Maybe that delays the subscription to this Maybe
until the other Publisher emits an element or completes normally.
Publisher source is consumed in an unbounded fashion (without applying backpressure).Scheduler.U - the value type of the other Publisher, irrelevantsubscriptionIndicator - the other Publisher that should trigger the subscription
to this Publisher.Maybe instanceNullPointerException - if subscriptionIndicator is null@CheckReturnValue @SchedulerSupport(value="io.reactivex:computation") @NonNull public final @NonNull Maybe<T> delaySubscription(long time, @NonNull TimeUnit unit)
Maybe that delays the subscription to the current Maybe by a given amount of time.
delaySubscription operates by default on the computation Scheduler.time - the time to delay the subscriptionunit - the time unit of delayMaybe instanceNullPointerException - if unit is nulldelaySubscription(long, TimeUnit, Scheduler)@CheckReturnValue @SchedulerSupport(value="custom") @NonNull public final @NonNull Maybe<T> delaySubscription(long time, @NonNull TimeUnit unit, @NonNull Scheduler scheduler)
Maybe that delays the subscription to the current Maybe by a given amount of time,
both waiting and subscribing on a given Scheduler.
Scheduler this operator will use.time - the time to delay the subscriptionunit - the time unit of delayscheduler - the Scheduler on which the waiting and subscription will happenMaybe instanceNullPointerException - if unit or scheduler is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final @NonNull Maybe<T> doAfterSuccess(@NonNull Consumer<? super T> onAfterSuccess)
Consumer with the success item after this item has been emitted to the downstream.
Note that the onAfterSuccess action is shared between subscriptions and as such
should be thread-safe.
doAfterSuccess does not operate by default on a particular Scheduler.History: 2.0.1 - experimental
onAfterSuccess - the Consumer that will be called after emitting an item from upstream to the downstreamMaybe instanceNullPointerException - if onAfterSuccess is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final @NonNull Maybe<T> doAfterTerminate(@NonNull Action onAfterTerminate)
Action to be called when this Maybe invokes either
onSuccess,
onComplete or onError.
doAfterTerminate does not operate by default on a particular Scheduler.onAfterTerminate - an Action to be invoked when the current Maybe finishesMaybe instanceNullPointerException - if onAfterTerminate is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final @NonNull Maybe<T> doFinally(@NonNull Action onFinally)
Maybe signals onSuccess, onError or onComplete or gets disposed by
the downstream.
In case of a race between a terminal event and a dispose call, the provided onFinally action
is executed once per subscription.
Note that the onFinally action is shared between subscriptions and as such
should be thread-safe.
doFinally does not operate by default on a particular Scheduler.History: 2.0.1 - experimental
onFinally - the action called when this Maybe terminates or gets disposedMaybe instanceNullPointerException - if onFinally is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final @NonNull Maybe<T> doOnDispose(@NonNull Action onDispose)
Action if a MaybeObserver subscribed to the current Maybe
disposes the common Disposable it received via onSubscribe.
doOnDispose does not operate by default on a particular Scheduler.onDispose - the action called when the subscription is disposedMaybe instanceNullPointerException - if onDispose is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final @NonNull Maybe<T> doOnComplete(@NonNull Action onComplete)
Action just before the current Maybe calls onComplete.
doOnComplete does not operate by default on a particular Scheduler.onComplete - the action to invoke when the current Maybe calls onCompleteMaybe with the side-effecting behavior appliedNullPointerException - if onComplete is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final @NonNull Maybe<T> doOnError(@NonNull Consumer<? super Throwable> onError)
Consumer with the error sent via onError for each
MaybeObserver that subscribes to the current Maybe.
doOnError does not operate by default on a particular Scheduler.onError - the consumer called with the success value of onErrorMaybe instanceNullPointerException - if onError is null@CheckReturnValue @SchedulerSupport(value="none") @NonNull public final @NonNull Maybe<T> doOnEvent(@NonNull BiConsumer<? super T,? super Throwable> onEvent)
onEvent callback with the (success value, null) for an onSuccess, (null, throwable) for
an onError or (null, null) for an onComplete signal from this Maybe before delivering said
signal to the downstream.
The exceptions thrown from the callback will override the event so the downstream receives the error instead of the original signal.
doOnEvent does not operate by default on a particular Scheduler.onEvent - the callback to call with the success value or the exception, whichever is not nullMaybe instanceNullPointerException - if onEvent is null@CheckReturnValue @SchedulerSupport(value="none") @NonNull public final @NonNull Maybe<T> doOnLifecycle(@NonNull Consumer<? super Disposable> onSubscribe, @NonNull Action onDispose)
onXXX method (shared between all MaybeObservers) for the lifecycle events of
the sequence (subscription, disposal).
doOnLifecycle does not operate by default on a particular Scheduler.onSubscribe - a Consumer called with the Disposable sent via MaybeObserver.onSubscribe(Disposable)onDispose - called when the downstream disposes the Disposable via dispose()Maybe instanceNullPointerException - if onSubscribe or onDispose is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final @NonNull Maybe<T> doOnSubscribe(@NonNull Consumer<? super Disposable> onSubscribe)
Consumer with the Disposable sent through the onSubscribe for each
MaybeObserver that subscribes to the current Maybe.
doOnSubscribe does not operate by default on a particular Scheduler.onSubscribe - the Consumer called with the Disposable sent via onSubscribeMaybe instanceNullPointerException - if onSubscribe is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final @NonNull Maybe<T> doOnTerminate(@NonNull Action onTerminate)
Maybe instance that calls the given onTerminate callback
just before this Maybe completes normally or with an exception.
This differs from doAfterTerminate in that this happens before the onComplete or
onError notification.
doOnTerminate does not operate by default on a particular Scheduler.History: 2.2.7 - experimental
onTerminate - the action to invoke when the consumer calls onComplete or onErrorMaybe instanceNullPointerException - if onTerminate is nulldoOnTerminate(Action)@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final @NonNull Maybe<T> doOnSuccess(@NonNull Consumer<? super T> onSuccess)
Consumer with the success value sent via onSuccess for each
MaybeObserver that subscribes to the current Maybe.
doOnSuccess does not operate by default on a particular Scheduler.onSuccess - the Consumer called with the success value of the upstreamMaybe instanceNullPointerException - if onSuccess is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final @NonNull Maybe<T> filter(@NonNull Predicate<? super T> predicate)
Maybe via a predicate function and emitting it if the predicate
returns true, completing otherwise.
filter does not operate by default on a particular Scheduler.predicate - a function that evaluates the item emitted by the current Maybe, returning true
if it passes the filterMaybe instanceNullPointerException - if predicate is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final <R> @NonNull Maybe<R> flatMap(@NonNull Function<? super T,? extends MaybeSource<? extends R>> mapper)
Maybe that is based on applying a specified function to the item emitted by the current Maybe,
where that function returns a MaybeSource.
flatMap does not operate by default on a particular Scheduler.Note that flatMap and concatMap for Maybe is the same operation.
R - the result value typemapper - a function that, when applied to the item emitted by the current Maybe, returns a MaybeSourceMaybe instanceNullPointerException - if mapper is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final <R> @NonNull Maybe<R> flatMap(@NonNull Function<? super T,? extends MaybeSource<? extends R>> onSuccessMapper, @NonNull Function<? super Throwable,? extends MaybeSource<? extends R>> onErrorMapper, @NonNull Supplier<? extends MaybeSource<? extends R>> onCompleteSupplier)
onSuccess, onError or onComplete signals of the current Maybe into a MaybeSource and emits that
MaybeSource's signals.
flatMap does not operate by default on a particular Scheduler.R - the result typeonSuccessMapper - a function that returns a MaybeSource to merge for the onSuccess item emitted by this MaybeonErrorMapper - a function that returns a MaybeSource to merge for an onError notification from this MaybeonCompleteSupplier - a function that returns a MaybeSource to merge for an onComplete notification this MaybeMaybe instanceNullPointerException - if onSuccessMapper, onErrorMapper or onCompleteSupplier is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final <U,R> @NonNull Maybe<R> flatMap(@NonNull Function<? super T,? extends MaybeSource<? extends U>> mapper, @NonNull BiFunction<? super T,? super U,? extends R> combiner)
Maybe that emits the results of a specified function to the pair of values emitted by the
current Maybe and a specified mapped MaybeSource.
flatMap does not operate by default on a particular Scheduler.U - the type of items emitted by the MaybeSource returned by the mapper functionR - the type of items emitted by the resulting Maybemapper - a function that returns a MaybeSource for the item emitted by the current Maybecombiner - a function that combines one item emitted by each of the source and collection MaybeSource and
returns an item to be emitted by the resulting MaybeSourceMaybe instanceNullPointerException - if mapper or combiner is null@BackpressureSupport(value=FULL) @CheckReturnValue @NonNull @SchedulerSupport(value="none") public final <U> @NonNull Flowable<U> flattenAsFlowable(@NonNull Function<? super T,? extends Iterable<? extends U>> mapper)
Maybe into an Iterable and emits its items as a
Flowable sequence.
flattenAsFlowable does not operate by default on a particular Scheduler.U - the type of item emitted by the inner Iterablemapper - a function that returns an Iterable sequence of values for when given an item emitted by the
current MaybeFlowable instanceNullPointerException - if mapper is nullflattenStreamAsFlowable(Function)@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final <U> @NonNull Observable<U> flattenAsObservable(@NonNull Function<? super T,? extends Iterable<? extends U>> mapper)
Maybe into an Iterable and emits its items as an
Observable sequence.
flattenAsObservable does not operate by default on a particular Scheduler.U - the type of item emitted by the resulting Iterablemapper - a function that returns an Iterable sequence of values for when given an item emitted by the
current MaybeObservable instanceNullPointerException - if mapper is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final <R> @NonNull Observable<R> flatMapObservable(@NonNull Function<? super T,? extends ObservableSource<? extends R>> mapper)
Observable that is based on applying a specified function to the item emitted by the current Maybe,
where that function returns an ObservableSource.
flatMapObservable does not operate by default on a particular Scheduler.R - the result value typemapper - a function that, when applied to the item emitted by the current Maybe, returns an ObservableSourceObservable instanceNullPointerException - if mapper is null@BackpressureSupport(value=FULL) @CheckReturnValue @NonNull @SchedulerSupport(value="none") public final <R> @NonNull Flowable<R> flatMapPublisher(@NonNull Function<? super T,? extends Publisher<? extends R>> mapper)
Flowable that emits items based on applying a specified function to the item emitted by the
current Maybe, where that function returns a Publisher.
Flowable honors the downstream backpressure.flatMapPublisher does not operate by default on a particular Scheduler.R - the result value typemapper - a function that, when applied to the item emitted by the current Maybe, returns a
FlowableFlowable instanceNullPointerException - if mapper is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final <R> @NonNull Maybe<R> flatMapSingle(@NonNull Function<? super T,? extends SingleSource<? extends R>> mapper)
Maybe based on applying a specified function to the item emitted by the
current Maybe, where that function returns a Single.
When this Maybe just completes the resulting Maybe completes as well.
flatMapSingle does not operate by default on a particular Scheduler.History: 2.0.2 - experimental
R - the result value typemapper - a function that, when applied to the item emitted by the current Maybe, returns a
SingleMaybe instanceNullPointerException - if mapper is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final @NonNull Completable flatMapCompletable(@NonNull Function<? super T,? extends CompletableSource> mapper)
Completable that completes based on applying a specified function to the item emitted by the
current Maybe, where that function returns a Completable.
flatMapCompletable does not operate by default on a particular Scheduler.mapper - a function that, when applied to the item emitted by the current Maybe, returns a
CompletableCompletable instanceNullPointerException - if mapper is null@CheckReturnValue @SchedulerSupport(value="none") @NonNull public final @NonNull Maybe<T> hide()
Maybe and its Disposable.
Allows preventing certain identity-based optimizations (fusion).
hide does not operate by default on a particular Scheduler.Maybe instance@CheckReturnValue @SchedulerSupport(value="none") @NonNull public final @NonNull Completable ignoreElement()
Completable that ignores the item emitted by the current Maybe and only calls onComplete or onError.
ignoreElement does not operate by default on a particular Scheduler.Completable instance@CheckReturnValue @SchedulerSupport(value="none") @NonNull public final @NonNull Single<Boolean> isEmpty()
Single that emits true if the current Maybe is empty, otherwise false.
isEmpty does not operate by default on a particular Scheduler.Single instance@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final <R> @NonNull Maybe<R> lift(@NonNull MaybeOperator<? extends R,? super T> lift)
Maybe which, when subscribed to, invokes the apply(MaybeObserver) method
of the provided MaybeOperator for each individual downstream Maybe and allows the
insertion of a custom operator by accessing the downstream's MaybeObserver during this subscription phase
and providing a new MaybeObserver, containing the custom operator's intended business logic, that will be
used in the subscription process going further upstream.
Generally, such a new MaybeObserver will wrap the downstream's MaybeObserver and forwards the
onSuccess, onError and onComplete events from the upstream directly or according to the
emission pattern the custom operator's business logic requires. In addition, such operator can intercept the
flow control calls of dispose and isDisposed that would have traveled upstream and perform
additional actions depending on the same business logic requirements.
Example:
// Step 1: Create the consumer type that will be returned by the MaybeOperator.apply():
public final class CustomMaybeObserver<T> implements MaybeObserver<T>, Disposable {
// The downstream's MaybeObserver that will receive the onXXX events
final MaybeObserver<? super String> downstream;
// The connection to the upstream source that will call this class' onXXX methods
Disposable upstream;
// The constructor takes the downstream subscriber and usually any other parameters
public CustomMaybeObserver(MaybeObserver<? super String> downstream) {
this.downstream = downstream;
}
// In the subscription phase, the upstream sends a Disposable to this class
// and subsequently this class has to send a Disposable to the downstream.
// Note that relaying the upstream's Disposable directly is not allowed in RxJava
@Override
public void onSubscribe(Disposable d) {
if (upstream != null) {
d.dispose();
} else {
upstream = d;
downstream.onSubscribe(this);
}
}
// The upstream calls this with the next item and the implementation's
// responsibility is to emit an item to the downstream based on the intended
// business logic, or if it can't do so for the particular item,
// request more from the upstream
@Override
public void onSuccess(T item) {
String str = item.toString();
if (str.length() < 2) {
downstream.onSuccess(str);
} else {
// Maybe is expected to produce one of the onXXX events only
downstream.onComplete();
}
}
// Some operators may handle the upstream's error while others
// could just forward it to the downstream.
@Override
public void onError(Throwable throwable) {
downstream.onError(throwable);
}
// When the upstream completes, usually the downstream should complete as well.
@Override
public void onComplete() {
downstream.onComplete();
}
// Some operators may use their own resources which should be cleaned up if
// the downstream disposes the flow before it completed. Operators without
// resources can simply forward the dispose to the upstream.
// In some cases, a disposed flag may be set by this method so that other parts
// of this class may detect the dispose and stop sending events
// to the downstream.
@Override
public void dispose() {
upstream.dispose();
}
// Some operators may simply forward the call to the upstream while others
// can return the disposed flag set in dispose().
@Override
public boolean isDisposed() {
return upstream.isDisposed();
}
}
// Step 2: Create a class that implements the MaybeOperator 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 CustomMaybeOperator<T> implements MaybeOperator<String> {
@Override
public MaybeObserver<? super String> apply(MaybeObserver<? super T> upstream) {
return new CustomMaybeObserver<T>(upstream);
}
}
// Step 3: Apply the custom operator via lift() in a flow by creating an instance of it
// or reusing an existing one.
Maybe.just(5)
.lift(new CustomMaybeOperator<Integer>())
.test()
.assertResult("5");
Maybe.just(15)
.lift(new CustomMaybeOperator<Integer>())
.test()
.assertResult();
Creating custom operators can be complicated and it is recommended one consults the RxJava wiki: Writing operators page about the tools, requirements, rules, considerations and pitfalls of implementing them.
Note that implementing custom operators via this lift() method adds slightly more overhead by requiring
an additional allocation and indirection per assembled flows. Instead, extending the abstract Maybe
class and creating a MaybeTransformer with it is recommended.
Note also that it is not possible to stop the subscription phase in lift() as the apply() method
requires a non-null MaybeObserver instance to be returned, which is then unconditionally subscribed to
the current Maybe. 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 a MaybeObserver that should immediately dispose the upstream's Disposable in its
onSubscribe method. Again, using a MaybeTransformer and extending the Maybe is
a better option as subscribeActual(io.reactivex.rxjava3.core.MaybeObserver<? super T>) can decide to not subscribe to its upstream after all.
lift does not operate by default on a particular Scheduler, however, the
MaybeOperator may use a Scheduler to support its own asynchronous behavior.R - the output value typelift - the MaybeOperator that receives the downstream's MaybeObserver and should return
a MaybeObserver with custom behavior to be used as the consumer for the current
Maybe.Maybe instanceNullPointerException - if lift is nullcompose(MaybeTransformer)@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final <R> @NonNull Maybe<R> map(@NonNull Function<? super T,? extends R> mapper)
Maybe that applies a specified function to the item emitted by the current Maybe and
emits the result of this function application.
map does not operate by default on a particular Scheduler.R - the result value typemapper - a function to apply to the item emitted by the MaybeMaybe instanceNullPointerException - if mapper is null@CheckReturnValue @SchedulerSupport(value="none") @NonNull public final @NonNull Single<Notification<T>> materialize()
Maybe into a Notification of the same kind
and emits it as a Single's onSuccess value to downstream.
materialize does not operate by default on a particular Scheduler.History: 2.2.4 - experimental
Single instanceSingle.dematerialize(Function)@BackpressureSupport(value=FULL) @CheckReturnValue @NonNull @SchedulerSupport(value="none") public final @NonNull Flowable<T> mergeWith(@NonNull MaybeSource<? extends T> other)
Maybe and another MaybeSource into a single Flowable, without any transformation.
You can combine items emitted by multiple Maybes so that they appear as a single Flowable, by
using the mergeWith method.
mergeWith does not operate by default on a particular Scheduler.other - a MaybeSource to be mergedFlowable instanceNullPointerException - if other is null@CheckReturnValue @NonNull @SchedulerSupport(value="custom") public final @NonNull Maybe<T> observeOn(@NonNull Scheduler scheduler)
Maybe to emit its item (or notify of its error) on a specified Scheduler,
asynchronously.
Scheduler this operator will use.scheduler - the Scheduler to notify subscribers onMaybe instance that its subscribers are notified on the specified
SchedulerNullPointerException - if scheduler is nullsubscribeOn(io.reactivex.rxjava3.core.Scheduler)@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final <U> @NonNull Maybe<U> ofType(@NonNull Class<U> clazz)
Maybe, only emitting its success value if that
is an instance of the supplied Class.
ofType does not operate by default on a particular Scheduler.U - the output typeclazz - the class type to filter the items emitted by the current MaybeMaybe instanceNullPointerException - if clazz is null@CheckReturnValue @SchedulerSupport(value="none") public final <R> R to(@NonNull MaybeConverter<T,? extends R> converter)
This allows fluent conversion to any other type.
to does not operate by default on a particular Scheduler.History: 2.1.7 - experimental
R - the resulting object typeconverter - the function that receives the current Maybe instance and returns a valueNullPointerException - if converter is null@BackpressureSupport(value=FULL) @CheckReturnValue @SchedulerSupport(value="none") @NonNull public final @NonNull Flowable<T> toFlowable()
Maybe into a backpressure-aware Flowable instance composing cancellation
through.
Flowable honors the backpressure of the downstream.toFlowable does not operate by default on a particular Scheduler.Flowable instance@CheckReturnValue @SchedulerSupport(value="none") @NonNull public final @NonNull Future<T> toFuture()
Future representing the single value emitted by the current Maybe
or null if the current Maybe is empty.
Cancelling the Future will cancel the subscription to the current Maybe.
toFuture does not operate by default on a particular Scheduler.Future instance@CheckReturnValue @SchedulerSupport(value="none") @NonNull public final @NonNull Observable<T> toObservable()
Maybe into an Observable instance composing disposal
through.
toObservable does not operate by default on a particular Scheduler.Observable instance@CheckReturnValue @SchedulerSupport(value="none") @NonNull public final @NonNull Single<T> toSingle()
Maybe into a Single instance composing disposal
through and turning an empty Maybe into a signal of NoSuchElementException.
toSingle does not operate by default on a particular Scheduler.Single instancedefaultIfEmpty(Object)@CheckReturnValue @SchedulerSupport(value="none") @NonNull public final @NonNull Maybe<T> onErrorComplete()
Maybe instance that if this Maybe emits an error, it will emit an onComplete
and swallow the throwable.
onErrorComplete does not operate by default on a particular Scheduler.Maybe instance@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final @NonNull Maybe<T> onErrorComplete(@NonNull Predicate<? super Throwable> predicate)
Maybe instance that if this Maybe emits an error and the predicate returns
true, it will emit an onComplete and swallow the throwable.
onErrorComplete does not operate by default on a particular Scheduler.predicate - the predicate to call when an Throwable is emitted which should return true
if the Throwable should be swallowed and replaced with an onComplete.Maybe instanceNullPointerException - if predicate is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final @NonNull Maybe<T> onErrorResumeWith(@NonNull MaybeSource<? extends T> fallback)
MaybeSource when the current Maybe fails instead of
signaling the error via onError.
You can use this to prevent errors from propagating or to supply fallback data should errors be encountered.
onErrorResumeWith does not operate by default on a particular Scheduler.fallback - the next MaybeSource that will take over if the current Maybe encounters
an errorMaybe instanceNullPointerException - if fallback is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final @NonNull Maybe<T> onErrorResumeNext(@NonNull Function<? super Throwable,? extends MaybeSource<? extends T>> fallbackSupplier)
MaybeSource returned for the failure Throwable of the current Maybe by a
function instead of signaling the error via onError.
You can use this to prevent errors from propagating or to supply fallback data should errors be encountered.
onErrorResumeNext does not operate by default on a particular Scheduler.fallbackSupplier - a function that returns a MaybeSource that will take over if the current Maybe encounters
an errorMaybe instanceNullPointerException - if fallbackSupplier is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final @NonNull Maybe<T> onErrorReturn(@NonNull Function<? super Throwable,? extends T> itemSupplier)
Throwable error signaled by the current
Maybe instead of signaling the error via onError.
You can use this to prevent errors from propagating or to supply fallback data should errors be encountered.
onErrorReturn does not operate by default on a particular Scheduler.itemSupplier - a function that returns a single value that will be emitted as success value
the current Maybe signals an onError eventMaybe instanceNullPointerException - if itemSupplier is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final @NonNull Maybe<T> onErrorReturnItem(@NonNull T item)
Maybe fails instead of signaling the error via onError.
You can use this to prevent errors from propagating or to supply fallback data should errors be encountered.
onErrorReturnItem does not operate by default on a particular Scheduler.item - the value that is emitted as onSuccess in case the current Maybe signals an onErrorMaybe instanceNullPointerException - if item is null@CheckReturnValue @SchedulerSupport(value="none") @NonNull public final @NonNull Maybe<T> onTerminateDetach()
MaybeObserver if
the sequence is terminated or downstream calls dispose().
onTerminateDetach does not operate by default on a particular Scheduler.Maybe instance
the sequence is terminated or downstream calls dispose()@BackpressureSupport(value=FULL) @CheckReturnValue @SchedulerSupport(value="none") @NonNull public final @NonNull Flowable<T> repeat()
Flowable that repeats the sequence of items emitted by the current Maybe indefinitely.
repeat does not operate by default on a particular Scheduler.Flowable instance@BackpressureSupport(value=FULL) @CheckReturnValue @SchedulerSupport(value="none") @NonNull public final @NonNull Flowable<T> repeat(long times)
Flowable that repeats the sequence of items emitted by the current Maybe at most
count times.
repeat does not operate by default on a particular Scheduler.times - the number of times the current Maybe items are repeated, a count of 0 will yield an empty
sequenceFlowable instanceIllegalArgumentException - if times is negative@BackpressureSupport(value=FULL) @CheckReturnValue @SchedulerSupport(value="none") @NonNull public final @NonNull Flowable<T> repeatUntil(@NonNull BooleanSupplier stop)
Flowable that repeats the sequence of items emitted by the current Maybe until
the provided stop function returns true.
repeatUntil does not operate by default on a particular Scheduler.stop - a boolean supplier that is called when the current Flowable completes and unless it returns
false, the current Flowable is resubscribedFlowable instanceNullPointerException - if stop is null@BackpressureSupport(value=FULL) @CheckReturnValue @SchedulerSupport(value="none") @NonNull public final @NonNull Flowable<T> repeatWhen(@NonNull Function<? super Flowable<Object>,? extends Publisher<?>> handler)
Flowable that emits the same values as the current Maybe with the exception of an
onComplete. An onComplete notification from the source will result in the emission of
a void item to the Flowable provided as an argument to the notificationHandler
function. If that Publisher calls onComplete or onError then repeatWhen will
call onComplete or onError on the child observer. Otherwise, this operator will
resubscribe to the current Maybe.
Publisher to honor backpressure as well.
If this expectation is violated, the operator may throw an IllegalStateException.repeatWhen does not operate by default on a particular Scheduler.handler - receives a Publisher of notifications with which a user can complete or error, aborting the repeat.Flowable instanceNullPointerException - if handler is null@CheckReturnValue @SchedulerSupport(value="none") @NonNull public final @NonNull Maybe<T> retry()
Maybe that mirrors the current Maybe, resubscribing to it if it calls onError
(infinite retry count).
If the current Maybe calls MaybeObserver.onError(java.lang.Throwable), this operator will resubscribe to the current
Maybe rather than propagating the onError call.
retry does not operate by default on a particular Scheduler.Maybe instance@CheckReturnValue @SchedulerSupport(value="none") @NonNull public final @NonNull Maybe<T> retry(@NonNull BiPredicate<? super Integer,? super Throwable> predicate)
Maybe that mirrors the current Maybe, resubscribing to it if it calls onError
and the predicate returns true for that specific exception and retry count.
retry does not operate by default on a particular Scheduler.predicate - the predicate that determines if a resubscription may happen in case of a specific exception
and retry countMaybe instanceNullPointerException - if predicate is nullretry(),
ReactiveX operators documentation: Retry@CheckReturnValue @SchedulerSupport(value="none") @NonNull public final @NonNull Maybe<T> retry(long times)
Maybe that mirrors the current Maybe, resubscribing to it if it calls onError
up to a specified number of retries.
If the current Maybe calls MaybeObserver.onError(java.lang.Throwable), this operator will resubscribe to the current
Maybe for a maximum of count resubscriptions rather than propagating the
onError call.
retry does not operate by default on a particular Scheduler.times - the number of times to resubscribe if the current Maybe failsMaybe instanceIllegalArgumentException - if times is negative@CheckReturnValue @SchedulerSupport(value="none") @NonNull public final @NonNull Maybe<T> retry(long times, @NonNull Predicate<? super Throwable> predicate)
times or until the predicate returns false, whichever happens first.
retry does not operate by default on a particular Scheduler.times - the number of times to resubscribe if the current Maybe failspredicate - the predicate called with the failure Throwable and should return true to trigger a retry.Maybe instanceNullPointerException - if predicate is nullIllegalArgumentException - if times is negative@CheckReturnValue @SchedulerSupport(value="none") @NonNull public final @NonNull Maybe<T> retry(@NonNull Predicate<? super Throwable> predicate)
Maybe if it fails and the predicate returns true.
retry does not operate by default on a particular Scheduler.predicate - the predicate that receives the failure Throwable and should return true to trigger a retry.Maybe instanceNullPointerException - if predicate is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final @NonNull Maybe<T> retryUntil(@NonNull BooleanSupplier stop)
true.
retryUntil does not operate by default on a particular Scheduler.stop - the function that should return true to stop retryingMaybe instanceNullPointerException - if stop is null@CheckReturnValue @SchedulerSupport(value="none") @NonNull public final @NonNull Maybe<T> retryWhen(@NonNull Function<? super Flowable<Throwable>,? extends Publisher<?>> handler)
Maybe that emits the same values as the current Maybe with the exception of an
onError. An onError notification from the source will result in the emission of a
Throwable item to the Flowable provided as an argument to the notificationHandler
function. If the returned Publisher calls onComplete or onError then retry will call
onComplete or onError on the child subscription. Otherwise, this operator will
resubscribe to the current Maybe.
Example: This retries 3 times, each time incrementing the number of seconds it waits.
Maybe.create((MaybeEmitter<? super String> s) -> {
System.out.println("subscribing");
s.onError(new RuntimeException("always fails"));
}, BackpressureStrategy.BUFFER).retryWhen(attempts -> {
return attempts.zipWith(Publisher.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);
Output is:
subscribing
delay retry by 1 second(s)
subscribing
delay retry by 2 second(s)
subscribing
delay retry by 3 second(s)
subscribing
Note that the inner Publisher returned by the handler function should signal
either onNext, onError or onComplete in response to the received
Throwable to indicate the operator should retry or terminate. If the upstream to
the operator is asynchronous, signalling onNext followed by onComplete immediately may
result in the sequence to be completed immediately. Similarly, if this inner
Publisher signals onError or onComplete while the upstream is
active, the sequence is terminated with the same signal immediately.
The following example demonstrates how to retry an asynchronous source with a delay:
Maybe.timer(1, TimeUnit.SECONDS)
.doOnSubscribe(s -> System.out.println("subscribing"))
.map(v -> { throw new RuntimeException(); })
.retryWhen(errors -> {
AtomicInteger counter = new AtomicInteger();
return errors
.takeWhile(e -> counter.getAndIncrement() != 3)
.flatMap(e -> {
System.out.println("delay retry by " + counter.get() + " second(s)");
return Flowable.timer(counter.get(), TimeUnit.SECONDS);
});
})
.blockingGet();
retryWhen does not operate by default on a particular Scheduler.handler - receives a Publisher of notifications with which a user can complete or error, aborting the
retryMaybe instanceNullPointerException - if handler is null@SchedulerSupport(value="none") public final void safeSubscribe(@NonNull MaybeObserver<? super T> observer)
MaybeObserver, catches any RuntimeExceptions thrown by its
MaybeObserver.onSubscribe(Disposable), MaybeObserver.onSuccess(Object),
MaybeObserver.onError(Throwable) or MaybeObserver.onComplete() methods
and routes those to the global error handler via RxJavaPlugins.onError(Throwable).
By default, the Maybe protocol forbids the onXXX methods to throw, but some
MaybeObserver implementation may do it anyway, causing undefined behavior in the
upstream. This method and the underlying safe wrapper ensures such misbehaving consumers don't
disrupt the protocol.
safeSubscribe does not operate by default on a particular Scheduler.observer - the potentially misbehaving MaybeObserverNullPointerException - if observer is nullsubscribe(Consumer,Consumer, Action)@CheckReturnValue @NonNull @SchedulerSupport(value="none") @BackpressureSupport(value=FULL) public final @NonNull Flowable<T> startWith(@NonNull CompletableSource other)
Flowable which first runs the other CompletableSource
then the current Maybe if the other completed normally.
Flowable honors the backpressure of the downstream consumer.startWith does not operate by default on a particular Scheduler.other - the other CompletableSource to run firstFlowable instanceNullPointerException - if other is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") @BackpressureSupport(value=FULL) public final @NonNull Flowable<T> startWith(@NonNull SingleSource<T> other)
Flowable which first runs the other SingleSource
then the current Maybe if the other succeeded normally.
Flowable honors the backpressure of the downstream consumer.startWith does not operate by default on a particular Scheduler.other - the other SingleSource to run firstFlowable instanceNullPointerException - if other is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") @BackpressureSupport(value=FULL) public final @NonNull Flowable<T> startWith(@NonNull MaybeSource<T> other)
Flowable which first runs the other MaybeSource
then the current Maybe if the other succeeded or completed normally.
Flowable honors the backpressure of the downstream consumer.startWith does not operate by default on a particular Scheduler.other - the other MaybeSource to run firstFlowable instanceNullPointerException - if other is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final @NonNull Observable<T> startWith(@NonNull ObservableSource<T> other)
Observable which first delivers the events
of the other ObservableSource then runs the current Maybe.
startWith does not operate by default on a particular Scheduler.other - the other ObservableSource to run firstObservable instanceNullPointerException - if other is null@CheckReturnValue @NonNull @BackpressureSupport(value=FULL) @SchedulerSupport(value="none") public final @NonNull Flowable<T> startWith(@NonNull Publisher<T> other)
Flowable which first delivers the events
of the other Publisher then runs the current Maybe.
Flowable honors the backpressure of the downstream consumer
and expects the other Publisher to honor it as well.startWith does not operate by default on a particular Scheduler.other - the other Publisher to run firstFlowable instanceNullPointerException - if other is null@SchedulerSupport(value="none") @NonNull public final @NonNull Disposable subscribe()
Maybe and ignores onSuccess and onComplete emissions.
If the Maybe emits an error, it is wrapped into an
OnErrorNotImplementedException
and routed to the RxJavaPlugins.onError(Throwable) handler.
subscribe does not operate by default on a particular Scheduler.Disposable instance that can be used for disposing the subscription at any timesubscribe(Consumer, Consumer, Action, DisposableContainer)@CheckReturnValue @SchedulerSupport(value="none") @NonNull public final @NonNull Disposable subscribe(@NonNull Consumer<? super T> onSuccess)
Maybe and provides a callback to handle the items it emits.
If the Maybe emits an error, it is wrapped into an
OnErrorNotImplementedException
and routed to the RxJavaPlugins.onError(Throwable) handler.
subscribe does not operate by default on a particular Scheduler.onSuccess - the Consumer<T> you have designed to accept a success value from the MaybeDisposable instance that can be used for disposing the subscription at any timeNullPointerException - if onSuccess is nullsubscribe(Consumer, Consumer, Action, DisposableContainer)@CheckReturnValue @SchedulerSupport(value="none") @NonNull public final @NonNull Disposable subscribe(@NonNull Consumer<? super T> onSuccess, @NonNull Consumer<? super Throwable> onError)
Maybe and provides callbacks to handle the items it emits and any error
notification it issues.
subscribe does not operate by default on a particular Scheduler.onSuccess - the Consumer<T> you have designed to accept a success value from the MaybeonError - the Consumer<Throwable> you have designed to accept any error notification from the
MaybeDisposable instance that can be used for disposing the subscription at any timeNullPointerException - if onSuccess is null, or
if onError is nullsubscribe(Consumer, Consumer, Action, DisposableContainer)@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final @NonNull Disposable subscribe(@NonNull Consumer<? super T> onSuccess, @NonNull Consumer<? super Throwable> onError, @NonNull Action onComplete)
Maybe and provides callbacks to handle the items it emits and any error or
completion notification it issues.
subscribe does not operate by default on a particular Scheduler.onSuccess - the Consumer<T> you have designed to accept a success value from the MaybeonError - the Consumer<Throwable> you have designed to accept any error notification from the
MaybeonComplete - the Action you have designed to accept a completion notification from the
MaybeDisposable instance that can be used for disposing the subscription at any timeNullPointerException - if onSuccess, onError or
onComplete is nullsubscribe(Consumer, Consumer, Action, DisposableContainer)@SchedulerSupport(value="none") @NonNull public final @NonNull Disposable subscribe(@NonNull Consumer<? super T> onSuccess, @NonNull Consumer<? super Throwable> onError, @NonNull Action onComplete, @NonNull DisposableContainer container)
Disposable MaybeObserver,
adds it to the given DisposableContainer and ensures, that if the upstream
terminates or this particular Disposable is disposed, the MaybeObserver is removed
from the given composite.
The MaybeObserver will be removed after the callback for the terminal event has been invoked.
subscribe does not operate by default on a particular Scheduler.onSuccess - the callback for upstream itemsonError - the callback for an upstream erroronComplete - the callback for an upstream completion without any value or errorcontainer - the DisposableContainer (such as CompositeDisposable) to add and remove the
created Disposable MaybeObserverDisposable that allows disposing the particular subscription.NullPointerException - if onSuccess, onError,
onComplete or container is null@SchedulerSupport(value="none") public final void subscribe(@NonNull MaybeObserver<? super T> observer)
MaybeSourceMaybeObserver to this MaybeSource instance.subscribe in interface MaybeSource<T>observer - the MaybeObserver, not nullprotected abstract void subscribeActual(@NonNull MaybeObserver<? super T> observer)
MaybeObservers.
There is no need to call any of the plugin hooks on the current Maybe instance or
the MaybeObserver; all hooks and basic safeguards have been
applied by subscribe(MaybeObserver) before this method gets called.
observer - the MaybeObserver to handle, not null@CheckReturnValue @NonNull @SchedulerSupport(value="custom") public final @NonNull Maybe<T> subscribeOn(@NonNull Scheduler scheduler)
Maybe on the specified Scheduler.
Scheduler this operator will use.scheduler - the Scheduler to perform subscription actions onMaybe instanceNullPointerException - if scheduler is nullobserveOn(io.reactivex.rxjava3.core.Scheduler)@CheckReturnValue @SchedulerSupport(value="none") @NonNull public final <E extends MaybeObserver<? super T>> E subscribeWith(E observer)
MaybeObserver (subclass) to this Maybe and returns the given
MaybeObserver as is.
Usage example:
Maybe<Integer> source = Maybe.just(1);
CompositeDisposable composite = new CompositeDisposable();
DisposableMaybeObserver<Integer> ds = new DisposableMaybeObserver<>() {
// ...
};
composite.add(source.subscribeWith(ds));
subscribeWith does not operate by default on a particular Scheduler.E - the type of the MaybeObserver to use and returnobserver - the MaybeObserver (subclass) to use and return, not nullobserverNullPointerException - if observer is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final @NonNull Maybe<T> switchIfEmpty(@NonNull MaybeSource<? extends T> other)
Maybe that emits the items emitted by the current Maybe or the items of an alternate
MaybeSource if the current Maybe is empty.
switchIfEmpty does not operate by default on a particular Scheduler.other - the alternate MaybeSource to subscribe to if the main does not emit any itemsMaybe instanceNullPointerException - if other is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final @NonNull Single<T> switchIfEmpty(@NonNull SingleSource<? extends T> other)
Single that emits the items emitted by the current Maybe or the item of an alternate
SingleSource if the current Maybe is empty.
switchIfEmpty does not operate by default on a particular Scheduler.History: 2.1.4 - experimental
other - the alternate SingleSource to subscribe to if the main does not emit any itemsSingle instanceNullPointerException - if other is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final <U> @NonNull Maybe<T> takeUntil(@NonNull MaybeSource<U> other)
Maybe that emits the items emitted by the current Maybe until a second MaybeSource
emits an item.
takeUntil does not operate by default on a particular Scheduler.U - the type of items emitted by otherother - the MaybeSource whose first emitted item will cause takeUntil to stop emitting items
from the current MaybeMaybe instanceNullPointerException - if other is null@BackpressureSupport(value=UNBOUNDED_IN) @CheckReturnValue @NonNull @SchedulerSupport(value="none") public final <U> @NonNull Maybe<T> takeUntil(@NonNull Publisher<U> other)
Maybe that emits the item emitted by the current Maybe until a second Publisher
emits an item.
Publisher is consumed in an unbounded fashion and is cancelled after the first item
emitted.takeUntil does not operate by default on a particular Scheduler.U - the type of items emitted by otherother - the Publisher whose first emitted item will cause takeUntil to stop emitting items
from the source PublisherMaybe instanceNullPointerException - if other is null@CheckReturnValue @NonNull @SchedulerSupport(value="io.reactivex:computation") public final @NonNull Maybe<Timed<T>> timeInterval()
Maybe and signals it as a tuple (Timed)
success value.
If the current Maybe is empty or fails, the resulting Maybe will
pass along the signals to the downstream. To measure the time to termination,
use materialize() and apply Single.timeInterval().
timeInterval uses the computation Scheduler
for determining the current time upon subscription and upon receiving the
success item from the current Maybe.Maybe instance@CheckReturnValue @NonNull @SchedulerSupport(value="custom") public final @NonNull Maybe<Timed<T>> timeInterval(@NonNull Scheduler scheduler)
Maybe and signals it as a tuple (Timed)
success value.
If the current Maybe is empty or fails, the resulting Maybe will
pass along the signals to the downstream. To measure the time to termination,
use materialize() and apply Single.timeInterval(Scheduler).
timeInterval uses the provided Scheduler
for determining the current time upon subscription and upon receiving the
success item from the current Maybe.scheduler - the Scheduler used for providing the current timeMaybe instanceNullPointerException - if scheduler is null@CheckReturnValue @NonNull @SchedulerSupport(value="io.reactivex:computation") public final @NonNull Maybe<Timed<T>> timeInterval(@NonNull TimeUnit unit)
Maybe and signals it as a tuple (Timed)
success value.
If the current Maybe is empty or fails, the resulting Maybe will
pass along the signals to the downstream. To measure the time to termination,
use materialize() and apply Single.timeInterval(TimeUnit).
timeInterval uses the computation Scheduler
for determining the current time upon subscription and upon receiving the
success item from the current Maybe.unit - the time unit for measurementMaybe instanceNullPointerException - if unit is null@CheckReturnValue @NonNull @SchedulerSupport(value="custom") public final @NonNull Maybe<Timed<T>> timeInterval(@NonNull TimeUnit unit, @NonNull Scheduler scheduler)
Maybe and signals it as a tuple (Timed)
success value.
If the current Maybe is empty or fails, the resulting Maybe will
pass along the signals to the downstream. To measure the time to termination,
use materialize() and apply Single.timeInterval(TimeUnit, Scheduler).
timeInterval uses the provided Scheduler
for determining the current time upon subscription and upon receiving the
success item from the current Maybe.unit - the time unit for measurementscheduler - the Scheduler used for providing the current timeMaybe instanceNullPointerException - if unit or scheduler is null@CheckReturnValue @NonNull @SchedulerSupport(value="io.reactivex:computation") public final @NonNull Maybe<Timed<T>> timestamp()
Maybe with the current time (in milliseconds) of
its reception, using the computation Scheduler as time source,
then signals them as a Timed instance.
If the current Maybe is empty or fails, the resulting Maybe will
pass along the signals to the downstream. To measure the time to termination,
use materialize() and apply Single.timestamp().
timestamp uses the computation Scheduler
for determining the current time upon receiving the
success item from the current Maybe.Maybe instance@CheckReturnValue @NonNull @SchedulerSupport(value="custom") public final @NonNull Maybe<Timed<T>> timestamp(@NonNull Scheduler scheduler)
Maybe with the current time (in milliseconds) of
its reception, using the given Scheduler as time source,
then signals them as a Timed instance.
If the current Maybe is empty or fails, the resulting Maybe will
pass along the signals to the downstream. To measure the time to termination,
use materialize() and apply Single.timestamp(Scheduler).
timestamp uses the provided Scheduler
for determining the current time upon receiving the
success item from the current Maybe.scheduler - the Scheduler used for providing the current timeMaybe instanceNullPointerException - if scheduler is null@CheckReturnValue @NonNull @SchedulerSupport(value="io.reactivex:computation") public final @NonNull Maybe<Timed<T>> timestamp(@NonNull TimeUnit unit)
Maybe with the current time of
its reception, using the computation Scheduler as time source,
then signals it as a Timed instance.
If the current Maybe is empty or fails, the resulting Maybe will
pass along the signals to the downstream. To measure the time to termination,
use materialize() and apply Single.timestamp(TimeUnit).
timestamp uses the computation Scheduler,
for determining the current time upon receiving the
success item from the current Maybe.unit - the time unit for measurementMaybe instanceNullPointerException - if unit is null@CheckReturnValue @NonNull @SchedulerSupport(value="custom") public final @NonNull Maybe<Timed<T>> timestamp(@NonNull TimeUnit unit, @NonNull Scheduler scheduler)
Maybe with the current time of
its reception, using the given Scheduler as time source,
then signals it as a Timed instance.
If the current Maybe is empty or fails, the resulting Maybe will
pass along the signals to the downstream. To measure the time to termination,
use materialize() and apply Single.timestamp(TimeUnit, Scheduler).
timestamp uses the provided Scheduler,
which is used for determining the current time upon receiving the
success item from the current Maybe.unit - the time unit for measurementscheduler - the Scheduler used for providing the current timeMaybe instanceNullPointerException - if unit or scheduler is null@CheckReturnValue @SchedulerSupport(value="io.reactivex:computation") @NonNull public final @NonNull Maybe<T> timeout(long timeout, @NonNull TimeUnit unit)
Maybe that mirrors the current Maybe but applies a timeout policy for each emitted
item. If the next item isn't emitted within the specified timeout duration starting from its predecessor,
the resulting Maybe terminates and notifies MaybeObservers of a TimeoutException.
timeout operates by default on the computation Scheduler.timeout - maximum duration between emitted items before a timeout occursunit - the unit of time that applies to the timeout argument.Maybe instanceNullPointerException - if unit is null@CheckReturnValue @NonNull @SchedulerSupport(value="io.reactivex:computation") public final @NonNull Maybe<T> timeout(long timeout, @NonNull TimeUnit unit, @NonNull MaybeSource<? extends T> fallback)
Maybe that mirrors the current Maybe but applies a timeout policy for each emitted
item. If the next item isn't emitted within the specified timeout duration starting from its predecessor,
the current Maybe is disposed and resulting Maybe begins instead to mirror a fallback MaybeSource.
timeout operates by default on the computation Scheduler.timeout - maximum duration between items before a timeout occursunit - the unit of time that applies to the timeout argumentfallback - the fallback MaybeSource to use in case of a timeoutMaybe instanceNullPointerException - if unit or fallback is null@CheckReturnValue @NonNull @SchedulerSupport(value="custom") public final @NonNull Maybe<T> timeout(long timeout, @NonNull TimeUnit unit, @NonNull Scheduler scheduler, @NonNull MaybeSource<? extends T> fallback)
Maybe that mirrors the current Maybe but applies a timeout policy for each emitted
item using a specified Scheduler. If the next item isn't emitted within the specified timeout duration
starting from its predecessor, the current Maybe is disposed and resulting Maybe begins instead
to mirror a fallback MaybeSource.
Scheduler this operator will use.timeout - maximum duration between items before a timeout occursunit - the unit of time that applies to the timeout argumentfallback - the MaybeSource to use as the fallback in case of a timeoutscheduler - the Scheduler to run the timeout timers onMaybe instanceNullPointerException - if fallback, unit or scheduler is null@CheckReturnValue @SchedulerSupport(value="custom") @NonNull public final @NonNull Maybe<T> timeout(long timeout, @NonNull TimeUnit unit, @NonNull Scheduler scheduler)
Maybe that mirrors the current Maybe but applies a timeout policy for each emitted
item, where this policy is governed on a specified Scheduler. If the next item isn't emitted within the
specified timeout duration starting from its predecessor, the resulting Maybe terminates and
notifies MaybeObservers of a TimeoutException.
Scheduler this operator will use.timeout - maximum duration between items before a timeout occursunit - the unit of time that applies to the timeout argumentscheduler - the Scheduler to run the timeout timers onMaybe instanceNullPointerException - if unit or scheduler is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final <U> @NonNull Maybe<T> timeout(@NonNull MaybeSource<U> timeoutIndicator)
Maybe didn't signal an event before the timeoutIndicator MaybeSource signals, a
TimeoutException is signaled instead.
timeout does not operate by default on a particular Scheduler.U - the value type of thetimeoutIndicator - the MaybeSource that indicates the timeout by signaling onSuccess
or onComplete.Maybe instanceNullPointerException - if timeoutIndicator is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final <U> @NonNull Maybe<T> timeout(@NonNull MaybeSource<U> timeoutIndicator, @NonNull MaybeSource<? extends T> fallback)
Maybe didn't signal an event before the timeoutIndicator MaybeSource signals,
the current Maybe is disposed and the fallback MaybeSource subscribed to
as a continuation.
timeout does not operate by default on a particular Scheduler.U - the value type of thetimeoutIndicator - the MaybeSource that indicates the timeout by signaling onSuccess
or onComplete.fallback - the MaybeSource that is subscribed to if the current Maybe times outMaybe instanceNullPointerException - if timeoutIndicator or fallback is null@BackpressureSupport(value=UNBOUNDED_IN) @CheckReturnValue @NonNull @SchedulerSupport(value="none") public final <U> @NonNull Maybe<T> timeout(@NonNull Publisher<U> timeoutIndicator)
Maybe source didn't signal an event before the timeoutIndicator Publisher signals, a
TimeoutException is signaled instead.
timeoutIndicator Publisher is consumed in an unbounded manner and
is cancelled after its first item.timeout does not operate by default on a particular Scheduler.U - the value type of thetimeoutIndicator - the Publisher that indicates the timeout by signaling onSuccess
or onComplete.Maybe instanceNullPointerException - if timeoutIndicator is null@BackpressureSupport(value=UNBOUNDED_IN) @CheckReturnValue @NonNull @SchedulerSupport(value="none") public final <U> @NonNull Maybe<T> timeout(@NonNull Publisher<U> timeoutIndicator, @NonNull MaybeSource<? extends T> fallback)
Maybe didn't signal an event before the timeoutIndicator Publisher signals,
the current Maybe is disposed and the fallback MaybeSource subscribed to
as a continuation.
timeoutIndicator Publisher is consumed in an unbounded manner and
is cancelled after its first item.timeout does not operate by default on a particular Scheduler.U - the value type of thetimeoutIndicator - the MaybeSource that indicates the timeout by signaling onSuccess
or onCompletefallback - the MaybeSource that is subscribed to if the current Maybe times outMaybe instanceNullPointerException - if timeoutIndicator or fallback is null@CheckReturnValue @NonNull @SchedulerSupport(value="custom") public final @NonNull Maybe<T> unsubscribeOn(@NonNull Scheduler scheduler)
Maybe which makes sure when a MaybeObserver disposes the Disposable,
that call is propagated up on the specified Scheduler.
unsubscribeOn calls dispose() of the upstream on the Scheduler you specify.scheduler - the target scheduler where to execute the disposalMaybe instanceNullPointerException - if scheduler is null@CheckReturnValue @NonNull @SchedulerSupport(value="none") public final <U,R> @NonNull Maybe<R> zipWith(@NonNull MaybeSource<? extends U> other, @NonNull BiFunction<? super T,? super U,? extends R> zipper)
MaybeSource signal a success value then applies the given BiFunction
to those values and emits the BiFunction's resulting value to downstream.
If either this or the other MaybeSource is empty or signals an error, the resulting Maybe will
terminate immediately and dispose the other source.
zipWith does not operate by default on a particular Scheduler.U - the type of items emitted by the other MaybeSourceR - the type of items emitted by the resulting Maybeother - the other MaybeSourcezipper - a function that combines the pairs of items from the two MaybeSources to generate the items to
be emitted by the resulting MaybeMaybe instanceNullPointerException - if other or zipper is null@CheckReturnValue @SchedulerSupport(value="none") @NonNull public final @NonNull TestObserver<T> test()
TestObserver and subscribes
it to this Maybe.
test does not operate by default on a particular Scheduler.TestObserver instance@CheckReturnValue @SchedulerSupport(value="none") @NonNull public final @NonNull TestObserver<T> test(boolean dispose)
TestObserver optionally in cancelled state, then subscribes it to this Maybe.
test does not operate by default on a particular Scheduler.dispose - if true, the TestObserver will be disposed before subscribing to this
Maybe.TestObserver instance@CheckReturnValue @SchedulerSupport(value="none") @NonNull public static <T> @NonNull Maybe<T> fromOptional(@NonNull Optional<T> optional)
just(Object)
or an empty optional into an empty() Maybe instance.
Note that the operator takes an already instantiated optional reference and does not
by any means create this original optional. If the optional is to be created per
consumer upon subscription, use defer(Supplier) around fromOptional:
Maybe.defer(() -> Maybe.fromOptional(createOptional()));
fromOptional does not operate by default on a particular Scheduler.T - the element type of the optional valueoptional - the optional value to convert into a MaybeMaybe instanceNullPointerException - if optional is nulljust(Object),
empty()@CheckReturnValue @SchedulerSupport(value="none") @NonNull public static <T> @NonNull Maybe<T> fromCompletionStage(@NonNull CompletionStage<T> stage)
CompletionStage-based asynchronous calculation.
Note that the operator takes an already instantiated, running or terminated CompletionStage.
If the CompletionStage is to be created per consumer upon subscription, use defer(Supplier)
around fromCompletionStage:
Maybe.defer(() -> Maybe.fromCompletionStage(createCompletionStage()));
If the CompletionStage completes with null, the resulting Maybe is completed via onComplete.
Canceling the flow can't cancel the execution of the CompletionStage because CompletionStage
itself doesn't support cancellation. Instead, the operator detaches from the CompletionStage.
fromCompletionStage does not operate by default on a particular Scheduler.T - the element type of the CompletionStagestage - the CompletionStage to convert to Maybe and signal its terminal value or errorMaybe instanceNullPointerException - if stage is null@CheckReturnValue @SchedulerSupport(value="none") @NonNull public final <R> @NonNull Maybe<R> mapOptional(@NonNull Function<? super T,Optional<? extends R>> mapper)
Optional and emits the contained item if not empty.
mapOptional does not operate by default on a particular Scheduler.R - the non-null output typemapper - the function that receives the upstream success item and should return a non-empty Optional
to emit as the success output or an empty Optional to complete the MaybeMaybe instanceNullPointerException - if mapper is nullmap(Function),
filter(Predicate)@CheckReturnValue @SchedulerSupport(value="none") @NonNull public final @NonNull CompletionStage<T> toCompletionStage()
NoSuchElementException if the upstream is empty) via
a CompletionStage.
The upstream can be canceled by converting the resulting CompletionStage into
CompletableFuture via CompletionStage.toCompletableFuture() and
calling CompletableFuture.cancel(boolean) on it.
The upstream will be also cancelled if the resulting CompletionStage is converted to and
completed manually by CompletableFuture.complete(Object) or CompletableFuture.completeExceptionally(Throwable).
CompletionStages don't have a notion of emptiness and allow nulls, therefore, one can either use
toCompletionStage(Object) with null or turn the upstream into a sequence of Optionals and
default to Optional.empty():
CompletionStage<Optional<T>> stage = source.map(Optional::of).toCompletionStage(Optional.empty());
toCompletionStage does not operate by default on a particular Scheduler.CompletionStage instancetoCompletionStage(Object)@CheckReturnValue @SchedulerSupport(value="none") @NonNull public final @NonNull CompletionStage<T> toCompletionStage(@Nullable T defaultItem)
CompletionStage.
The upstream can be canceled by converting the resulting CompletionStage into
CompletableFuture via CompletionStage.toCompletableFuture() and
calling CompletableFuture.cancel(boolean) on it.
The upstream will be also cancelled if the resulting CompletionStage is converted to and
completed manually by CompletableFuture.complete(Object) or CompletableFuture.completeExceptionally(Throwable).
CompletionStages don't have a notion of emptiness and allow nulls, therefore, one can either use
a defaultItem of null or turn the flow into a sequence of Optionals and default to Optional.empty():
CompletionStage<Optional<T>> stage = source.map(Optional::of).toCompletionStage(Optional.empty());
toCompletionStage does not operate by default on a particular Scheduler.defaultItem - the item to signal if the upstream is emptyCompletionStage instance@CheckReturnValue @SchedulerSupport(value="none") @BackpressureSupport(value=FULL) @NonNull public final <R> @NonNull Flowable<R> flattenStreamAsFlowable(@NonNull Function<? super T,? extends Stream<? extends R>> mapper)
Stream and emits its
items to the downstream consumer as a Flowable.
The operator closes the Stream upon cancellation and when it terminates. The exceptions raised when
closing a Stream are routed to the global error handler (RxJavaPlugins.onError(Throwable).
If a Stream should not be closed, turn it into an Iterable and use flattenAsFlowable(Function):
source.flattenAsFlowable(item -> createStream(item)::iterator);
Primitive streams are not supported and items have to be boxed manually (e.g., via IntStream.boxed()):
source.flattenStreamAsFlowable(item -> IntStream.rangeClosed(1, 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.
Stream
on demand (i.e., when requested).flattenStreamAsFlowable does not operate by default on a particular Scheduler.R - the element type of the Stream and the output Flowablemapper - the function that receives the upstream success item and should
return a Stream of values to emit.Flowable instanceNullPointerException - if mapper is nullflattenAsFlowable(Function),
flattenStreamAsObservable(Function)@CheckReturnValue @SchedulerSupport(value="none") @NonNull public final <R> @NonNull Observable<R> flattenStreamAsObservable(@NonNull Function<? super T,? extends Stream<? extends R>> mapper)
Stream and emits its
items to the downstream consumer as an Observable.
The operator closes the Stream upon cancellation and when it terminates. The exceptions raised when
closing a Stream are routed to the global error handler (RxJavaPlugins.onError(Throwable).
If a Stream should not be closed, turn it into an Iterable and use flattenAsObservable(Function):
source.flattenAsObservable(item -> createStream(item)::iterator);
Primitive streams are not supported and items have to be boxed manually (e.g., via IntStream.boxed()):
source.flattenStreamAsObservable(item -> IntStream.rangeClosed(1, 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.
flattenStreamAsObservable does not operate by default on a particular Scheduler.R - the element type of the Stream and the output Observablemapper - the function that receives the upstream success item and should
return a Stream of values to emit.Observable instanceNullPointerException - if mapper is nullflattenAsObservable(Function),
flattenStreamAsFlowable(Function)