T - the value typepublic abstract classMaybe<T>extendsObjectimplementsMaybeSource<T>
Maybe class represents a deferred computation and emission of a single value, no value at all or an exception. TheMaybe class implements theMaybeSource base interface and the default consumer type it interacts with is theMaybeObserver via thesubscribe(MaybeObserver) method.
TheMaybe operates with the following sequential protocol:
onSubscribe (onSuccess | onError | onComplete)? Note thatonSuccess,onError andonComplete are mutually exclusive events; unlikeObservable,onSuccess is never followed byonError oronComplete.
LikeObservable, a runningMaybe can be stopped through theDisposable instance provided to consumers throughMaybeObserver.onSubscribe(io.reactivex.rxjava3.disposables.Disposable).
Like anObservable, aMaybe is lazy, can be either "hot" or "cold", synchronous or asynchronous.Maybe instances returned by the methods of this class arecold and there is a standardhot implementation in the form of a subject:MaybeSubject.
The documentation for this class makes use of marble diagrams. The following legend explains these diagrams:

SeeFlowable orObservable for the implementation of the Reactive Pattern for a stream or vector of values.
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 viasubscribe(MaybeObserver) can't be disposed from the outside (hence thevoid return of thesubscribe(MaybeObserver) method) and it is the responsibility of the implementor of theMaybeObserver to allow this to happen. RxJava supports such usage with the standardDisposableMaybeObserver instance. For convenience, thesubscribeWith(MaybeObserver) method is provided as well to allow working with aMaybeObserver (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> @NonNullMaybe<T> | amb(@NonNullIterable<? extendsMaybeSource<? extends T>> sources)Runs multiple MaybeSources provided by anIterable sequence and signals the events of the first one that signals (disposing the rest). |
static <T> @NonNullMaybe<T> | ambArray(MaybeSource<? extends T>... sources)Runs multiple MaybeSources and signals the events of the first one that signals (disposing the rest). |
@NonNullMaybe<T> | ambWith(@NonNullMaybeSource<? extendsT> 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 andblocks the current thread until it terminates. |
void | blockingSubscribe(@NonNullConsumer<? superT> onSuccess)Subscribes to the current Maybe and calls givenonSuccess callback on thecurrent thread when it completes normally. |
void | blockingSubscribe(@NonNullConsumer<? superT> onSuccess,@NonNullConsumer<? superThrowable> onError)Subscribes to the current Maybe and calls the appropriate callback on thecurrent thread when it terminates. |
void | blockingSubscribe(@NonNullConsumer<? superT> onSuccess,@NonNullConsumer<? superThrowable> onError,@NonNullAction onComplete)Subscribes to the current Maybe and calls the appropriate callback on thecurrent thread when it terminates. |
void | blockingSubscribe(@NonNullMaybeObserver<? superT> observer)Subscribes to the current Maybe and calls the appropriateMaybeObserver method on thecurrent thread. |
@NonNullMaybe<T> | cache()Returns a Maybe that subscribes to thisMaybe lazily, caches its event and replays it, to all the downstream subscribers. |
<U> @NonNullMaybe<U> | cast(@NonNullClass<? extends U> clazz)Casts the success value of the current Maybe into the target type or signals aClassCastException if not compatible. |
<R> @NonNullMaybe<R> | compose(@NonNullMaybeTransformer<? superT,? extends R> transformer)Transform a Maybe by applying a particularMaybeTransformer function to it. |
static <T> @NonNullFlowable<T> | concat(@NonNullIterable<? extendsMaybeSource<? extends T>> sources)Concatenate the single values, in a non-overlapping fashion, of the MaybeSource sources provided by anIterable sequence as aFlowable sequence. |
static <T> @NonNullFlowable<T> | concat(@NonNullMaybeSource<? extends T> source1,@NonNullMaybeSource<? extends T> source2)Returns a Flowable that emits the items emitted by twoMaybeSources, one after the other. |
static <T> @NonNullFlowable<T> | concat(@NonNullMaybeSource<? extends T> source1,@NonNullMaybeSource<? extends T> source2,@NonNullMaybeSource<? extends T> source3)Returns a Flowable that emits the items emitted by threeMaybeSources, one after the other. |
static <T> @NonNullFlowable<T> | concat(@NonNullMaybeSource<? extends T> source1,@NonNullMaybeSource<? extends T> source2,@NonNullMaybeSource<? extends T> source3,@NonNullMaybeSource<? extends T> source4)Returns a Flowable that emits the items emitted by fourMaybeSources, one after the other. |
static <T> @NonNullFlowable<T> | concat(@NonNullPublisher<? extendsMaybeSource<? extends T>> sources)Concatenate the single values, in a non-overlapping fashion, of the MaybeSource sources provided by aPublisher sequence as aFlowable sequence. |
static <T> @NonNullFlowable<T> | concat(@NonNullPublisher<? extendsMaybeSource<? extends T>> sources, int prefetch)Concatenate the single values, in a non-overlapping fashion, of the MaybeSource sources provided by aPublisher sequence as aFlowable sequence. |
static <T> @NonNullFlowable<T> | concatArray(MaybeSource<? extends T>... sources)Concatenate the single values, in a non-overlapping fashion, of the MaybeSource sources in the array as aFlowable sequence. |
static <T> @NonNullFlowable<T> | concatArrayDelayError(MaybeSource<? extends T>... sources)Concatenates a variable number of MaybeSource sources and delays errors from any of them till all terminate as aFlowable sequence. |
static <T> @NonNullFlowable<T> | concatArrayEager(MaybeSource<? extends T>... sources)Concatenates a sequence of MaybeSource eagerly into aFlowable sequence. |
static <T> @NonNullFlowable<T> | concatArrayEagerDelayError(MaybeSource<? extends T>... sources)Concatenates a sequence of MaybeSource eagerly into aFlowable sequence. |
static <T> @NonNullFlowable<T> | concatDelayError(@NonNullIterable<? extendsMaybeSource<? extends T>> sources)Concatenates the Iterable sequence ofMaybeSources into a single sequence by subscribing to eachMaybeSource, one after the other, one at a time and delays any errors till the all innerMaybeSources terminate as aFlowable sequence. |
static <T> @NonNullFlowable<T> | concatDelayError(@NonNullPublisher<? extendsMaybeSource<? extends T>> sources)Concatenates the Publisher sequence ofMaybeSources into a single sequence by subscribing to each innerMaybeSource, one after the other, one at a time and delays any errors till the all inner and the outerPublisher terminate as aFlowable sequence. |
static <T> @NonNullFlowable<T> | concatDelayError(@NonNullPublisher<? extendsMaybeSource<? extends T>> sources, int prefetch)Concatenates the Publisher sequence ofMaybeSources into a single sequence by subscribing to each innerMaybeSource, one after the other, one at a time and delays any errors till the all inner and the outerPublisher terminate as aFlowable sequence. |
static <T> @NonNullFlowable<T> | concatEager(@NonNullIterable<? extendsMaybeSource<? extends T>> sources)Concatenates a sequence of MaybeSources eagerly into aFlowable sequence. |
static <T> @NonNullFlowable<T> | concatEager(@NonNullIterable<? extendsMaybeSource<? extends T>> sources, int maxConcurrency)Concatenates a sequence of MaybeSources eagerly into aFlowable sequence and runs a limited number of the inner sequences at once. |
static <T> @NonNullFlowable<T> | concatEager(@NonNullPublisher<? extendsMaybeSource<? extends T>> sources) |
static <T> @NonNullFlowable<T> | concatEager(@NonNullPublisher<? extendsMaybeSource<? extends T>> sources, int maxConcurrency)Concatenates a Publisher sequence ofMaybeSources eagerly into aFlowable sequence, running at most the given number of innerMaybeSources at once. |
static <T> @NonNullFlowable<T> | concatEagerDelayError(@NonNullIterable<? extendsMaybeSource<? extends T>> sources)Concatenates a sequence of MaybeSources eagerly into aFlowable sequence, delaying errors until all innerMaybeSources terminate. |
static <T> @NonNullFlowable<T> | concatEagerDelayError(@NonNullIterable<? extendsMaybeSource<? extends T>> sources, int maxConcurrency)Concatenates a sequence of MaybeSources eagerly into aFlowable sequence, delaying errors until all innerMaybeSources terminate and runs a limited number of innerMaybeSources at once. |
static <T> @NonNullFlowable<T> | concatEagerDelayError(@NonNullPublisher<? extendsMaybeSource<? extends T>> sources)Concatenates a Publisher sequence ofMaybeSources eagerly into aFlowable sequence, delaying errors until all the inner and the outer sequence terminate. |
static <T> @NonNullFlowable<T> | concatEagerDelayError(@NonNullPublisher<? extendsMaybeSource<? extends T>> sources, int maxConcurrency)Concatenates a Publisher sequence ofMaybeSources eagerly into aFlowable sequence, delaying errors until all the inner and the outer sequence terminate and runs a limited number of the innerMaybeSources at once. |
<R> @NonNullMaybe<R> | concatMap(@NonNullFunction<? superT,? extendsMaybeSource<? extends R>> mapper)Returns a Maybe that is based on applying a specified function to the item emitted by the currentMaybe, where that function returns aMaybeSource. |
@NonNullCompletable | concatMapCompletable(@NonNullFunction<? superT,? extendsCompletableSource> mapper)Returns a Completable that completes based on applying a specified function to the item emitted by the currentMaybe, where that function returns aCompletable. |
<R> @NonNullMaybe<R> | concatMapSingle(@NonNullFunction<? superT,? extendsSingleSource<? extends R>> mapper)Returns a Maybe based on applying a specified function to the item emitted by the currentMaybe, where that function returns aSingle. |
@NonNullFlowable<T> | concatWith(@NonNullMaybeSource<? extendsT> other)Returns a Flowable that emits the items emitted from the currentMaybe, then theotherMaybeSource, one after the other, without interleaving them. |
@NonNullSingle<Boolean> | contains(@NonNullObject item) |
@NonNullSingle<Long> | count() |
static <T> @NonNullMaybe<T> | create(@NonNullMaybeOnSubscribe<T> onSubscribe)Provides an API (via a cold Maybe) that bridges the reactive world with the callback-style world. |
@NonNullSingle<T> | defaultIfEmpty(T defaultItem)Returns a Single that emits the item emitted by the currentMaybe or a specified default item if the currentMaybe is empty. |
static <T> @NonNullMaybe<T> | defer(@NonNullSupplier<? extendsMaybeSource<? extends T>> supplier)Calls a Supplier for each individualMaybeObserver to return the actualMaybeSource source to be subscribed to. |
@NonNullMaybe<T> | delay(long time,@NonNullTimeUnit unit)Returns a Maybe that signals the events emitted by the currentMaybe shifted forward in time by a specified delay. |
@NonNullMaybe<T> | delay(long time,@NonNullTimeUnit unit, boolean delayError)Returns a Maybe that signals the events emitted by the currentMaybe shifted forward in time by a specified delay. |
@NonNullMaybe<T> | delay(long time,@NonNullTimeUnit unit,@NonNullScheduler scheduler)Returns a Maybe that signals the events emitted by the currentMaybe shifted forward in time by a specified delay. |
@NonNullMaybe<T> | delay(long time,@NonNullTimeUnit unit,@NonNullScheduler scheduler, boolean delayError)Returns a Maybe that signals the events emitted by the currentMaybe shifted forward in time by a specified delay running on the specifiedScheduler. |
<U> @NonNullMaybe<T> | delay(@NonNullPublisher<U> delayIndicator)Delays the emission of this Maybe until the givenPublisher signals an item or completes. |
@NonNullMaybe<T> | delaySubscription(long time,@NonNullTimeUnit unit)Returns a Maybe that delays the subscription to the currentMaybe by a given amount of time. |
@NonNullMaybe<T> | delaySubscription(long time,@NonNullTimeUnit unit,@NonNullScheduler scheduler)Returns a Maybe that delays the subscription to the currentMaybe by a given amount of time, both waiting and subscribing on a givenScheduler. |
<U> @NonNullMaybe<T> | delaySubscription(@NonNullPublisher<U> subscriptionIndicator)Returns a Maybe that delays the subscription to thisMaybe until the otherPublisher emits an element or completes normally. |
<R> @NonNullMaybe<R> | dematerialize(@NonNullFunction<? superT,Notification<R>> selector)Maps the Notification success value of the currentMaybe back into normalonSuccess,onError oronComplete signals. |
@NonNullMaybe<T> | doAfterSuccess(@NonNullConsumer<? superT> onAfterSuccess)Calls the specified Consumer with the success item after this item has been emitted to the downstream. |
@NonNullMaybe<T> | doAfterTerminate(@NonNullAction onAfterTerminate) |
@NonNullMaybe<T> | doFinally(@NonNullAction onFinally)Calls the specified action after this Maybe signalsonSuccess,onError oronComplete or gets disposed by the downstream. |
@NonNullMaybe<T> | doOnComplete(@NonNullAction onComplete) |
@NonNullMaybe<T> | doOnDispose(@NonNullAction onDispose)Calls the shared Action if aMaybeObserver subscribed to the currentMaybe disposes the commonDisposable it received viaonSubscribe. |
@NonNullMaybe<T> | doOnError(@NonNullConsumer<? superThrowable> onError)Calls the shared Consumer with the error sent viaonError for eachMaybeObserver that subscribes to the currentMaybe. |
@NonNullMaybe<T> | doOnEvent(@NonNullBiConsumer<? superT,? superThrowable> onEvent)Calls the given onEvent callback with the (success value,null) for anonSuccess, (null, throwable) for anonError or (null,null) for anonComplete signal from thisMaybe before delivering said signal to the downstream. |
@NonNullMaybe<T> | doOnLifecycle(@NonNullConsumer<? superDisposable> onSubscribe,@NonNullAction onDispose)Calls the appropriate onXXX method (shared between allMaybeObservers) for the lifecycle events of the sequence (subscription, disposal). |
@NonNullMaybe<T> | doOnSubscribe(@NonNullConsumer<? superDisposable> onSubscribe)Calls the shared Consumer with theDisposable sent through theonSubscribe for eachMaybeObserver that subscribes to the currentMaybe. |
@NonNullMaybe<T> | doOnSuccess(@NonNullConsumer<? superT> onSuccess)Calls the shared Consumer with the success value sent viaonSuccess for eachMaybeObserver that subscribes to the currentMaybe. |
@NonNullMaybe<T> | doOnTerminate(@NonNullAction onTerminate)Returns a Maybe instance that calls the given onTerminate callback just before thisMaybe completes normally or with an exception. |
static <T> @NonNullMaybe<T> | empty()Returns a (singleton) Maybe instance that callsonComplete immediately. |
static <T> @NonNullMaybe<T> | error(@NonNullSupplier<? extendsThrowable> supplier) |
static <T> @NonNullMaybe<T> | error(@NonNullThrowable throwable)Returns a Maybe that invokes a subscriber'sonError method when the subscriber subscribes to it. |
@NonNullMaybe<T> | filter(@NonNullPredicate<? superT> predicate)Filters the success item of the Maybe via a predicate function and emitting it if the predicate returnstrue, completing otherwise. |
<R> @NonNullMaybe<R> | flatMap(@NonNullFunction<? superT,? extendsMaybeSource<? extends R>> mapper)Returns a Maybe that is based on applying a specified function to the item emitted by the currentMaybe, where that function returns aMaybeSource. |
<R> @NonNullMaybe<R> | flatMap(@NonNullFunction<? superT,? extendsMaybeSource<? extends R>> onSuccessMapper,@NonNullFunction<? superThrowable,? extendsMaybeSource<? extends R>> onErrorMapper,@NonNullSupplier<? extendsMaybeSource<? extends R>> onCompleteSupplier)Maps the onSuccess,onError oronComplete signals of the currentMaybe into aMaybeSource and emits thatMaybeSource's signals. |
<U,R> @NonNullMaybe<R> | flatMap(@NonNullFunction<? superT,? extendsMaybeSource<? extends U>> mapper,@NonNullBiFunction<? superT,? super U,? extends R> combiner)Returns a Maybe that emits the results of a specified function to the pair of values emitted by the currentMaybe and a specified mappedMaybeSource. |
@NonNullCompletable | flatMapCompletable(@NonNullFunction<? superT,? extendsCompletableSource> mapper)Returns a Completable that completes based on applying a specified function to the item emitted by the currentMaybe, where that function returns aCompletable. |
<R> @NonNullObservable<R> | flatMapObservable(@NonNullFunction<? superT,? extendsObservableSource<? extends R>> mapper)Returns an Observable that is based on applying a specified function to the item emitted by the currentMaybe, where that function returns anObservableSource. |
<R> @NonNullFlowable<R> | flatMapPublisher(@NonNullFunction<? superT,? extendsPublisher<? extends R>> mapper) |
<R> @NonNullMaybe<R> | flatMapSingle(@NonNullFunction<? superT,? extendsSingleSource<? extends R>> mapper)Returns a Maybe based on applying a specified function to the item emitted by the currentMaybe, where that function returns aSingle. |
<U> @NonNullFlowable<U> | flattenAsFlowable(@NonNullFunction<? superT,? extendsIterable<? extends U>> mapper) |
<U> @NonNullObservable<U> | flattenAsObservable(@NonNullFunction<? superT,? extendsIterable<? extends U>> mapper)Maps the success value of the current Maybe into anIterable and emits its items as anObservable sequence. |
<R> @NonNullFlowable<R> | flattenStreamAsFlowable(@NonNullFunction<? superT,? extendsStream<? extends R>> mapper) |
<R> @NonNullObservable<R> | flattenStreamAsObservable(@NonNullFunction<? superT,? extendsStream<? extends R>> mapper)Maps the upstream succecss value into a Java Stream and emits its items to the downstream consumer as anObservable. |
static <T> @NonNullMaybe<T> | fromAction(@NonNullAction action)Returns a Maybe instance that runs the givenAction for eachMaybeObserver and emits either its exception or simply completes. |
static <T> @NonNullMaybe<T> | fromCallable(@NonNullCallable<? extends T> callable)Returns a Maybe that invokes the givenCallable for each individualMaybeObserver that subscribes and emits the resulting non-null item viaonSuccess while considering anull result from theCallable as indication for valueless completion viaonComplete. |
static <T> @NonNullMaybe<T> | fromCompletable(@NonNullCompletableSource completableSource)Wraps a CompletableSource into aMaybe. |
static <T> @NonNullMaybe<T> | fromCompletionStage(@NonNullCompletionStage<T> stage)Signals the completion value or error of the given (hot) CompletionStage-based asynchronous calculation. |
static <T> @NonNullMaybe<T> | fromFuture(@NonNullFuture<? extends T> future) |
static <T> @NonNullMaybe<T> | fromFuture(@NonNullFuture<? extends T> future, long timeout,@NonNullTimeUnit unit) |
static <T> @NonNullMaybe<T> | fromObservable(@NonNullObservableSource<T> source)Wraps an ObservableSource into aMaybe and emits the very first item or completes if the source is empty. |
static <T> @NonNullMaybe<T> | fromOptional(@NonNullOptional<T> optional)Converts the existing value of the provided optional into a just(Object) or an empty optional into anempty()Maybe instance. |
static <T> @NonNullMaybe<T> | fromPublisher(@NonNullPublisher<T> source)Wraps a Publisher into aMaybe and emits the very first item or completes if the source is empty. |
static <T> @NonNullMaybe<T> | fromRunnable(@NonNullRunnable run)Returns a Maybe instance that runs the givenRunnable for eachMaybeObserver and emits either its unchecked exception or simply completes. |
static <T> @NonNullMaybe<T> | fromSingle(@NonNullSingleSource<T> single)Wraps a SingleSource into aMaybe. |
static <T> @NonNullMaybe<T> | fromSupplier(@NonNullSupplier<? extends T> supplier)Returns a Maybe that invokes the givenSupplier for each individualMaybeObserver that subscribes and emits the resulting non-null item viaonSuccess while considering anull result from theSupplier as indication for valueless completion viaonComplete. |
@NonNullMaybe<T> | hide()Hides the identity of this Maybe and itsDisposable. |
@NonNullCompletable | ignoreElement()Returns a Completable that ignores the item emitted by the currentMaybe and only callsonComplete oronError. |
@NonNullSingle<Boolean> | isEmpty() |
static <T> @NonNullMaybe<T> | just(T item)Returns a Maybe that emits a specified item. |
<R> @NonNullMaybe<R> | lift(@NonNullMaybeOperator<? extends R,? superT> lift)This method requires advanced knowledge about building operators, please consider other standard composition methods first; Returns a Maybe which, when subscribed to, invokes theapply(MaybeObserver) method of the providedMaybeOperator for each individual downstreamMaybe and allows the insertion of a custom operator by accessing the downstream'sMaybeObserver during this subscription phase and providing a newMaybeObserver, containing the custom operator's intended business logic, that will be used in the subscription process going further upstream. |
<R> @NonNullMaybe<R> | map(@NonNullFunction<? superT,? extends R> mapper)Returns a Maybe that applies a specified function to the item emitted by the currentMaybe and emits the result of this function application. |
<R> @NonNullMaybe<R> | mapOptional(@NonNullFunction<? superT,Optional<? extends R>> mapper)Maps the upstream success value into an Optional and emits the contained item if not empty. |
@NonNullSingle<Notification<T>> | materialize()Maps the signal types of this Maybe into aNotification of the same kind and emits it as aSingle'sonSuccess value to downstream. |
static <T> @NonNullFlowable<T> | merge(@NonNullIterable<? extendsMaybeSource<? extends T>> sources)Merges an Iterable sequence ofMaybeSource instances into a singleFlowable sequence, running allMaybeSources at once. |
static <T> @NonNullMaybe<T> | merge(@NonNullMaybeSource<? extendsMaybeSource<? extends T>> source)Flattens a MaybeSource that emits aMaybeSource into a singleMaybeSource that emits the item emitted by the nestedMaybeSource, without any transformation. |
static <T> @NonNullFlowable<T> | merge(@NonNullMaybeSource<? extends T> source1,@NonNullMaybeSource<? extends T> source2)Flattens two MaybeSources into a singleFlowable, without any transformation. |
static <T> @NonNullFlowable<T> | merge(@NonNullMaybeSource<? extends T> source1,@NonNullMaybeSource<? extends T> source2,@NonNullMaybeSource<? extends T> source3)Flattens three MaybeSources into a singleFlowable, without any transformation. |
static <T> @NonNullFlowable<T> | merge(@NonNullMaybeSource<? extends T> source1,@NonNullMaybeSource<? extends T> source2,@NonNullMaybeSource<? extends T> source3,@NonNullMaybeSource<? extends T> source4)Flattens four MaybeSources into a singleFlowable, without any transformation. |
static <T> @NonNullFlowable<T> | merge(@NonNullPublisher<? extendsMaybeSource<? extends T>> sources)Merges a Publisher sequence ofMaybeSource instances into a singleFlowable sequence, running allMaybeSources at once. |
static <T> @NonNullFlowable<T> | merge(@NonNullPublisher<? extendsMaybeSource<? extends T>> sources, int maxConcurrency)Merges a Publisher sequence ofMaybeSource instances into a singleFlowable sequence, running at most maxConcurrencyMaybeSources at once. |
static <T> @NonNullFlowable<T> | mergeArray(MaybeSource<? extends T>... sources)Merges an array of MaybeSource instances into a singleFlowable sequence, running allMaybeSources at once. |
static <T> @NonNullFlowable<T> | mergeArrayDelayError(MaybeSource<? extends T>... sources)Flattens an array of MaybeSources into oneFlowable, in a way that allows a subscriber to receive all successfully emitted items from each of the sourceMaybeSources without being interrupted by an error notification from one of them. |
static <T> @NonNullFlowable<T> | mergeDelayError(@NonNullIterable<? extendsMaybeSource<? extends T>> sources)Flattens an Iterable sequence ofMaybeSources into oneFlowable, in a way that allows a subscriber to receive all successfully emitted items from each of the sourceMaybeSources without being interrupted by an error notification from one of them. |
static <T> @NonNullFlowable<T> | mergeDelayError(@NonNullMaybeSource<? extends T> source1,@NonNullMaybeSource<? extends T> source2)Flattens two MaybeSources into oneFlowable, in a way that allows a subscriber to receive all successfully emitted items from each of the sourceMaybeSources without being interrupted by an error notification from one of them. |
static <T> @NonNullFlowable<T> | mergeDelayError(@NonNullMaybeSource<? extends T> source1,@NonNullMaybeSource<? extends T> source2,@NonNullMaybeSource<? extends T> source3)Flattens three MaybeSource into oneFlowable, in a way that allows a subscriber to receive all successfully emitted items from all of the sourceMaybeSources without being interrupted by an error notification from one of them. |
static <T> @NonNullFlowable<T> | mergeDelayError(@NonNullMaybeSource<? extends T> source1,@NonNullMaybeSource<? extends T> source2,@NonNullMaybeSource<? extends T> source3,@NonNullMaybeSource<? extends T> source4)Flattens four MaybeSources into oneFlowable, in a way that allows a subscriber to receive all successfully emitted items from all of the sourceMaybeSources without being interrupted by an error notification from one of them. |
static <T> @NonNullFlowable<T> | mergeDelayError(@NonNullPublisher<? extendsMaybeSource<? extends T>> sources)Flattens a Publisher that emitsMaybeSources into oneFlowable, in a way that allows a subscriber to receive all successfully emitted items from all of the sourceMaybeSources without being interrupted by an error notification from one of them or even the mainPublisher. |
static <T> @NonNullFlowable<T> | mergeDelayError(@NonNullPublisher<? extendsMaybeSource<? extends T>> sources, int maxConcurrency)Flattens a Publisher that emitsMaybeSources into oneFlowable, in a way that allows a subscriber to receive all successfully emitted items from all of the sourceMaybeSources without being interrupted by an error notification from one of them or even the mainPublisher as well as limiting the total number of activeMaybeSources. |
@NonNullFlowable<T> | mergeWith(@NonNullMaybeSource<? extendsT> other) |
static <T> @NonNullMaybe<T> | never()Returns a Maybe that never sends any items or notifications to aMaybeObserver. |
@NonNullMaybe<T> | observeOn(@NonNullScheduler scheduler)Wraps a Maybe to emit its item (or notify of its error) on a specifiedScheduler, asynchronously. |
<U> @NonNullMaybe<U> | ofType(@NonNullClass<U> clazz)Filters the items emitted by the current Maybe, only emitting its success value if that is an instance of the suppliedClass. |
@NonNullMaybe<T> | onErrorComplete()Returns a Maybe instance that if thisMaybe emits an error, it will emit anonComplete and swallow the throwable. |
@NonNullMaybe<T> | onErrorComplete(@NonNullPredicate<? superThrowable> predicate)Returns a Maybe instance that if thisMaybe emits an error and the predicate returnstrue, it will emit anonComplete and swallow the throwable. |
@NonNullMaybe<T> | onErrorResumeNext(@NonNullFunction<? superThrowable,? extendsMaybeSource<? extendsT>> fallbackSupplier)Resumes the flow with a MaybeSource returned for the failureThrowable of the currentMaybe by a function instead of signaling the error viaonError. |
@NonNullMaybe<T> | onErrorResumeWith(@NonNullMaybeSource<? extendsT> fallback)Resumes the flow with the given MaybeSource when the currentMaybe fails instead of signaling the error viaonError. |
@NonNullMaybe<T> | onErrorReturn(@NonNullFunction<? superThrowable,? extendsT> itemSupplier)Ends the flow with a success item returned by a function for the Throwable error signaled by the currentMaybe instead of signaling the error viaonError. |
@NonNullMaybe<T> | onErrorReturnItem(T item)Ends the flow with the given success item when the current Maybe fails instead of signaling the error viaonError. |
@NonNullMaybe<T> | onTerminateDetach()Nulls out references to the upstream producer and downstream MaybeObserver if the sequence is terminated or downstream callsdispose(). |
@NonNullFlowable<T> | repeat()Returns a Flowable that repeats the sequence of items emitted by the currentMaybe indefinitely. |
@NonNullFlowable<T> | repeat(long times)Returns a Flowable that repeats the sequence of items emitted by the currentMaybe at mostcount times. |
@NonNullFlowable<T> | repeatUntil(@NonNullBooleanSupplier stop)Returns a Flowable that repeats the sequence of items emitted by the currentMaybe until the provided stop function returnstrue. |
@NonNullFlowable<T> | repeatWhen(@NonNullFunction<? superFlowable<Object>,? extendsPublisher<?>> handler)Returns a Flowable that emits the same values as the currentMaybe with the exception of anonComplete. |
@NonNullMaybe<T> | retry()Returns a Maybe that mirrors the currentMaybe, resubscribing to it if it callsonError (infinite retry count). |
@NonNullMaybe<T> | retry(@NonNullBiPredicate<? superInteger,? superThrowable> predicate)Returns a Maybe that mirrors the currentMaybe, resubscribing to it if it callsonError and the predicate returnstrue for that specific exception and retry count. |
@NonNullMaybe<T> | retry(long times)Returns a Maybe that mirrors the currentMaybe, resubscribing to it if it callsonError up to a specified number of retries. |
@NonNullMaybe<T> | retry(long times,@NonNullPredicate<? superThrowable> predicate)Retries at most times or until the predicate returnsfalse, whichever happens first. |
@NonNullMaybe<T> | retry(@NonNullPredicate<? superThrowable> predicate)Retries the current Maybe if it fails and the predicate returnstrue. |
@NonNullMaybe<T> | retryUntil(@NonNullBooleanSupplier stop)Retries until the given stop function returns true. |
@NonNullMaybe<T> | retryWhen(@NonNullFunction<? superFlowable<Throwable>,? extendsPublisher<?>> handler)Returns a Maybe that emits the same values as the currentMaybe with the exception of anonError. |
void | safeSubscribe(@NonNullMaybeObserver<? superT> observer)Wraps the given MaybeObserver, catches anyRuntimeExceptions thrown by itsMaybeObserver.onSubscribe(Disposable),MaybeObserver.onSuccess(Object),MaybeObserver.onError(Throwable) orMaybeObserver.onComplete() methods and routes those to the global error handler viaRxJavaPlugins.onError(Throwable). |
static <T> @NonNullSingle<Boolean> | sequenceEqual(@NonNullMaybeSource<? extends T> source1,@NonNullMaybeSource<? extends T> source2)Returns a Single that emits aBoolean value that indicates whether twoMaybeSource sequences are the same by comparing the items emitted by eachMaybeSource pairwise. |
static <T> @NonNullSingle<Boolean> | sequenceEqual(@NonNullMaybeSource<? extends T> source1,@NonNullMaybeSource<? extends T> source2,@NonNullBiPredicate<? super T,? super T> isEqual)Returns a Single that emits aBoolean value that indicates whether twoMaybeSources are the same by comparing the items emitted by eachMaybeSource pairwise based on the results of a specified equality function. |
@NonNullFlowable<T> | startWith(@NonNullCompletableSource other)Returns a Flowable which first runs the otherCompletableSource then the currentMaybe if the other completed normally. |
@NonNullFlowable<T> | startWith(@NonNullMaybeSource<T> other)Returns a Flowable which first runs the otherMaybeSource then the currentMaybe if the other succeeded or completed normally. |
@NonNullObservable<T> | startWith(@NonNullObservableSource<T> other)Returns an Observable which first delivers the events of the otherObservableSource then runs the currentMaybe. |
@NonNullFlowable<T> | startWith(@NonNullPublisher<T> other) |
@NonNullFlowable<T> | startWith(@NonNullSingleSource<T> other)Returns a Flowable which first runs the otherSingleSource then the currentMaybe if the other succeeded normally. |
@NonNullDisposable | subscribe()Subscribes to a Maybe and ignoresonSuccess andonComplete emissions. |
@NonNullDisposable | subscribe(@NonNullConsumer<? superT> onSuccess)Subscribes to a Maybe and provides a callback to handle the items it emits. |
@NonNullDisposable | subscribe(@NonNullConsumer<? superT> onSuccess,@NonNullConsumer<? superThrowable> onError)Subscribes to a Maybe and provides callbacks to handle the items it emits and any error notification it issues. |
@NonNullDisposable | subscribe(@NonNullConsumer<? superT> onSuccess,@NonNullConsumer<? superThrowable> onError,@NonNullAction onComplete)Subscribes to a Maybe and provides callbacks to handle the items it emits and any error or completion notification it issues. |
@NonNullDisposable | subscribe(@NonNullConsumer<? superT> onSuccess,@NonNullConsumer<? superThrowable> onError,@NonNullAction onComplete,@NonNullDisposableContainer container)Wraps the given onXXX callbacks into a DisposableMaybeObserver, adds it to the givenDisposableContainer and ensures, that if the upstream terminates or this particularDisposable is disposed, theMaybeObserver is removed from the given composite. |
void | subscribe(@NonNullMaybeObserver<? superT> observer)Subscribes the given MaybeObserver to thisMaybeSource instance. |
protected abstract void | subscribeActual(@NonNullMaybeObserver<? superT> observer)Implement this method in subclasses to handle the incoming MaybeObservers. |
@NonNullMaybe<T> | subscribeOn(@NonNullScheduler scheduler)Asynchronously subscribes subscribers to this Maybe on the specifiedScheduler. |
<E extendsMaybeObserver<? superT>> | subscribeWith(E observer) |
@NonNullMaybe<T> | switchIfEmpty(@NonNullMaybeSource<? extendsT> other)Returns a Maybe that emits the items emitted by the currentMaybe or the items of an alternateMaybeSource if the currentMaybe is empty. |
@NonNullSingle<T> | switchIfEmpty(@NonNullSingleSource<? extendsT> other)Returns a Single that emits the items emitted by the currentMaybe or the item of an alternateSingleSource if the currentMaybe is empty. |
static <T> @NonNullFlowable<T> | switchOnNext(@NonNullPublisher<? extendsMaybeSource<? extends T>> sources)Switches between MaybeSources emitted by the sourcePublisher whenever a newMaybeSource is emitted, disposing the previously runningMaybeSource, exposing the success items as aFlowable sequence. |
static <T> @NonNullFlowable<T> | switchOnNextDelayError(@NonNullPublisher<? extendsMaybeSource<? extends T>> sources)Switches between MaybeSources emitted by the sourcePublisher whenever a newMaybeSource is emitted, disposing the previously runningMaybeSource, exposing the success items as aFlowable sequence and delaying all errors from all of them until all terminate. |
<U> @NonNullMaybe<T> | takeUntil(@NonNullMaybeSource<U> other)Returns a Maybe that emits the items emitted by the currentMaybe until a secondMaybeSource emits an item. |
<U> @NonNullMaybe<T> | takeUntil(@NonNullPublisher<U> other)Returns a Maybe that emits the item emitted by the currentMaybe until a secondPublisher emits an item. |
@NonNullTestObserver<T> | test()Creates a TestObserver and subscribes it to thisMaybe. |
@NonNullTestObserver<T> | test(boolean dispose)Creates a TestObserver optionally in cancelled state, then subscribes it to thisMaybe. |
@NonNullMaybe<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. |
@NonNullMaybe<Timed<T>> | timeInterval(@NonNullScheduler 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. |
@NonNullMaybe<Timed<T>> | timeInterval(@NonNullTimeUnit unit)Measures the time between the subscription and success item emission of the current Maybe and signals it as a tuple (Timed) success value. |
@NonNullMaybe<Timed<T>> | timeInterval(@NonNullTimeUnit unit,@NonNullScheduler scheduler)Measures the time between the subscription and success item emission of the current Maybe and signals it as a tuple (Timed) success value. |
@NonNullMaybe<T> | timeout(long timeout,@NonNullTimeUnit unit)Returns a Maybe that mirrors the currentMaybe but applies a timeout policy for each emitted item. |
@NonNullMaybe<T> | timeout(long timeout,@NonNullTimeUnit unit,@NonNullMaybeSource<? extendsT> fallback)Returns a Maybe that mirrors the currentMaybe but applies a timeout policy for each emitted item. |
@NonNullMaybe<T> | timeout(long timeout,@NonNullTimeUnit unit,@NonNullScheduler scheduler)Returns a Maybe that mirrors the currentMaybe but applies a timeout policy for each emitted item, where this policy is governed on a specifiedScheduler. |
@NonNullMaybe<T> | timeout(long timeout,@NonNullTimeUnit unit,@NonNullScheduler scheduler,@NonNullMaybeSource<? extendsT> fallback)Returns a Maybe that mirrors the currentMaybe but applies a timeout policy for each emitted item using a specifiedScheduler. |
<U> @NonNullMaybe<T> | timeout(@NonNullMaybeSource<U> timeoutIndicator)If the current Maybe didn't signal an event before thetimeoutIndicatorMaybeSource signals, aTimeoutException is signaled instead. |
<U> @NonNullMaybe<T> | timeout(@NonNullMaybeSource<U> timeoutIndicator,@NonNullMaybeSource<? extendsT> fallback)If the current Maybe didn't signal an event before thetimeoutIndicatorMaybeSource signals, the currentMaybe is disposed and thefallbackMaybeSource subscribed to as a continuation. |
<U> @NonNullMaybe<T> | timeout(@NonNullPublisher<U> timeoutIndicator)If the current Maybe source didn't signal an event before thetimeoutIndicatorPublisher signals, aTimeoutException is signaled instead. |
<U> @NonNullMaybe<T> | timeout(@NonNullPublisher<U> timeoutIndicator,@NonNullMaybeSource<? extendsT> fallback)If the current Maybe didn't signal an event before thetimeoutIndicatorPublisher signals, the currentMaybe is disposed and thefallbackMaybeSource subscribed to as a continuation. |
static@NonNullMaybe<Long> | timer(long delay,@NonNullTimeUnit unit)Returns a Maybe that emits0L after a specified delay. |
static@NonNullMaybe<Long> | timer(long delay,@NonNullTimeUnit unit,@NonNullScheduler scheduler) |
@NonNullMaybe<Timed<T>> | timestamp() |
@NonNullMaybe<Timed<T>> | timestamp(@NonNullScheduler scheduler) |
@NonNullMaybe<Timed<T>> | timestamp(@NonNullTimeUnit unit) |
@NonNullMaybe<Timed<T>> | timestamp(@NonNullTimeUnit unit,@NonNullScheduler scheduler) |
<R> R | to(@NonNullMaybeConverter<T,? extends R> converter)Calls the specified converter function during assembly time and returns its resulting value. |
@NonNullCompletionStage<T> | toCompletionStage()Signals the upstream success item (or a NoSuchElementException if the upstream is empty) via aCompletionStage. |
@NonNullCompletionStage<T> | toCompletionStage(T defaultItem)Signals the upstream success item (or the default item if the upstream is empty) via a CompletionStage. |
@NonNullFlowable<T> | toFlowable()Converts this Maybe into a backpressure-awareFlowable instance composing cancellation through. |
@NonNullFuture<T> | toFuture()Returns a Future representing the single value emitted by the currentMaybe ornull if the currentMaybe is empty. |
@NonNullObservable<T> | toObservable()Converts this Maybe into anObservable instance composing disposal through. |
@NonNullSingle<T> | toSingle()Converts this Maybe into aSingle instance composing disposal through and turning an emptyMaybe into a signal ofNoSuchElementException. |
static <T> @NonNullMaybe<T> | unsafeCreate(@NonNullMaybeSource<T> onSubscribe)Advanced use only: creates a Maybe instance without any safeguards by using a callback that is called with aMaybeObserver. |
@NonNullMaybe<T> | unsubscribeOn(@NonNullScheduler scheduler)Returns a Maybe which makes sure when aMaybeObserver disposes theDisposable, that call is propagated up on the specifiedScheduler. |
static <T,D> @NonNullMaybe<T> | using(@NonNullSupplier<? extends D> resourceSupplier,@NonNullFunction<? super D,? extendsMaybeSource<? extends T>> sourceSupplier,@NonNullConsumer<? super D> resourceCleanup)Constructs a Maybe that creates a dependent resource object which is disposed of when the generatedMaybeSource terminates or the downstream calls dispose(). |
static <T,D> @NonNullMaybe<T> | using(@NonNullSupplier<? extends D> resourceSupplier,@NonNullFunction<? super D,? extendsMaybeSource<? extends T>> sourceSupplier,@NonNullConsumer<? super D> resourceCleanup, boolean eager)Constructs a Maybe that creates a dependent resource object which is disposed first ({code eager == true}) when the generatedMaybeSource terminates or the downstream disposes; or after ({code eager == false}). |
static <T> @NonNullMaybe<T> | wrap(@NonNullMaybeSource<T> source) |
static <T,R> @NonNullMaybe<R> | zip(@NonNullIterable<? extendsMaybeSource<? extends T>> sources,@NonNullFunction<? superObject[],? extends R> zipper)Returns a Maybe that emits the results of a specified combiner function applied to combinations of items emitted, in sequence, by anIterable of otherMaybeSources. |
static <T1,T2,R> @NonNullMaybe<R> | zip(@NonNullMaybeSource<? extends T1> source1,@NonNullMaybeSource<? extends T2> source2,@NonNullBiFunction<? 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 otherMaybeSources. |
static <T1,T2,T3,R> | zip(@NonNullMaybeSource<? extends T1> source1,@NonNullMaybeSource<? extends T2> source2,@NonNullMaybeSource<? extends T3> source3,@NonNullFunction3<? 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 otherMaybeSources. |
static <T1,T2,T3,T4,R> | zip(@NonNullMaybeSource<? extends T1> source1,@NonNullMaybeSource<? extends T2> source2,@NonNullMaybeSource<? extends T3> source3,@NonNullMaybeSource<? extends T4> source4,@NonNullFunction4<? 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 otherMaybeSources. |
static <T1,T2,T3,T4,T5,R> | zip(@NonNullMaybeSource<? extends T1> source1,@NonNullMaybeSource<? extends T2> source2,@NonNullMaybeSource<? extends T3> source3,@NonNullMaybeSource<? extends T4> source4,@NonNullMaybeSource<? extends T5> source5,@NonNullFunction5<? 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 otherMaybeSources. |
static <T1,T2,T3,T4,T5,T6,R> | zip(@NonNullMaybeSource<? extends T1> source1,@NonNullMaybeSource<? extends T2> source2,@NonNullMaybeSource<? extends T3> source3,@NonNullMaybeSource<? extends T4> source4,@NonNullMaybeSource<? extends T5> source5,@NonNullMaybeSource<? extends T6> source6,@NonNullFunction6<? 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 otherMaybeSources. |
static <T1,T2,T3,T4,T5,T6,T7,R> | zip(@NonNullMaybeSource<? extends T1> source1,@NonNullMaybeSource<? extends T2> source2,@NonNullMaybeSource<? extends T3> source3,@NonNullMaybeSource<? extends T4> source4,@NonNullMaybeSource<? extends T5> source5,@NonNullMaybeSource<? extends T6> source6,@NonNullMaybeSource<? extends T7> source7,@NonNullFunction7<? 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 otherMaybeSources. |
static <T1,T2,T3,T4,T5,T6,T7,T8,R> | zip(@NonNullMaybeSource<? extends T1> source1,@NonNullMaybeSource<? extends T2> source2,@NonNullMaybeSource<? extends T3> source3,@NonNullMaybeSource<? extends T4> source4,@NonNullMaybeSource<? extends T5> source5,@NonNullMaybeSource<? extends T6> source6,@NonNullMaybeSource<? extends T7> source7,@NonNullMaybeSource<? extends T8> source8,@NonNullFunction8<? 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 otherMaybeSources. |
static <T1,T2,T3,T4,T5,T6,T7,T8,T9,R> | zip(@NonNullMaybeSource<? extends T1> source1,@NonNullMaybeSource<? extends T2> source2,@NonNullMaybeSource<? extends T3> source3,@NonNullMaybeSource<? extends T4> source4,@NonNullMaybeSource<? extends T5> source5,@NonNullMaybeSource<? extends T6> source6,@NonNullMaybeSource<? extends T7> source7,@NonNullMaybeSource<? extends T8> source8,@NonNullMaybeSource<? extends T9> source9,@NonNullFunction9<? 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 otherMaybeSources. |
static <T,R> @NonNullMaybe<R> | zipArray(@NonNullFunction<? superObject[],? 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 otherMaybeSources. |
<U,R> @NonNullMaybe<R> | zipWith(@NonNullMaybeSource<? extends U> other,@NonNullBiFunction<? superT,? super U,? extends R> zipper)Waits until this and the other MaybeSource signal a success value then applies the givenBiFunction to those values and emits theBiFunction's resulting value to downstream. |
@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullMaybe<T> amb(@NonNullIterable<? extendsMaybeSource<? extends T>> sources)
MaybeSources provided by anIterable sequence and signals the events of the first one that signals (disposing the rest).
amb does not operate by default on a particularScheduler.T - the value typesources - theIterable sequence of sources. A subscription to each source will occur in the same order as in theIterable.Maybe instanceNullPointerException - ifsources isnull@CheckReturnValue@SchedulerSupport(value="none")@NonNull@SafeVarargspublic static <T> @NonNullMaybe<T> ambArray(@NonNullMaybeSource<? 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 particularScheduler.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 - ifsources isnull@BackpressureSupport(value=FULL)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullFlowable<T> concat(@NonNullIterable<? extendsMaybeSource<? extends T>> sources)
MaybeSource sources provided by anIterable sequence as aFlowable sequence.
Flowable honors the backpressure of the downstream consumer.concat does not operate by default on a particularScheduler.T - the value typesources - theIterable sequence ofMaybeSource instancesFlowable instanceNullPointerException - ifsources isnull@BackpressureSupport(value=FULL)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullFlowable<T> concat(@NonNullMaybeSource<? extends T> source1,@NonNullMaybeSource<? extends T> source2)
Flowable that emits the items emitted by twoMaybeSources, one after the other.
Flowable honors the backpressure of the downstream consumer.concat does not operate by default on a particularScheduler.T - the common value typesource1 - aMaybeSource to be concatenatedsource2 - aMaybeSource to be concatenatedFlowable instanceNullPointerException - ifsource1 orsource2 isnull@BackpressureSupport(value=FULL)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullFlowable<T> concat(@NonNullMaybeSource<? extends T> source1,@NonNullMaybeSource<? extends T> source2,@NonNullMaybeSource<? extends T> source3)
Flowable that emits the items emitted by threeMaybeSources, one after the other.
Flowable honors the backpressure of the downstream consumer.concat does not operate by default on a particularScheduler.T - the common value typesource1 - aMaybeSource to be concatenatedsource2 - aMaybeSource to be concatenatedsource3 - aMaybeSource to be concatenatedFlowable instanceNullPointerException - ifsource1,source2 orsource3 isnull@BackpressureSupport(value=FULL)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullFlowable<T> concat(@NonNullMaybeSource<? extends T> source1,@NonNullMaybeSource<? extends T> source2,@NonNullMaybeSource<? extends T> source3,@NonNullMaybeSource<? extends T> source4)
Flowable that emits the items emitted by fourMaybeSources, one after the other.
Flowable honors the backpressure of the downstream consumer.concat does not operate by default on a particularScheduler.T - the common value typesource1 - aMaybeSource to be concatenatedsource2 - aMaybeSource to be concatenatedsource3 - aMaybeSource to be concatenatedsource4 - aMaybeSource to be concatenatedFlowable instanceNullPointerException - ifsource1,source2,source3 orsource4 isnull@BackpressureSupport(value=FULL)@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic static <T> @NonNullFlowable<T> concat(@NonNullPublisher<? extendsMaybeSource<? extends T>> sources)
MaybeSource sources provided by aPublisher sequence as aFlowable sequence.
Flowable honors the backpressure of the downstream consumer and expects thePublisher to honor backpressure as well. If the sourcesPublisher violates this, aMissingBackpressureException is signaled.concat does not operate by default on a particularScheduler.T - the value typesources - thePublisher ofMaybeSource instancesFlowable instanceNullPointerException - ifsources isnull@BackpressureSupport(value=FULL)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullFlowable<T> concat(@NonNullPublisher<? extendsMaybeSource<? extends T>> sources, int prefetch)
MaybeSource sources provided by aPublisher sequence as aFlowable sequence.
Flowable honors the backpressure of the downstream consumer and expects thePublisher to honor backpressure as well. If the sourcesPublisher violates this, aMissingBackpressureException is signaled.concat does not operate by default on a particularScheduler.T - the value typesources - thePublisher ofMaybeSource instancesprefetch - the number ofMaybeSources to prefetch from thePublisherFlowable instanceNullPointerException - ifsources isnullIllegalArgumentException - ifprefetch is non-positive@BackpressureSupport(value=FULL)@CheckReturnValue@NonNull@SchedulerSupport(value="none")@SafeVarargspublic static <T> @NonNullFlowable<T> concatArray(@NonNullMaybeSource<? extends T>... sources)
MaybeSource sources in the array as aFlowable sequence.
Flowable honors the backpressure of the downstream consumer.concatArray does not operate by default on a particularScheduler.T - the value typesources - the array ofMaybeSource instancesFlowable instanceNullPointerException - ifsources isnull@BackpressureSupport(value=FULL)@CheckReturnValue@SchedulerSupport(value="none")@SafeVarargs@NonNullpublic static <T> @NonNullFlowable<T> concatArrayDelayError(@NonNullMaybeSource<? extends T>... sources)
MaybeSource sources and delays errors from any of them till all terminate as aFlowable sequence.
concatArrayDelayError does not operate by default on a particularScheduler.T - the common base value typesources - the array of sourcesFlowable instanceNullPointerException - ifsources isnull@BackpressureSupport(value=FULL)@CheckReturnValue@SchedulerSupport(value="none")@NonNull@SafeVarargspublic static <T> @NonNullFlowable<T> concatArrayEager(@NonNullMaybeSource<? extends T>... sources)
MaybeSource eagerly into aFlowable sequence. Eager concatenation means that once an observer subscribes, this operator subscribes to all of the sourceMaybeSources. The operator buffers the value emitted by theseMaybeSources and then drains them in order, each one after the previous one completes.

Scheduler.T - the value typesources - a sequence ofMaybeSources that need to be eagerly concatenatedFlowable instance with the specified concatenation behaviorNullPointerException - ifsources isnull@BackpressureSupport(value=FULL)@CheckReturnValue@SchedulerSupport(value="none")@NonNull@SafeVarargspublic static <T> @NonNullFlowable<T> concatArrayEagerDelayError(@NonNullMaybeSource<? extends T>... sources)
MaybeSource eagerly into aFlowable sequence. Eager concatenation means that once an observer subscribes, this operator subscribes to all of the sourceMaybeSources. The operator buffers the value emitted by theseMaybeSources and then drains them in order, each one after the previous one completes.

Scheduler.T - the value typesources - a sequence ofMaybeSources that need to be eagerly concatenatedFlowable instance with the specified concatenation behaviorNullPointerException - ifsources isnull@BackpressureSupport(value=FULL)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullFlowable<T> concatDelayError(@NonNullIterable<? extendsMaybeSource<? extends T>> sources)
Iterable sequence ofMaybeSources into a single sequence by subscribing to eachMaybeSource, one after the other, one at a time and delays any errors till the all innerMaybeSources terminate as aFlowable sequence.
concatDelayError does not operate by default on a particularScheduler.T - the common element base typesources - theIterable sequence ofMaybeSourcesFlowable with the concatenating behaviorNullPointerException - ifsources isnull@BackpressureSupport(value=FULL)@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic static <T> @NonNullFlowable<T> concatDelayError(@NonNullPublisher<? extendsMaybeSource<? extends T>> sources)
Publisher sequence ofMaybeSources into a single sequence by subscribing to each innerMaybeSource, one after the other, one at a time and delays any errors till the all inner and the outerPublisher terminate as aFlowable sequence.
concatDelayError fully supports backpressure.concatDelayError does not operate by default on a particularScheduler.T - the common element base typesources - thePublisher sequence ofMaybeSourcesFlowable with the concatenating behaviorNullPointerException - ifsources isnull@BackpressureSupport(value=FULL)@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic static <T> @NonNullFlowable<T> concatDelayError(@NonNullPublisher<? extendsMaybeSource<? extends T>> sources, int prefetch)
Publisher sequence ofMaybeSources into a single sequence by subscribing to each innerMaybeSource, one after the other, one at a time and delays any errors till the all inner and the outerPublisher terminate as aFlowable sequence.
concatDelayError fully supports backpressure.concatDelayError does not operate by default on a particularScheduler.T - the common element base typesources - thePublisher sequence ofMaybeSourcesprefetch - The number of upstream items to prefetch so that fresh items are ready to be mapped when a previousMaybeSource terminates. The operator replenishes after half of the prefetch amount has been consumed and turned intoMaybeSources.Flowable with the concatenating behaviorNullPointerException - ifsources isnullIllegalArgumentException - ifprefetch is non-positive@BackpressureSupport(value=FULL)@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic static <T> @NonNullFlowable<T> concatEager(@NonNullIterable<? extendsMaybeSource<? extends T>> sources)
MaybeSources eagerly into aFlowable sequence.
Eager concatenation means that once an observer subscribes, this operator subscribes to all of the sourceMaybeSources. The operator buffers the values emitted by theseMaybeSources and then drains them in order, each one after the previous one completes.
Scheduler.T - the value typesources - a sequence ofMaybeSource that need to be eagerly concatenatedFlowable instance with the specified concatenation behaviorNullPointerException - ifsources isnull@BackpressureSupport(value=FULL)@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic static <T> @NonNullFlowable<T> concatEager(@NonNullIterable<? extendsMaybeSource<? extends T>> sources, int maxConcurrency)
MaybeSources eagerly into aFlowable 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 sourceMaybeSources. The operator buffers the values emitted by theseMaybeSources and then drains them in order, each one after the previous one completes.
Scheduler.T - the value typesources - a sequence ofMaybeSource that need to be eagerly concatenatedmaxConcurrency - the maximum number of concurrently running innerMaybeSources;Integer.MAX_VALUE is interpreted as all innerMaybeSources can be active at the same timeFlowable instance with the specified concatenation behaviorNullPointerException - ifsources isnullIllegalArgumentException - ifmaxConcurrency is non-positive@BackpressureSupport(value=FULL)@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic static <T> @NonNullFlowable<T> concatEager(@NonNullPublisher<? extendsMaybeSource<? extends T>> sources)
Publisher sequence ofMaybeSources eagerly into aFlowable sequence. Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the emitted sourceMaybeSources as they are observed. The operator buffers the values emitted by theseMaybeSources 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 signalMissingBackpressureException.Scheduler.T - the value typesources - a sequence ofMaybeSources that need to be eagerly concatenatedFlowable instance with the specified concatenation behaviorNullPointerException - ifsources isnull@BackpressureSupport(value=FULL)@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic static <T> @NonNullFlowable<T> concatEager(@NonNullPublisher<? extendsMaybeSource<? extends T>> sources, int maxConcurrency)
Publisher sequence ofMaybeSources eagerly into aFlowable sequence, running at most the given number of innerMaybeSources at once.
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the emitted sourceMaybeSources as they are observed. The operator buffers the values emitted by theseMaybeSources 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 signalMissingBackpressureException.Scheduler.T - the value typesources - a sequence ofMaybeSources that need to be eagerly concatenatedmaxConcurrency - the maximum number of concurrently running innerMaybeSources;Integer.MAX_VALUE is interpreted as all innerMaybeSources can be active at the same timeFlowable instance with the specified concatenation behaviorNullPointerException - ifsources isnullIllegalArgumentException - ifmaxConcurrency is non-positive@BackpressureSupport(value=FULL)@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic static <T> @NonNullFlowable<T> concatEagerDelayError(@NonNullIterable<? extendsMaybeSource<? extends T>> sources)
MaybeSources eagerly into aFlowable sequence, delaying errors until all innerMaybeSources terminate.
Eager concatenation means that once an observer subscribes, this operator subscribes to all of the sourceMaybeSources. The operator buffers the values emitted by theseMaybeSources and then drains them in order, each one after the previous one completes.
Scheduler.T - the value typesources - a sequence ofMaybeSource that need to be eagerly concatenatedFlowable instance with the specified concatenation behaviorNullPointerException - ifsources isnull@BackpressureSupport(value=FULL)@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic static <T> @NonNullFlowable<T> concatEagerDelayError(@NonNullIterable<? extendsMaybeSource<? extends T>> sources, int maxConcurrency)
MaybeSources eagerly into aFlowable sequence, delaying errors until all innerMaybeSources terminate and runs a limited number of innerMaybeSources at once.
Eager concatenation means that once an observer subscribes, this operator subscribes to all of the sourceMaybeSources. The operator buffers the values emitted by theseMaybeSources and then drains them in order, each one after the previous one completes.
Scheduler.T - the value typesources - a sequence ofMaybeSource that need to be eagerly concatenatedmaxConcurrency - the maximum number of concurrently running innerMaybeSources;Integer.MAX_VALUE is interpreted as all innerMaybeSources can be active at the same timeFlowable instance with the specified concatenation behaviorNullPointerException - ifsources isnullIllegalArgumentException - ifmaxConcurrency is non-positive@BackpressureSupport(value=FULL)@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic static <T> @NonNullFlowable<T> concatEagerDelayError(@NonNullPublisher<? extendsMaybeSource<? extends T>> sources)
Publisher sequence ofMaybeSources eagerly into aFlowable 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 sourceMaybeSources as they are observed. The operator buffers the values emitted by theseMaybeSources 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 signalMissingBackpressureException.Scheduler.T - the value typesources - a sequence ofMaybeSources that need to be eagerly concatenatedFlowable instance with the specified concatenation behaviorNullPointerException - ifsources isnull@BackpressureSupport(value=FULL)@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic static <T> @NonNullFlowable<T> concatEagerDelayError(@NonNullPublisher<? extendsMaybeSource<? extends T>> sources, int maxConcurrency)
Publisher sequence ofMaybeSources eagerly into aFlowable sequence, delaying errors until all the inner and the outer sequence terminate and runs a limited number of the innerMaybeSources at once.
Eager concatenation means that once a subscriber subscribes, this operator subscribes to all of the emitted sourceMaybeSources as they are observed. The operator buffers the values emitted by theseMaybeSources 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 signalMissingBackpressureException.Scheduler.T - the value typesources - a sequence ofMaybeSources that need to be eagerly concatenatedmaxConcurrency - the maximum number of concurrently running innerMaybeSources;Integer.MAX_VALUE is interpreted as all innerMaybeSources can be active at the same timeFlowable instance with the specified concatenation behaviorNullPointerException - ifsources isnullIllegalArgumentException - ifmaxConcurrency is non-positive@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullMaybe<T> create(@NonNullMaybeOnSubscribe<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 aMaybeObserver subscribes to the returnedMaybe, the providedMaybeOnSubscribe callback is invoked with a fresh instance of aMaybeEmitter that will interact only with that specificMaybeObserver. If thisMaybeObserver disposes the flow (makingMaybeEmitter.isDisposed() returntrue), other observers subscribed to the same returnedMaybe are not affected.
create does not operate by default on a particularScheduler.T - the value typeonSubscribe - the emitter that is called when aMaybeObserver subscribes to the returnedMaybeMaybe instanceNullPointerException - ifonSubscribe isnullMaybeOnSubscribe,Cancellable@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullMaybe<T> defer(@NonNullSupplier<? extendsMaybeSource<? extends T>> supplier)
Supplier for each individualMaybeObserver to return the actualMaybeSource source to be subscribed to.
defer does not operate by default on a particularScheduler.T - the value typesupplier - theSupplier that is called for each individualMaybeObserver and returns aMaybeSource instance to subscribe toMaybe instanceNullPointerException - ifsupplier isnull@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic static <T> @NonNullMaybe<T> empty()
Maybe instance that callsonComplete immediately.
empty does not operate by default on a particularScheduler.T - the value typeMaybe instance@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullMaybe<T> error(@NonNullThrowable throwable)
Maybe that invokes a subscriber'sonError method when the subscriber subscribes to it.
error does not operate by default on a particularScheduler.T - the type of the item (ostensibly) emitted by theMaybethrowable - the particularThrowable to pass toonErrorMaybe instanceNullPointerException - ifthrowable isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullMaybe<T> error(@NonNullSupplier<? extendsThrowable> supplier)
Maybe that invokes aMaybeObserver'sonError method when theMaybeObserver subscribes to it.
error does not operate by default on a particularScheduler.T - the type of the items (ostensibly) emitted by theMaybesupplier - aSupplier factory to return aThrowable for each individualMaybeObserverMaybe instanceNullPointerException - ifsupplier isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullMaybe<T> fromAction(@NonNullAction action)
Maybe instance that runs the givenAction for eachMaybeObserver and emits either its exception or simply completes.
fromAction does not operate by default on a particularScheduler.Action throws an exception, the respectiveThrowable is delivered to the downstream viaMaybeObserver.onError(Throwable), except when the downstream has disposed the resultingMaybe source. In this latter case, theThrowable is delivered to the global error handler viaRxJavaPlugins.onError(Throwable) as anUndeliverableException.T - the target typeaction - theAction to run for eachMaybeObserverMaybe instanceNullPointerException - ifaction isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullMaybe<T> fromCompletable(@NonNullCompletableSource completableSource)
CompletableSource into aMaybe.
fromCompletable does not operate by default on a particularScheduler.T - the target typecompletableSource - theCompletableSource to convert fromMaybe instanceNullPointerException - ifcompletableSource isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullMaybe<T> fromSingle(@NonNullSingleSource<T> single)
SingleSource into aMaybe.
fromSingle does not operate by default on a particularScheduler.T - the target typesingle - theSingleSource to convert fromMaybe instanceNullPointerException - ifsingle isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullMaybe<T> fromCallable(@NonNullCallable<? extends T> callable)
Maybe that invokes the givenCallable for each individualMaybeObserver that subscribes and emits the resulting non-null item viaonSuccess while considering anull result from theCallable as indication for valueless completion viaonComplete.
This operator allows you to defer the execution of the givenCallable until aMaybeObserver subscribes to the returnedMaybe. In other terms, this source operator evaluates the givenCallable "lazily".
Note that thenull handling of this operator differs from the similar source operators in the otherbase reactive classes. Those operators signal aNullPointerException if the value returned by theirCallable isnull while thisfromCallable considers it to indicate the returnedMaybe is empty.
fromCallable does not operate by default on a particularScheduler.Callable.call() will be forwarded toonError, except if theMaybeObserver disposed the subscription in the meantime. In this latter case, the exception is forwarded to the global error handler viaRxJavaPlugins.onError(Throwable) wrapped into aUndeliverableException. Fatal exceptions are rethrown and usually will end up in the executing thread'sThread.UncaughtExceptionHandler.uncaughtException(Thread, Throwable) handler.T - the type of the item emitted by theMaybe.callable - aCallable instance whose execution should be deferred and performed for each individualMaybeObserver that subscribes to the returnedMaybe.Maybe instanceNullPointerException - ifcallable isnulldefer(Supplier),fromSupplier(Supplier)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullMaybe<T> fromFuture(@NonNullFuture<? extends T> future)
Future into aMaybe, treating anull result as an indication of emptiness.
The operator callsFuture.get(), which is a blocking method, on the subscription thread. It is recommended applyingsubscribeOn(Scheduler) to move this blocking wait to a background thread, and if theScheduler supports it, interrupt the wait when the flow is disposed.
Unlike 1.x, disposing theMaybe 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 particularScheduler.T - the type of object that theFuture returns, and also the type of item to be emitted by the resultingMaybefuture - the sourceFutureMaybe instanceNullPointerException - iffuture isnullfromCompletionStage(CompletionStage)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullMaybe<T> fromFuture(@NonNullFuture<? extends T> future, long timeout,@NonNullTimeUnit unit)
Future into aMaybe, with a timeout on theFuture.
The operator callsFuture.get(long, TimeUnit), which is a blocking method, on the subscription thread. It is recommended applyingsubscribeOn(Scheduler) to move this blocking wait to a background thread, and if theScheduler supports it, interrupt the wait when the flow is disposed.
Unlike 1.x, disposing theMaybe 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 particularScheduler.T - the type of object that theFuture returns, and also the type of item to be emitted by the resultingMaybefuture - the sourceFuturetimeout - the maximum time to wait before callinggetunit - theTimeUnit of thetimeout argumentMaybe instanceNullPointerException - iffuture orunit isnullfromCompletionStage(CompletionStage)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullMaybe<T> fromObservable(@NonNullObservableSource<T> source)
ObservableSource into aMaybe and emits the very first item or completes if the source is empty.
fromObservable does not operate by default on a particularScheduler.T - the target typesource - theObservableSource to convert fromMaybe instanceNullPointerException - ifsource isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")@BackpressureSupport(value=UNBOUNDED_IN)public static <T> @NonNullMaybe<T> fromPublisher(@NonNullPublisher<T> source)
Publisher into aMaybe and emits the very first item or completes if the source is empty.
Publisher in an unbounded manner (requestingLong.MAX_VALUE) but cancels it after one item received.fromPublisher does not operate by default on a particularScheduler.T - the target typesource - thePublisher to convert fromMaybe instanceNullPointerException - ifsource isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullMaybe<T> fromRunnable(@NonNullRunnable run)
Maybe instance that runs the givenRunnable for eachMaybeObserver and emits either its unchecked exception or simply completes.
If the code to be wrapped needs to throw a checked or more broaderThrowable exception, that exception has to be converted to an unchecked exception by the wrapped code itself. Alternatively, use thefromAction(Action) method which allows the wrapped code to throw anyThrowable exception and will signal it to observers as-is.
fromRunnable does not operate by default on a particularScheduler.Runnable throws an exception, the respectiveThrowable is delivered to the downstream viaMaybeObserver.onError(Throwable), except when the downstream has disposed thisMaybe source. In this latter case, theThrowable is delivered to the global error handler viaRxJavaPlugins.onError(Throwable) as anUndeliverableException.T - the target typerun - theRunnable to run for eachMaybeObserverMaybe instanceNullPointerException - ifrun isnullfromAction(Action)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullMaybe<T> fromSupplier(@NonNullSupplier<? extends T> supplier)
Maybe that invokes the givenSupplier for each individualMaybeObserver that subscribes and emits the resulting non-null item viaonSuccess while considering anull result from theSupplier as indication for valueless completion viaonComplete. This operator allows you to defer the execution of the givenSupplier until aMaybeObserver subscribes to the returnedMaybe. In other terms, this source operator evaluates the givenSupplier "lazily".

Note that thenull handling of this operator differs from the similar source operators in the otherbase reactive classes. Those operators signal aNullPointerException if the value returned by theirSupplier isnull while thisfromSupplier considers it to indicate the returnedMaybe is empty.
fromSupplier does not operate by default on a particularScheduler.Supplier.get() will be forwarded toonError, except if theMaybeObserver disposed the subscription in the meantime. In this latter case, the exception is forwarded to the global error handler viaRxJavaPlugins.onError(Throwable) wrapped into aUndeliverableException. Fatal exceptions are rethrown and usually will end up in the executing thread'sThread.UncaughtExceptionHandler.uncaughtException(Thread, Throwable) handler.T - the type of the item emitted by theMaybe.supplier - aSupplier instance whose execution should be deferred and performed for each individualMaybeObserver that subscribes to the returnedMaybe.Maybe instanceNullPointerException - ifsupplier isnulldefer(Supplier),fromCallable(Callable)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullMaybe<T> just(T item)
Maybe that emits a specified item.
To convert any object into aMaybe that emits that object, pass that object into thejust method.
just does not operate by default on a particularScheduler.T - the type of that itemitem - the item to emitMaybe instanceNullPointerException - ifitem isnull@BackpressureSupport(value=FULL)@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic static <T> @NonNullFlowable<T> merge(@NonNullIterable<? extendsMaybeSource<? extends T>> sources)
Iterable sequence ofMaybeSource instances into a singleFlowable sequence, running allMaybeSources at once.
merge does not operate by default on a particularScheduler.MaybeSources signal aThrowable viaonError, the resultingFlowable terminates with thatThrowable and all other sourceMaybeSources are disposed. If more than oneMaybeSource signals an error, the resultingFlowable may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeException containing two or more of the various error signals.Throwables that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable) method asUndeliverableException errors. Similarly,Throwables signaled by source(s) after the returnedFlowable has been cancelled or terminated with a (composite) error will be sent to the same global error handler. UsemergeDelayError(Iterable) to merge sources and terminate only when all sourceMaybeSources have completed or failed with an error.T - the common and resulting value typesources - theIterable sequence ofMaybeSource sourcesFlowable instanceNullPointerException - ifsources isnullmergeDelayError(Iterable)@BackpressureSupport(value=FULL)@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic static <T> @NonNullFlowable<T> merge(@NonNullPublisher<? extendsMaybeSource<? extends T>> sources)
Publisher sequence ofMaybeSource instances into a singleFlowable sequence, running allMaybeSources at once.
merge does not operate by default on a particularScheduler.MaybeSources signal aThrowable viaonError, the resultingFlowable terminates with thatThrowable and all other sourceMaybeSources are disposed. If more than oneMaybeSource signals an error, the resultingFlowable may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeException containing two or more of the various error signals.Throwables that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable) method asUndeliverableException errors. Similarly,Throwables signaled by source(s) after the returnedFlowable has been cancelled or terminated with a (composite) error will be sent to the same global error handler. UsemergeDelayError(Publisher) to merge sources and terminate only when all sourceMaybeSources have completed or failed with an error.T - the common and resulting value typesources - theFlowable sequence ofMaybeSource sourcesFlowable instanceNullPointerException - ifsources isnullmergeDelayError(Publisher)@BackpressureSupport(value=FULL)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullFlowable<T> merge(@NonNullPublisher<? extendsMaybeSource<? extends T>> sources, int maxConcurrency)
Publisher sequence ofMaybeSource instances into a singleFlowable sequence, running at most maxConcurrencyMaybeSources at once.
merge does not operate by default on a particularScheduler.MaybeSources signal aThrowable viaonError, the resultingFlowable terminates with thatThrowable and all other sourceMaybeSources are disposed. If more than oneMaybeSource signals an error, the resultingFlowable may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeException containing two or more of the various error signals.Throwables that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable) method asUndeliverableException errors. Similarly,Throwables signaled by source(s) after the returnedFlowable has been cancelled or terminated with a (composite) error will be sent to the same global error handler. UsemergeDelayError(Publisher, int) to merge sources and terminate only when all sourceMaybeSources have completed or failed with an error.T - the common and resulting value typesources - theFlowable sequence ofMaybeSource sourcesmaxConcurrency - the maximum number of concurrently runningMaybeSourcesFlowable instanceNullPointerException - ifsources isnullIllegalArgumentException - ifmaxConcurrency is non-positivemergeDelayError(Publisher, int)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullMaybe<T> merge(@NonNullMaybeSource<? extendsMaybeSource<? extends T>> source)
MaybeSource that emits aMaybeSource into a singleMaybeSource that emits the item emitted by the nestedMaybeSource, without any transformation.
merge does not operate by default on a particularScheduler.Maybe emits the outer source's or the innerMaybeSource'sThrowable as is. Unlike the othermerge() operators, this operator won't and can't produce aCompositeException because there is only one possibility for the outer or the innerMaybeSource to emit anonError signal. Therefore, there is no need for amergeDelayError(MaybeSource<MaybeSource<T>>) operator.T - the value type of the sources and the outputsource - aMaybeSource that emits aMaybeSourceMaybe instanceNullPointerException - ifsource isnull@BackpressureSupport(value=FULL)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullFlowable<T> merge(@NonNullMaybeSource<? extends T> source1,@NonNullMaybeSource<? extends T> source2)
MaybeSources into a singleFlowable, without any transformation.
You can combine items emitted by multipleMaybeSources so that they appear as a singleFlowable, by using themerge method.
merge does not operate by default on a particularScheduler.MaybeSources signal aThrowable viaonError, the resultingFlowable terminates with thatThrowable and all other sourceMaybeSources are disposed. If more than oneMaybeSource signals an error, the resultingFlowable may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeException containing two or more of the various error signals.Throwables that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable) method asUndeliverableException errors. Similarly,Throwables signaled by source(s) after the returnedFlowable has been cancelled or terminated with a (composite) error will be sent to the same global error handler. UsemergeDelayError(MaybeSource, MaybeSource) to merge sources and terminate only when all sourceMaybeSources have completed or failed with an error.T - the common value typesource1 - aMaybeSource to be mergedsource2 - aMaybeSource to be mergedFlowable instanceNullPointerException - ifsource1 orsource2 isnullmergeDelayError(MaybeSource, MaybeSource)@BackpressureSupport(value=FULL)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullFlowable<T> merge(@NonNullMaybeSource<? extends T> source1,@NonNullMaybeSource<? extends T> source2,@NonNullMaybeSource<? extends T> source3)
MaybeSources into a singleFlowable, without any transformation.
You can combine items emitted by multipleMaybeSources so that they appear as a singleFlowable, by using themerge method.
merge does not operate by default on a particularScheduler.MaybeSources signal aThrowable viaonError, the resultingFlowable terminates with thatThrowable and all other sourceMaybeSources are disposed. If more than oneMaybeSource signals an error, the resultingFlowable may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeException containing two or more of the various error signals.Throwables that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable) method asUndeliverableException errors. Similarly,Throwables signaled by source(s) after the returnedFlowable has been cancelled or terminated with a (composite) error will be sent to the same global error handler. UsemergeDelayError(MaybeSource, MaybeSource, MaybeSource) to merge sources and terminate only when all sourceMaybeSources have completed or failed with an error.T - the common value typesource1 - aMaybeSource to be mergedsource2 - aMaybeSource to be mergedsource3 - aMaybeSource to be mergedFlowable instanceNullPointerException - ifsource1,source2 orsource3 isnullmergeDelayError(MaybeSource, MaybeSource, MaybeSource)@BackpressureSupport(value=FULL)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullFlowable<T> merge(@NonNullMaybeSource<? extends T> source1,@NonNullMaybeSource<? extends T> source2,@NonNullMaybeSource<? extends T> source3,@NonNullMaybeSource<? extends T> source4)
MaybeSources into a singleFlowable, without any transformation.
You can combine items emitted by multipleMaybeSources so that they appear as a singleFlowable, by using themerge method.
merge does not operate by default on a particularScheduler.MaybeSources signal aThrowable viaonError, the resultingFlowable terminates with thatThrowable and all other sourceMaybeSources are disposed. If more than oneMaybeSource signals an error, the resultingFlowable may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeException containing two or more of the various error signals.Throwables that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable) method asUndeliverableException errors. Similarly,Throwables signaled by source(s) after the returnedFlowable has been cancelled or terminated with a (composite) error will be sent to the same global error handler. UsemergeDelayError(MaybeSource, MaybeSource, MaybeSource, MaybeSource) to merge sources and terminate only when all sourceMaybeSources have completed or failed with an error.T - the common value typesource1 - aMaybeSource to be mergedsource2 - aMaybeSource to be mergedsource3 - aMaybeSource to be mergedsource4 - aMaybeSource to be mergedFlowable instanceNullPointerException - ifsource1,source2,source3 orsource4 isnullmergeDelayError(MaybeSource, MaybeSource, MaybeSource, MaybeSource)@BackpressureSupport(value=FULL)@CheckReturnValue@NonNull@SchedulerSupport(value="none")@SafeVarargspublic static <T> @NonNullFlowable<T> mergeArray(MaybeSource<? extends T>... sources)
MaybeSource instances into a singleFlowable sequence, running allMaybeSources at once.
mergeArray does not operate by default on a particularScheduler.MaybeSources signal aThrowable viaonError, the resultingFlowable terminates with thatThrowable and all other sourceMaybeSources are disposed. If more than oneMaybeSource signals an error, the resultingFlowable may terminate with the first one's error or, depending on the concurrency of the sources, may terminate with aCompositeException containing two or more of the various error signals.Throwables that didn't make into the composite will be sent (individually) to the global error handler viaRxJavaPlugins.onError(Throwable) method asUndeliverableException errors. Similarly,Throwables signaled by source(s) after the returnedFlowable has been cancelled or terminated with a (composite) error will be sent to the same global error handler. UsemergeArrayDelayError(MaybeSource...) to merge sources and terminate only when all sourceMaybeSources have completed or failed with an error.T - the common and resulting value typesources - the array sequence ofMaybeSource sourcesFlowable instanceNullPointerException - ifsources isnullmergeArrayDelayError(MaybeSource...)@BackpressureSupport(value=FULL)@CheckReturnValue@SchedulerSupport(value="none")@SafeVarargs@NonNullpublic static <T> @NonNullFlowable<T> mergeArrayDelayError(@NonNullMaybeSource<? extends T>... sources)
MaybeSources into oneFlowable, in a way that allows a subscriber to receive all successfully emitted items from each of the sourceMaybeSources without being interrupted by an error notification from one of them.
This behaves likemerge(Publisher) except that if any of the mergedMaybeSources notify of an error viaonError,mergeArrayDelayError will refrain from propagating that error notification until all of the mergedMaybeSources have finished emitting items.
Even if multiple mergedMaybeSources sendonError notifications,mergeArrayDelayError will only invoke theonError method of its subscribers once.
mergeArrayDelayError does not operate by default on a particularScheduler.T - the common element base typesources - the array ofMaybeSourcesFlowable instanceNullPointerException - ifsources isnull@BackpressureSupport(value=FULL)@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic static <T> @NonNullFlowable<T> mergeDelayError(@NonNullIterable<? extendsMaybeSource<? extends T>> sources)
Iterable sequence ofMaybeSources into oneFlowable, in a way that allows a subscriber to receive all successfully emitted items from each of the sourceMaybeSources without being interrupted by an error notification from one of them.
This behaves likemerge(Publisher) except that if any of the mergedMaybeSources notify of an error viaonError,mergeDelayError will refrain from propagating that error notification until all of the mergedMaybeSources have finished emitting items.

Even if multiple mergedMaybeSources sendonError notifications,mergeDelayError will only invoke theonError method of its subscribers once.
mergeDelayError does not operate by default on a particularScheduler.T - the common element base typesources - theIterable ofMaybeSourcesFlowable instanceNullPointerException - ifsources isnull@BackpressureSupport(value=FULL)@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic static <T> @NonNullFlowable<T> mergeDelayError(@NonNullPublisher<? extendsMaybeSource<? extends T>> sources)
Publisher that emitsMaybeSources into oneFlowable, in a way that allows a subscriber to receive all successfully emitted items from all of the sourceMaybeSources without being interrupted by an error notification from one of them or even the mainPublisher.
This behaves likemerge(Publisher) except that if any of the mergedMaybeSources notify of an error viaonError,mergeDelayError will refrain from propagating that error notification until all of the mergedMaybeSources and the mainPublisher have finished emitting items.
Even if multiple mergedMaybeSources sendonError notifications,mergeDelayError will only invoke theonError 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 particularScheduler.T - the common element base typesources - aPublisher that emitsMaybeSourcesFlowable instanceNullPointerException - ifsources isnull@BackpressureSupport(value=FULL)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullFlowable<T> mergeDelayError(@NonNullPublisher<? extendsMaybeSource<? extends T>> sources, int maxConcurrency)
Publisher that emitsMaybeSources into oneFlowable, in a way that allows a subscriber to receive all successfully emitted items from all of the sourceMaybeSources without being interrupted by an error notification from one of them or even the mainPublisher as well as limiting the total number of activeMaybeSources.
This behaves likemerge(Publisher, int) except that if any of the mergedMaybeSources notify of an error viaonError,mergeDelayError will refrain from propagating that error notification until all of the mergedMaybeSources and the mainPublisher have finished emitting items.
Even if multiple mergedMaybeSources sendonError notifications,mergeDelayError will only invoke theonError 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 particularScheduler.History: 2.1.9 - experimental
T - the common element base typesources - aPublisher that emitsMaybeSourcesmaxConcurrency - the maximum number of active innerMaybeSources to be merged at a timeFlowable instanceNullPointerException - ifsources isnullIllegalArgumentException - ifmaxConcurrency is non-positive@BackpressureSupport(value=FULL)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullFlowable<T> mergeDelayError(@NonNullMaybeSource<? extends T> source1,@NonNullMaybeSource<? extends T> source2)
MaybeSources into oneFlowable, in a way that allows a subscriber to receive all successfully emitted items from each of the sourceMaybeSources without being interrupted by an error notification from one of them.
This behaves likemerge(MaybeSource, MaybeSource) except that if any of the mergedMaybeSources notify of an error viaonError,mergeDelayError will refrain from propagating that error notification until all of the mergedMaybeSources have finished emitting items.
Even if both mergedMaybeSources sendonError notifications,mergeDelayError will only invoke theonError method of its subscribers once.
mergeDelayError does not operate by default on a particularScheduler.T - the common element base typesource1 - aMaybeSource to be mergedsource2 - aMaybeSource to be mergedFlowable instanceNullPointerException - ifsource1 orsource2 isnull@BackpressureSupport(value=FULL)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullFlowable<T> mergeDelayError(@NonNullMaybeSource<? extends T> source1,@NonNullMaybeSource<? extends T> source2,@NonNullMaybeSource<? extends T> source3)
MaybeSource into oneFlowable, in a way that allows a subscriber to receive all successfully emitted items from all of the sourceMaybeSources without being interrupted by an error notification from one of them.
This behaves likemerge(MaybeSource, MaybeSource, MaybeSource) except that if any of the mergedMaybeSources notify of an error viaonError,mergeDelayError will refrain from propagating that error notification until all of the mergedMaybeSources have finished emitting items.
Even if multiple mergedMaybeSources sendonError notifications,mergeDelayError will only invoke theonError method of its subscribers once.
mergeDelayError does not operate by default on a particularScheduler.T - the common element base typesource1 - aMaybeSource to be mergedsource2 - aMaybeSource to be mergedsource3 - aMaybeSource to be mergedFlowable instanceNullPointerException - ifsource1,source2 orsource3 isnull@BackpressureSupport(value=FULL)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullFlowable<T> mergeDelayError(@NonNullMaybeSource<? extends T> source1,@NonNullMaybeSource<? extends T> source2,@NonNullMaybeSource<? extends T> source3,@NonNullMaybeSource<? extends T> source4)
MaybeSources into oneFlowable, in a way that allows a subscriber to receive all successfully emitted items from all of the sourceMaybeSources without being interrupted by an error notification from one of them.
This behaves likemerge(MaybeSource, MaybeSource, MaybeSource, MaybeSource) except that if any of the mergedMaybeSources notify of an error viaonError,mergeDelayError will refrain from propagating that error notification until all of the mergedMaybeSources have finished emitting items.
Even if multiple mergedMaybeSources sendonError notifications,mergeDelayError will only invoke theonError method of its subscribers once.
mergeDelayError does not operate by default on a particularScheduler.T - the common element base typesource1 - aMaybeSource to be mergedsource2 - aMaybeSource to be mergedsource3 - aMaybeSource to be mergedsource4 - aMaybeSource to be mergedFlowable instanceNullPointerException - ifsource1,source2,source3 orsource4 isnull@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic static <T> @NonNullMaybe<T> never()
Maybe that never sends any items or notifications to aMaybeObserver.
ThisMaybe is useful primarily for testing purposes.
never does not operate by default on a particularScheduler.T - the type of items (not) emitted by theMaybeMaybe instance@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic static <T> @NonNullSingle<Boolean> sequenceEqual(@NonNullMaybeSource<? extends T> source1,@NonNullMaybeSource<? extends T> source2)
Single that emits aBoolean value that indicates whether twoMaybeSource sequences are the same by comparing the items emitted by eachMaybeSource pairwise.
sequenceEqual does not operate by default on a particularScheduler.T - the type of items emitted by eachMaybeSourcesource1 - the firstMaybeSource to comparesource2 - the secondMaybeSource to compareSingle instanceNullPointerException - ifsource1 orsource2 isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullSingle<Boolean> sequenceEqual(@NonNullMaybeSource<? extends T> source1,@NonNullMaybeSource<? extends T> source2,@NonNullBiPredicate<? super T,? super T> isEqual)
Single that emits aBoolean value that indicates whether twoMaybeSources are the same by comparing the items emitted by eachMaybeSource pairwise based on the results of a specified equality function.
sequenceEqual does not operate by default on a particularScheduler.T - the type of items emitted by eachMaybeSourcesource1 - the firstMaybeSource to comparesource2 - the secondMaybeSource to compareisEqual - a function used to compare items emitted by eachMaybeSourceSingle instanceNullPointerException - ifsource1,source2 orisEqual isnull@BackpressureSupport(value=UNBOUNDED_IN)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullFlowable<T> switchOnNext(@NonNullPublisher<? extendsMaybeSource<? extends T>> sources)
MaybeSources emitted by the sourcePublisher whenever a newMaybeSource is emitted, disposing the previously runningMaybeSource, exposing the success items as aFlowable sequence.
sourcesPublisher is consumed in an unbounded manner (requestingLong.MAX_VALUE). The returnedFlowable respects the backpressure from the downstream.switchOnNext does not operate by default on a particularScheduler.sourcesPublisher or the currently runningMaybeSource, disposing the rest. Late errors are forwarded to the global error handler viaRxJavaPlugins.onError(Throwable).T - the element type of theMaybeSourcessources - thePublisher sequence of innerMaybeSources to switch betweenFlowable instanceNullPointerException - ifsources isnullswitchOnNextDelayError(Publisher),ReactiveX operators documentation: Switch@BackpressureSupport(value=FULL)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullFlowable<T> switchOnNextDelayError(@NonNullPublisher<? extendsMaybeSource<? extends T>> sources)
MaybeSources emitted by the sourcePublisher whenever a newMaybeSource is emitted, disposing the previously runningMaybeSource, exposing the success items as aFlowable sequence and delaying all errors from all of them until all terminate.
sourcesPublisher is consumed in an unbounded manner (requestingLong.MAX_VALUE). The returnedFlowable respects the backpressure from the downstream.switchOnNextDelayError does not operate by default on a particularScheduler.Flowable collects all errors emitted by either thesourcesPublisher or any innerMaybeSource and emits them as aCompositeException when all sources terminate. If only one source ever failed, its error is emitted as-is at the end.T - the element type of theMaybeSourcessources - thePublisher sequence of innerMaybeSources to switch betweenFlowable instanceNullPointerException - ifsources isnullswitchOnNext(Publisher),ReactiveX operators documentation: Switch@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")@NonNullpublic static @NonNullMaybe<Long> timer(long delay,@NonNullTimeUnit unit)
Maybe that emits0L after a specified delay.
timer operates by default on thecomputationScheduler.delay - the initial delay before emitting a single0Lunit - time units to use fordelayMaybe instanceNullPointerException - ifunit isnull@CheckReturnValue@NonNull@SchedulerSupport(value="custom")public static @NonNullMaybe<Long> timer(long delay,@NonNullTimeUnit unit,@NonNullScheduler scheduler)
Maybe that emits0L after a specified delay on a specifiedScheduler.
Scheduler this operator will use.delay - the initial delay before emitting a single 0Lunit - time units to use fordelayscheduler - theScheduler to use for scheduling the itemMaybe instanceNullPointerException - ifunit orscheduler isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullMaybe<T> unsafeCreate(@NonNullMaybeSource<T> onSubscribe)
Maybe instance without any safeguards by using a callback that is called with aMaybeObserver.
unsafeCreate does not operate by default on a particularScheduler.T - the value typeonSubscribe - the function that is called with the subscribingMaybeObserverMaybe instanceIllegalArgumentException - ifonSubscribe is aMaybeNullPointerException - ifonSubscribe isnull@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic static <T,D> @NonNullMaybe<T> using(@NonNullSupplier<? extends D> resourceSupplier,@NonNullFunction<? super D,? extendsMaybeSource<? extends T>> sourceSupplier,@NonNullConsumer<? super D> resourceCleanup)
Maybe that creates a dependent resource object which is disposed of when the generatedMaybeSource terminates or the downstream calls dispose().
using does not operate by default on a particularScheduler.T - the element type of the generatedMaybeSourceD - the type of the resource associated with the output sequenceresourceSupplier - the factory function to create a resource object that depends on theMaybesourceSupplier - the factory function to create aMaybeSourceresourceCleanup - the function that will dispose of the resourceMaybe instanceNullPointerException - ifresourceSupplier,sourceSupplier orresourceCleanup isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T,D> @NonNullMaybe<T> using(@NonNullSupplier<? extends D> resourceSupplier,@NonNullFunction<? super D,? extendsMaybeSource<? extends T>> sourceSupplier,@NonNullConsumer<? super D> resourceCleanup, boolean eager)
Maybe that creates a dependent resource object which is disposed first ({code eager == true}) when the generatedMaybeSource terminates or the downstream disposes; or after ({code eager == false}).
Eager disposal is particularly appropriate for a synchronousMaybe that reuses resources.disposeAction will only be called once per subscription.
using does not operate by default on a particularScheduler.T - the element type of the generatedMaybeSourceD - the type of the resource associated with the output sequenceresourceSupplier - the factory function to create a resource object that depends on theMaybesourceSupplier - the factory function to create aMaybeSourceresourceCleanup - the function that will dispose of the resourceeager - Iftrue then resource disposal will happen either on adispose() call before the upstream is disposed or just before the emission of a terminal event (onSuccess,onComplete oronError). Iffalse the resource disposal will happen either on adispose() call after the upstream is disposed or just after the emission of a terminal event (onSuccess,onComplete oronError).Maybe instanceNullPointerException - ifresourceSupplier,sourceSupplier orresourceCleanup isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T> @NonNullMaybe<T> wrap(@NonNullMaybeSource<T> source)
MaybeSource instance into a newMaybe instance if not already aMaybe instance.
wrap does not operate by default on a particularScheduler.T - the value typesource - the source to wrapMaybe instanceNullPointerException - ifsource isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T,R> @NonNullMaybe<R> zip(@NonNullIterable<? extendsMaybeSource<? extends T>> sources,@NonNullFunction<? superObject[],? extends R> zipper)
Maybe that emits the results of a specified combiner function applied to combinations of items emitted, in sequence, by anIterable of otherMaybeSources.
Note on method signature: since Java doesn't allow creating a generic array withnew T[], the implementation of this operator has to create anObject[] instead. Unfortunately, aFunction<Integer[], R> passed to the method would trigger aClassCastException.
This operator terminates eagerly if any of the sourceMaybeSources signal anonError oronComplete. This also means it is possible some sources may not get subscribed to at all.
zip does not operate by default on a particularScheduler.T - the common value typeR - the zipped result typesources - anIterable of sourceMaybeSourceszipper - a function that, when applied to an item emitted by each of the sourceMaybeSources, results in an item that will be emitted by the resultingMaybeMaybe instanceNullPointerException - ifzipper orsources isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T1,T2,R> @NonNullMaybe<R> zip(@NonNullMaybeSource<? extends T1> source1,@NonNullMaybeSource<? extends T2> source2,@NonNullBiFunction<? 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 otherMaybeSources.
This operator terminates eagerly if any of the sourceMaybeSources signal anonError oronComplete. This also means it is possible some sources may not get subscribed to at all.
zip does not operate by default on a particularScheduler.T1 - the value type of the first sourceT2 - the value type of the second sourceR - the zipped result typesource1 - the first sourceMaybeSourcesource2 - a second sourceMaybeSourcezipper - a function that, when applied to an item emitted by each of the sourceMaybeSources, results in an item that will be emitted by the resultingMaybeMaybe instanceNullPointerException - ifsource1,source2 orzipper isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T1,T2,T3,R> @NonNullMaybe<R> zip(@NonNullMaybeSource<? extends T1> source1,@NonNullMaybeSource<? extends T2> source2,@NonNullMaybeSource<? extends T3> source3,@NonNullFunction3<? 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 otherMaybeSources.
This operator terminates eagerly if any of the sourceMaybeSources signal anonError oronComplete. This also means it is possible some sources may not get subscribed to at all.
zip does not operate by default on a particularScheduler.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 sourceMaybeSourcesource2 - a second sourceMaybeSourcesource3 - a third sourceMaybeSourcezipper - a function that, when applied to an item emitted by each of the sourceMaybeSources, results in an item that will be emitted by the resultingMaybeMaybe instanceNullPointerException - ifsource1,source2,source3 orzipper isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T1,T2,T3,T4,R> @NonNullMaybe<R> zip(@NonNullMaybeSource<? extends T1> source1,@NonNullMaybeSource<? extends T2> source2,@NonNullMaybeSource<? extends T3> source3,@NonNullMaybeSource<? extends T4> source4,@NonNullFunction4<? 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 otherMaybeSources.
This operator terminates eagerly if any of the sourceMaybeSources signal anonError oronComplete. This also means it is possible some sources may not get subscribed to at all.
zip does not operate by default on a particularScheduler.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 sourceMaybeSourcesource2 - a second sourceMaybeSourcesource3 - a third sourceMaybeSourcesource4 - a fourth sourceMaybeSourcezipper - a function that, when applied to an item emitted by each of the sourceMaybeSources, results in an item that will be emitted by the resultingMaybeMaybe instanceNullPointerException - ifsource1,source2,source3,source4 orzipper isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T1,T2,T3,T4,T5,R> @NonNullMaybe<R> zip(@NonNullMaybeSource<? extends T1> source1,@NonNullMaybeSource<? extends T2> source2,@NonNullMaybeSource<? extends T3> source3,@NonNullMaybeSource<? extends T4> source4,@NonNullMaybeSource<? extends T5> source5,@NonNullFunction5<? 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 otherMaybeSources.
This operator terminates eagerly if any of the sourceMaybeSources signal anonError oronComplete. This also means it is possible some sources may not get subscribed to at all.
zip does not operate by default on a particularScheduler.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 sourceMaybeSourcesource2 - a second sourceMaybeSourcesource3 - a third sourceMaybeSourcesource4 - a fourth sourceMaybeSourcesource5 - a fifth sourceMaybeSourcezipper - a function that, when applied to an item emitted by each of the sourceMaybeSources, results in an item that will be emitted by the resultingMaybeMaybe instanceNullPointerException - ifsource1,source2,source3,source4,source5 orzipper isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T1,T2,T3,T4,T5,T6,R> @NonNullMaybe<R> zip(@NonNullMaybeSource<? extends T1> source1,@NonNullMaybeSource<? extends T2> source2,@NonNullMaybeSource<? extends T3> source3,@NonNullMaybeSource<? extends T4> source4,@NonNullMaybeSource<? extends T5> source5,@NonNullMaybeSource<? extends T6> source6,@NonNullFunction6<? 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 otherMaybeSources.
This operator terminates eagerly if any of the sourceMaybeSources signal anonError oronComplete. This also means it is possible some sources may not get subscribed to at all.
zip does not operate by default on a particularScheduler.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 sourceMaybeSourcesource2 - a second sourceMaybeSourcesource3 - a third sourceMaybeSourcesource4 - a fourth sourceMaybeSourcesource5 - a fifth sourceMaybeSourcesource6 - a sixth sourceMaybeSourcezipper - a function that, when applied to an item emitted by each of the sourceMaybeSources, results in an item that will be emitted by the resultingMaybeMaybe instanceNullPointerException - ifsource1,source2,source3,source4,source5,source6 orzipper isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T1,T2,T3,T4,T5,T6,T7,R> @NonNullMaybe<R> zip(@NonNullMaybeSource<? extends T1> source1,@NonNullMaybeSource<? extends T2> source2,@NonNullMaybeSource<? extends T3> source3,@NonNullMaybeSource<? extends T4> source4,@NonNullMaybeSource<? extends T5> source5,@NonNullMaybeSource<? extends T6> source6,@NonNullMaybeSource<? extends T7> source7,@NonNullFunction7<? 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 otherMaybeSources.
This operator terminates eagerly if any of the sourceMaybeSources signal anonError oronComplete. This also means it is possible some sources may not get subscribed to at all.
zip does not operate by default on a particularScheduler.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 sourceMaybeSourcesource2 - a second sourceMaybeSourcesource3 - a third sourceMaybeSourcesource4 - a fourth sourceMaybeSourcesource5 - a fifth sourceMaybeSourcesource6 - a sixth sourceMaybeSourcesource7 - a seventh sourceMaybeSourcezipper - a function that, when applied to an item emitted by each of the sourceMaybeSources, results in an item that will be emitted by the resultingMaybeMaybe instanceNullPointerException - ifsource1,source2,source3,source4,source5,source6,source7 orzipper isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T1,T2,T3,T4,T5,T6,T7,T8,R> @NonNullMaybe<R> zip(@NonNullMaybeSource<? extends T1> source1,@NonNullMaybeSource<? extends T2> source2,@NonNullMaybeSource<? extends T3> source3,@NonNullMaybeSource<? extends T4> source4,@NonNullMaybeSource<? extends T5> source5,@NonNullMaybeSource<? extends T6> source6,@NonNullMaybeSource<? extends T7> source7,@NonNullMaybeSource<? extends T8> source8,@NonNullFunction8<? 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 otherMaybeSources.
This operator terminates eagerly if any of the sourceMaybeSources signal anonError oronComplete. This also means it is possible some sources may not get subscribed to at all.
zip does not operate by default on a particularScheduler.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 sourceMaybeSourcesource2 - a second sourceMaybeSourcesource3 - a third sourceMaybeSourcesource4 - a fourth sourceMaybeSourcesource5 - a fifth sourceMaybeSourcesource6 - a sixth sourceMaybeSourcesource7 - a seventh sourceMaybeSourcesource8 - an eighth sourceMaybeSourcezipper - a function that, when applied to an item emitted by each of the sourceMaybeSources, results in an item that will be emitted by the resultingMaybeMaybe instanceNullPointerException - ifsource1,source2,source3,source4,source5,source6,source7,source8 orzipper isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public static <T1,T2,T3,T4,T5,T6,T7,T8,T9,R> @NonNullMaybe<R> zip(@NonNullMaybeSource<? extends T1> source1,@NonNullMaybeSource<? extends T2> source2,@NonNullMaybeSource<? extends T3> source3,@NonNullMaybeSource<? extends T4> source4,@NonNullMaybeSource<? extends T5> source5,@NonNullMaybeSource<? extends T6> source6,@NonNullMaybeSource<? extends T7> source7,@NonNullMaybeSource<? extends T8> source8,@NonNullMaybeSource<? extends T9> source9,@NonNullFunction9<? 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 otherMaybeSources.
This operator terminates eagerly if any of the sourceMaybeSources signal anonError oronComplete. This also means it is possible some sources may not get subscribed to at all.
zip does not operate by default on a particularScheduler.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 sourceMaybeSourcesource2 - a second sourceMaybeSourcesource3 - a third sourceMaybeSourcesource4 - a fourth sourceMaybeSourcesource5 - a fifth sourceMaybeSourcesource6 - a sixth sourceMaybeSourcesource7 - a seventh sourceMaybeSourcesource8 - an eighth sourceMaybeSourcesource9 - a ninth sourceMaybeSourcezipper - a function that, when applied to an item emitted by each of the sourceMaybeSources, results in an item that will be emitted by the resultingMaybeMaybe instanceNullPointerException - ifsource1,source2,source3,source4,source5,source6,source7,source8,source9 orzipper isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")@SafeVarargspublic static <T,R> @NonNullMaybe<R> zipArray(@NonNullFunction<? superObject[],? extends R> zipper,@NonNullMaybeSource<? 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 otherMaybeSources. Note on method signature: since Java doesn't allow creating a generic array withnew T[], the implementation of this operator has to create anObject[] instead. Unfortunately, aFunction<Integer[], R> passed to the method would trigger aClassCastException.

This operator terminates eagerly if any of the sourceMaybeSources signal anonError oronComplete. This also means it is possible some sources may not get subscribed to at all.
zipArray does not operate by default on a particularScheduler.T - the common element typeR - the result typesources - an array of sourceMaybeSourceszipper - a function that, when applied to an item emitted by each of the sourceMaybeSources, results in an item that will be emitted by the resultingMaybeMaybe instanceNullPointerException - ifsources orzipper isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final @NonNullMaybe<T> ambWith(@NonNullMaybeSource<? extendsT> other)
MaybeSource (current or provided) that first signals an event.
ambWith does not operate by default on a particularScheduler.other - aMaybeSource competing to react first. A subscription to this provided source will occur after subscribing to the current source.Maybe instanceNullPointerException - ifother isnull@CheckReturnValue@SchedulerSupport(value="none")@Nullablepublic 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 particularScheduler.Exception intoRuntimeException and throws that. Otherwise,RuntimeExceptions andErrors are rethrown as they are.@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final T blockingGet(@NonNullT 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 particularScheduler.Exception intoRuntimeException and throws that. Otherwise,RuntimeExceptions andErrors are rethrown as they are.defaultValue - the default item to return if thisMaybe is emptyNullPointerException - ifdefaultValue isnull@SchedulerSupport(value="none")public final void blockingSubscribe()
Maybe andblocks the current thread until it terminates.
blockingSubscribe does not operate by default on a particularScheduler.Maybe signals an error, theThrowable is routed to the global error handler viaRxJavaPlugins.onError(Throwable). If the current thread is interrupted, anInterruptedException is routed to the same global error handler.@SchedulerSupport(value="none")public final void blockingSubscribe(@NonNullConsumer<? superT> onSuccess)
Maybe and calls givenonSuccess callback on thecurrent thread when it completes normally.
blockingSubscribe does not operate by default on a particularScheduler.Maybe signals an error oronSuccess throws, the respectiveThrowable is routed to the global error handler viaRxJavaPlugins.onError(Throwable). If the current thread is interrupted, anInterruptedException is routed to the same global error handler.onSuccess - theConsumer to call if the currentMaybe succeedsNullPointerException - ifonSuccess isnullblockingSubscribe(Consumer, Consumer),blockingSubscribe(Consumer, Consumer, Action)@SchedulerSupport(value="none")public final void blockingSubscribe(@NonNullConsumer<? superT> onSuccess,@NonNullConsumer<? superThrowable> onError)
Maybe and calls the appropriate callback on thecurrent thread when it terminates.
blockingSubscribe does not operate by default on a particularScheduler.onSuccess oronError throw, theThrowable is routed to the global error handler viaRxJavaPlugins.onError(Throwable). If the current thread is interrupted, theonError consumer is called with anInterruptedException.onSuccess - theConsumer to call if the currentMaybe succeedsonError - theConsumer to call if the currentMaybe signals an errorNullPointerException - ifonSuccess oronError isnullblockingSubscribe(Consumer, Consumer, Action)@SchedulerSupport(value="none")public final void blockingSubscribe(@NonNullConsumer<? superT> onSuccess,@NonNullConsumer<? superThrowable> onError,@NonNullAction onComplete)
Maybe and calls the appropriate callback on thecurrent thread when it terminates.
blockingSubscribe does not operate by default on a particularScheduler.onSuccess,onError oronComplete throw, theThrowable is routed to the global error handler viaRxJavaPlugins.onError(Throwable). If the current thread is interrupted, theonError consumer is called with anInterruptedException.onSuccess - theConsumer to call if the currentMaybe succeedsonError - theConsumer to call if the currentMaybe signals an erroronComplete - theAction to call if the currentMaybe completes without a valueNullPointerException - ifonSuccess,onError oronComplete isnull@SchedulerSupport(value="none")public final void blockingSubscribe(@NonNullMaybeObserver<? superT> observer)
Maybe and calls the appropriateMaybeObserver method on thecurrent thread.
blockingSubscribe does not operate by default on a particularScheduler.onError signal is delivered to theMaybeObserver.onError(Throwable) method. If any of theMaybeObserver's methods throw, theRuntimeException is propagated to the caller of this method. If the current thread is interrupted, anInterruptedException is delivered toobserver.onError.observer - theMaybeObserver to call methods on the current threadNullPointerException - ifobserver isnull@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final @NonNullMaybe<T> cache()
Maybe that subscribes to thisMaybe 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 thisMaybe.
Note: You sacrifice the ability to dispose the origin when you use thecache.
cache does not operate by default on a particularScheduler.Maybe instance@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <U> @NonNullMaybe<U> cast(@NonNullClass<? extends U> clazz)
Maybe into the target type or signals aClassCastException if not compatible.
cast does not operate by default on a particularScheduler.U - the target typeclazz - the type token to use for casting the success result from the currentMaybeMaybe instanceNullPointerException - ifclazz isnull@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final <R> @NonNullMaybe<R> compose(@NonNullMaybeTransformer<? superT,? extends R> transformer)
Maybe by applying a particularMaybeTransformer function to it.
This method operates on theMaybe itself whereaslift(io.reactivex.rxjava3.core.MaybeOperator<? extends R, ? super T>) operates on theMaybe'sMaybeObservers.
If the operator you are creating is designed to act on the individual item emitted by aMaybe, uselift(io.reactivex.rxjava3.core.MaybeOperator<? extends R, ? super T>). If your operator is designed to transform the currentMaybe as a whole (for instance, by applying a particular set of existing RxJava operators to it) usecompose.
compose does not operate by default on a particularScheduler.R - the value type of theMaybe returned by the transformer functiontransformer - the transformer function, notnullMaybe instanceNullPointerException - iftransformer isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <R> @NonNullMaybe<R> concatMap(@NonNullFunction<? superT,? extendsMaybeSource<? extends R>> mapper)
Maybe that is based on applying a specified function to the item emitted by the currentMaybe, where that function returns aMaybeSource.
Note that flatMap and concatMap forMaybe is the same operation.
concatMap does not operate by default on a particularScheduler.R - the result value typemapper - a function that, when applied to the item emitted by the currentMaybe, returns aMaybeSourceMaybe instanceNullPointerException - ifmapper isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final @NonNullCompletable concatMapCompletable(@NonNullFunction<? superT,? extendsCompletableSource> mapper)
Completable that completes based on applying a specified function to the item emitted by the currentMaybe, where that function returns aCompletable.
This operator is an alias forflatMapCompletable(Function).
concatMapCompletable does not operate by default on a particularScheduler.mapper - a function that, when applied to the item emitted by the currentMaybe, returns aCompletableCompletable instanceNullPointerException - ifmapper isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <R> @NonNullMaybe<R> concatMapSingle(@NonNullFunction<? superT,? extendsSingleSource<? extends R>> mapper)
Maybe based on applying a specified function to the item emitted by the currentMaybe, where that function returns aSingle. When thisMaybe just completes the resultingMaybe completes as well.
This operator is an alias forflatMapSingle(Function).
concatMapSingle does not operate by default on a particularScheduler.R - the result value typemapper - a function that, when applied to the item emitted by the currentMaybe, returns aSingleMaybe instanceNullPointerException - ifmapper isnull@BackpressureSupport(value=FULL)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final @NonNullFlowable<T> concatWith(@NonNullMaybeSource<? extendsT> other)
Flowable that emits the items emitted from the currentMaybe, then theotherMaybeSource, one after the other, without interleaving them.
concatWith does not operate by default on a particularScheduler.other - aMaybeSource to be concatenated after the currentFlowable instanceNullPointerException - ifother isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final @NonNullSingle<Boolean> contains(@NonNullObject item)
Single that emits aBoolean that indicates whether the currentMaybe emitted a specified item.
contains does not operate by default on a particularScheduler.item - the item to search for in the emissions from the currentMaybe, notnullSingle instanceNullPointerException - ifitem isnull@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final @NonNullSingle<Long> count()
Single that counts the total number of items emitted (0 or 1) by the currentMaybe and emits this count as a 64-bitLong.
count does not operate by default on a particularScheduler.Single instance@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final @NonNullSingle<T> defaultIfEmpty(@NonNullT defaultItem)
Single that emits the item emitted by the currentMaybe or a specified default item if the currentMaybe is empty.
defaultIfEmpty does not operate by default on a particularScheduler.defaultItem - the item to emit if the currentMaybe emits no itemsSingle instanceNullPointerException - ifdefaultItem isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <R> @NonNullMaybe<R> dematerialize(@NonNullFunction<? superT,Notification<R>> selector)
Notification success value of the currentMaybe back into normalonSuccess,onError oronComplete signals.
The intended use of theselector function is to perform a type-safe identity mapping (see example) on a source that is already of typeNotification<T>. The Java language doesn't allow limiting instance methods to a certain generic argument shape, therefore, a function is used to ensure the conversion remains type safe.
RegularonError oronComplete signals from the currentMaybe are passed along to the downstream.
dematerialize does not operate by default on a particularScheduler.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 aNotification instance.Maybe instanceNullPointerException - ifselector isnullmaterialize()@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")@NonNullpublic final @NonNullMaybe<T> delay(long time,@NonNullTimeUnit unit)
Maybe that signals the events emitted by the currentMaybe shifted forward in time by a specified delay. An error signal will not be delayed.
delay operates by default on thecomputationScheduler.time - the delay to shift the source byunit - theTimeUnit in whichtime is definedMaybe instanceNullPointerException - ifunit isnulldelay(long, TimeUnit, Scheduler, boolean)@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")@NonNullpublic final @NonNullMaybe<T> delay(long time,@NonNullTimeUnit unit, boolean delayError)
Maybe that signals the events emitted by the currentMaybe shifted forward in time by a specified delay.
delay operates by default on thecomputationScheduler.time - the delay to shift the source byunit - theTimeUnit in whichtime is defineddelayError - iftrue, both success and error signals are delayed. iffalse, only success signals are delayed.Maybe instanceNullPointerException - ifunit isnulldelay(long, TimeUnit, Scheduler, boolean)@CheckReturnValue@SchedulerSupport(value="custom")@NonNullpublic final @NonNullMaybe<T> delay(long time,@NonNullTimeUnit unit,@NonNullScheduler scheduler)
Maybe that signals the events emitted by the currentMaybe 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 - theTimeUnit in whichtime is definedscheduler - theScheduler to use for delayingMaybe instanceNullPointerException - ifunit orscheduler isnulldelay(long, TimeUnit, Scheduler, boolean)@CheckReturnValue@NonNull@SchedulerSupport(value="custom")public final @NonNullMaybe<T> delay(long time,@NonNullTimeUnit unit,@NonNullScheduler scheduler, boolean delayError)
Maybe that signals the events emitted by the currentMaybe shifted forward in time by a specified delay running on the specifiedScheduler.
Scheduler this operator will use.time - the delay to shift the source byunit - theTimeUnit in whichtime is definedscheduler - theScheduler to use for delayingdelayError - iftrue, both success and error signals are delayed. iffalse, only success signals are delayed.Maybe instanceNullPointerException - ifunit orscheduler isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")@BackpressureSupport(value=UNBOUNDED_IN)public final <U> @NonNullMaybe<T> delay(@NonNullPublisher<U> delayIndicator)
Maybe until the givenPublisher 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 particularScheduler.U - the subscription delay value type (ignored)delayIndicator - thePublisher that gets subscribed to when thisMaybe signals an event and that signal is emitted when thePublisher signals an item or completesMaybe instanceNullPointerException - ifdelayIndicator isnull@BackpressureSupport(value=UNBOUNDED_IN)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <U> @NonNullMaybe<T> delaySubscription(@NonNullPublisher<U> subscriptionIndicator)
Maybe that delays the subscription to thisMaybe until the otherPublisher emits an element or completes normally.
Publisher source is consumed in an unbounded fashion (without applying backpressure).Scheduler.U - the value type of the otherPublisher, irrelevantsubscriptionIndicator - the otherPublisher that should trigger the subscription to thisPublisher.Maybe instanceNullPointerException - ifsubscriptionIndicator isnull@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")@NonNullpublic final @NonNullMaybe<T> delaySubscription(long time,@NonNullTimeUnit unit)
Maybe that delays the subscription to the currentMaybe by a given amount of time.
delaySubscription operates by default on thecomputationScheduler.time - the time to delay the subscriptionunit - the time unit ofdelayMaybe instanceNullPointerException - ifunit isnulldelaySubscription(long, TimeUnit, Scheduler)@CheckReturnValue@SchedulerSupport(value="custom")@NonNullpublic final @NonNullMaybe<T> delaySubscription(long time,@NonNullTimeUnit unit,@NonNullScheduler scheduler)
Maybe that delays the subscription to the currentMaybe by a given amount of time, both waiting and subscribing on a givenScheduler.
Scheduler this operator will use.time - the time to delay the subscriptionunit - the time unit ofdelayscheduler - theScheduler on which the waiting and subscription will happenMaybe instanceNullPointerException - ifunit orscheduler isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final @NonNullMaybe<T> doAfterSuccess(@NonNullConsumer<? superT> onAfterSuccess)
Consumer with the success item after this item has been emitted to the downstream.Note that theonAfterSuccess action is shared between subscriptions and as such should be thread-safe.

doAfterSuccess does not operate by default on a particularScheduler.History: 2.0.1 - experimental
onAfterSuccess - theConsumer that will be called after emitting an item from upstream to the downstreamMaybe instanceNullPointerException - ifonAfterSuccess isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final @NonNullMaybe<T> doAfterTerminate(@NonNullAction onAfterTerminate)
Action to be called when thisMaybe invokes eitheronSuccess,onComplete oronError.
doAfterTerminate does not operate by default on a particularScheduler.onAfterTerminate - anAction to be invoked when the currentMaybe finishesMaybe instanceNullPointerException - ifonAfterTerminate isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final @NonNullMaybe<T> doFinally(@NonNullAction onFinally)
Maybe signalsonSuccess,onError oronComplete or gets disposed by the downstream.
In case of a race between a terminal event and a dispose call, the providedonFinally action is executed once per subscription.
Note that theonFinally action is shared between subscriptions and as such should be thread-safe.
doFinally does not operate by default on a particularScheduler.History: 2.0.1 - experimental
onFinally - the action called when thisMaybe terminates or gets disposedMaybe instanceNullPointerException - ifonFinally isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final @NonNullMaybe<T> doOnDispose(@NonNullAction onDispose)
Action if aMaybeObserver subscribed to the currentMaybe disposes the commonDisposable it received viaonSubscribe.
doOnDispose does not operate by default on a particularScheduler.onDispose - the action called when the subscription is disposedMaybe instanceNullPointerException - ifonDispose isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final @NonNullMaybe<T> doOnComplete(@NonNullAction onComplete)
Action just before the currentMaybe callsonComplete.
doOnComplete does not operate by default on a particularScheduler.onComplete - the action to invoke when the currentMaybe callsonCompleteMaybe with the side-effecting behavior appliedNullPointerException - ifonComplete isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final @NonNullMaybe<T> doOnError(@NonNullConsumer<? superThrowable> onError)
Consumer with the error sent viaonError for eachMaybeObserver that subscribes to the currentMaybe.
doOnError does not operate by default on a particularScheduler.onError - the consumer called with the success value ofonErrorMaybe instanceNullPointerException - ifonError isnull@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final @NonNullMaybe<T> doOnEvent(@NonNullBiConsumer<? superT,? superThrowable> onEvent)
onEvent callback with the (success value,null) for anonSuccess, (null, throwable) for anonError or (null,null) for anonComplete signal from thisMaybe 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 particularScheduler.onEvent - the callback to call with the success value or the exception, whichever is notnullMaybe instanceNullPointerException - ifonEvent isnull@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final @NonNullMaybe<T> doOnLifecycle(@NonNullConsumer<? superDisposable> onSubscribe,@NonNullAction onDispose)
onXXX method (shared between allMaybeObservers) for the lifecycle events of the sequence (subscription, disposal).
doOnLifecycle does not operate by default on a particularScheduler.onSubscribe - aConsumer called with theDisposable sent viaMaybeObserver.onSubscribe(Disposable)onDispose - called when the downstream disposes theDisposable viadispose()Maybe instanceNullPointerException - ifonSubscribe oronDispose isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final @NonNullMaybe<T> doOnSubscribe(@NonNullConsumer<? superDisposable> onSubscribe)
Consumer with theDisposable sent through theonSubscribe for eachMaybeObserver that subscribes to the currentMaybe.
doOnSubscribe does not operate by default on a particularScheduler.onSubscribe - theConsumer called with theDisposable sent viaonSubscribeMaybe instanceNullPointerException - ifonSubscribe isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final @NonNullMaybe<T> doOnTerminate(@NonNullAction onTerminate)
Maybe instance that calls the given onTerminate callback just before thisMaybe completes normally or with an exception.
This differs fromdoAfterTerminate in that this happensbefore theonComplete oronError notification.
doOnTerminate does not operate by default on a particularScheduler.History: 2.2.7 - experimental
onTerminate - the action to invoke when the consumer callsonComplete oronErrorMaybe instanceNullPointerException - ifonTerminate isnulldoOnTerminate(Action)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final @NonNullMaybe<T> doOnSuccess(@NonNullConsumer<? superT> onSuccess)
Consumer with the success value sent viaonSuccess for eachMaybeObserver that subscribes to the currentMaybe.
doOnSuccess does not operate by default on a particularScheduler.onSuccess - theConsumer called with the success value of the upstreamMaybe instanceNullPointerException - ifonSuccess isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final @NonNullMaybe<T> filter(@NonNullPredicate<? superT> predicate)
Maybe via a predicate function and emitting it if the predicate returnstrue, completing otherwise.
filter does not operate by default on a particularScheduler.predicate - a function that evaluates the item emitted by the currentMaybe, returningtrue if it passes the filterMaybe instanceNullPointerException - ifpredicate isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <R> @NonNullMaybe<R> flatMap(@NonNullFunction<? superT,? extendsMaybeSource<? extends R>> mapper)
Maybe that is based on applying a specified function to the item emitted by the currentMaybe, where that function returns aMaybeSource.
flatMap does not operate by default on a particularScheduler.Note that flatMap and concatMap forMaybe is the same operation.
R - the result value typemapper - a function that, when applied to the item emitted by the currentMaybe, returns aMaybeSourceMaybe instanceNullPointerException - ifmapper isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <R> @NonNullMaybe<R> flatMap(@NonNullFunction<? superT,? extendsMaybeSource<? extends R>> onSuccessMapper,@NonNullFunction<? superThrowable,? extendsMaybeSource<? extends R>> onErrorMapper,@NonNullSupplier<? extendsMaybeSource<? extends R>> onCompleteSupplier)
onSuccess,onError oronComplete signals of the currentMaybe into aMaybeSource and emits thatMaybeSource's signals.
flatMap does not operate by default on a particularScheduler.R - the result typeonSuccessMapper - a function that returns aMaybeSource to merge for theonSuccess item emitted by thisMaybeonErrorMapper - a function that returns aMaybeSource to merge for anonError notification from thisMaybeonCompleteSupplier - a function that returns aMaybeSource to merge for anonComplete notification thisMaybeMaybe instanceNullPointerException - ifonSuccessMapper,onErrorMapper oronCompleteSupplier isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <U,R> @NonNullMaybe<R> flatMap(@NonNullFunction<? superT,? extendsMaybeSource<? extends U>> mapper,@NonNullBiFunction<? superT,? super U,? extends R> combiner)
Maybe that emits the results of a specified function to the pair of values emitted by the currentMaybe and a specified mappedMaybeSource.
flatMap does not operate by default on a particularScheduler.U - the type of items emitted by theMaybeSource returned by themapper functionR - the type of items emitted by the resultingMaybemapper - a function that returns aMaybeSource for the item emitted by the currentMaybecombiner - a function that combines one item emitted by each of the source and collectionMaybeSource and returns an item to be emitted by the resultingMaybeSourceMaybe instanceNullPointerException - ifmapper orcombiner isnull@BackpressureSupport(value=FULL)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <U> @NonNullFlowable<U> flattenAsFlowable(@NonNullFunction<? superT,? extendsIterable<? extends U>> mapper)
Maybe into anIterable and emits its items as aFlowable sequence.
flattenAsFlowable does not operate by default on a particularScheduler.U - the type of item emitted by the innerIterablemapper - a function that returns anIterable sequence of values for when given an item emitted by the currentMaybeFlowable instanceNullPointerException - ifmapper isnullflattenStreamAsFlowable(Function)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <U> @NonNullObservable<U> flattenAsObservable(@NonNullFunction<? superT,? extendsIterable<? extends U>> mapper)
Maybe into anIterable and emits its items as anObservable sequence.
flattenAsObservable does not operate by default on a particularScheduler.U - the type of item emitted by the resultingIterablemapper - a function that returns anIterable sequence of values for when given an item emitted by the currentMaybeObservable instanceNullPointerException - ifmapper isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <R> @NonNullObservable<R> flatMapObservable(@NonNullFunction<? superT,? extendsObservableSource<? extends R>> mapper)
Observable that is based on applying a specified function to the item emitted by the currentMaybe, where that function returns anObservableSource.
flatMapObservable does not operate by default on a particularScheduler.R - the result value typemapper - a function that, when applied to the item emitted by the currentMaybe, returns anObservableSourceObservable instanceNullPointerException - ifmapper isnull@BackpressureSupport(value=FULL)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <R> @NonNullFlowable<R> flatMapPublisher(@NonNullFunction<? superT,? extendsPublisher<? extends R>> mapper)
Flowable that emits items based on applying a specified function to the item emitted by the currentMaybe, where that function returns aPublisher.
Flowable honors the downstream backpressure.flatMapPublisher does not operate by default on a particularScheduler.R - the result value typemapper - a function that, when applied to the item emitted by the currentMaybe, returns aFlowableFlowable instanceNullPointerException - ifmapper isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <R> @NonNullMaybe<R> flatMapSingle(@NonNullFunction<? superT,? extendsSingleSource<? extends R>> mapper)
Maybe based on applying a specified function to the item emitted by the currentMaybe, where that function returns aSingle. When thisMaybe just completes the resultingMaybe completes as well.
flatMapSingle does not operate by default on a particularScheduler.History: 2.0.2 - experimental
R - the result value typemapper - a function that, when applied to the item emitted by the currentMaybe, returns aSingleMaybe instanceNullPointerException - ifmapper isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final @NonNullCompletable flatMapCompletable(@NonNullFunction<? superT,? extendsCompletableSource> mapper)
Completable that completes based on applying a specified function to the item emitted by the currentMaybe, where that function returns aCompletable.
flatMapCompletable does not operate by default on a particularScheduler.mapper - a function that, when applied to the item emitted by the currentMaybe, returns aCompletableCompletable instanceNullPointerException - ifmapper isnull@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final @NonNullMaybe<T> hide()
Maybe and itsDisposable.
Allows preventing certain identity-based optimizations (fusion).
hide does not operate by default on a particularScheduler.Maybe instance@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final @NonNullCompletable ignoreElement()
Completable that ignores the item emitted by the currentMaybe and only callsonComplete oronError.
ignoreElement does not operate by default on a particularScheduler.Completable instance@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final @NonNullSingle<Boolean> isEmpty()
Single that emitstrue if the currentMaybe is empty, otherwisefalse.
isEmpty does not operate by default on a particularScheduler.Single instance@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <R> @NonNullMaybe<R> lift(@NonNullMaybeOperator<? extends R,? superT> lift)
Maybe which, when subscribed to, invokes theapply(MaybeObserver) method of the providedMaybeOperator for each individual downstreamMaybe and allows the insertion of a custom operator by accessing the downstream'sMaybeObserver during this subscription phase and providing a newMaybeObserver, containing the custom operator's intended business logic, that will be used in the subscription process going further upstream.
Generally, such a newMaybeObserver will wrap the downstream'sMaybeObserver and forwards theonSuccess,onError andonComplete events from the upstream directly or according to the emission pattern the custom operator's business logic requires. In addition, such operator can intercept the flow control calls ofdispose andisDisposed that would have traveled upstream and perform additional actions depending on the same business logic requirements.
Example:
// Step 1: Create the consumer type that will be returned by the 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 theRxJava wiki: Writing operators page about the tools, requirements, rules, considerations and pitfalls of implementing them.
Note that implementing custom operators via thislift() method adds slightly more overhead by requiring an additional allocation and indirection per assembled flows. Instead, extending the abstractMaybe class and creating aMaybeTransformer with it is recommended.
Note also that it is not possible to stop the subscription phase inlift() as theapply() method requires a non-nullMaybeObserver instance to be returned, which is then unconditionally subscribed to the currentMaybe. 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 aMaybeObserver that should immediately dispose the upstream'sDisposable in itsonSubscribe method. Again, using aMaybeTransformer and extending theMaybe is a better option assubscribeActual(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 particularScheduler, however, theMaybeOperator may use aScheduler to support its own asynchronous behavior.R - the output value typelift - theMaybeOperator that receives the downstream'sMaybeObserver and should return aMaybeObserver with custom behavior to be used as the consumer for the currentMaybe.Maybe instanceNullPointerException - iflift isnullcompose(MaybeTransformer)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <R> @NonNullMaybe<R> map(@NonNullFunction<? superT,? extends R> mapper)
Maybe that applies a specified function to the item emitted by the currentMaybe and emits the result of this function application.
map does not operate by default on a particularScheduler.R - the result value typemapper - a function to apply to the item emitted by theMaybeMaybe instanceNullPointerException - ifmapper isnull@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final @NonNullSingle<Notification<T>> materialize()
Maybe into aNotification of the same kind and emits it as aSingle'sonSuccess value to downstream.
materialize does not operate by default on a particularScheduler.History: 2.2.4 - experimental
Single instanceSingle.dematerialize(Function)@BackpressureSupport(value=FULL)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final @NonNullFlowable<T> mergeWith(@NonNullMaybeSource<? extendsT> other)
Maybe and anotherMaybeSource into a singleFlowable, without any transformation.
You can combine items emitted by multipleMaybes so that they appear as a singleFlowable, by using themergeWith method.
mergeWith does not operate by default on a particularScheduler.other - aMaybeSource to be mergedFlowable instanceNullPointerException - ifother isnull@CheckReturnValue@NonNull@SchedulerSupport(value="custom")public final @NonNullMaybe<T> observeOn(@NonNullScheduler scheduler)
Maybe to emit its item (or notify of its error) on a specifiedScheduler, asynchronously.
Scheduler this operator will use.scheduler - theScheduler to notify subscribers onMaybe instance that its subscribers are notified on the specifiedSchedulerNullPointerException - ifscheduler isnullsubscribeOn(io.reactivex.rxjava3.core.Scheduler)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <U> @NonNullMaybe<U> ofType(@NonNullClass<U> clazz)
Maybe, only emitting its success value if that is an instance of the suppliedClass.
ofType does not operate by default on a particularScheduler.U - the output typeclazz - the class type to filter the items emitted by the currentMaybeMaybe instanceNullPointerException - ifclazz isnull@CheckReturnValue@SchedulerSupport(value="none")public final <R> R to(@NonNullMaybeConverter<T,? extends R> converter)

This allows fluent conversion to any other type.
to does not operate by default on a particularScheduler.History: 2.1.7 - experimental
R - the resulting object typeconverter - the function that receives the currentMaybe instance and returns a valueNullPointerException - ifconverter isnull@BackpressureSupport(value=FULL)@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final @NonNullFlowable<T> toFlowable()
Maybe into a backpressure-awareFlowable instance composing cancellation through.
Flowable honors the backpressure of the downstream.toFlowable does not operate by default on a particularScheduler.Flowable instance@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final @NonNullFuture<T> toFuture()
Future representing the single value emitted by the currentMaybe ornull if the currentMaybe is empty.
Cancelling theFuture will cancel the subscription to the currentMaybe.
toFuture does not operate by default on a particularScheduler.Future instance@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final @NonNullObservable<T> toObservable()
Maybe into anObservable instance composing disposal through.
toObservable does not operate by default on a particularScheduler.Observable instance@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final @NonNullSingle<T> toSingle()
Maybe into aSingle instance composing disposal through and turning an emptyMaybe into a signal ofNoSuchElementException.
toSingle does not operate by default on a particularScheduler.Single instancedefaultIfEmpty(Object)@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final @NonNullMaybe<T> onErrorComplete()
Maybe instance that if thisMaybe emits an error, it will emit anonComplete and swallow the throwable.
onErrorComplete does not operate by default on a particularScheduler.Maybe instance@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final @NonNullMaybe<T> onErrorComplete(@NonNullPredicate<? superThrowable> predicate)
Maybe instance that if thisMaybe emits an error and the predicate returnstrue, it will emit anonComplete and swallow the throwable.
onErrorComplete does not operate by default on a particularScheduler.predicate - the predicate to call when anThrowable is emitted which should returntrue if theThrowable should be swallowed and replaced with anonComplete.Maybe instanceNullPointerException - ifpredicate isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final @NonNullMaybe<T> onErrorResumeWith(@NonNullMaybeSource<? extendsT> fallback)
MaybeSource when the currentMaybe fails instead of signaling the error viaonError.
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 particularScheduler.fallback - the nextMaybeSource that will take over if the currentMaybe encounters an errorMaybe instanceNullPointerException - iffallback isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final @NonNullMaybe<T> onErrorResumeNext(@NonNullFunction<? superThrowable,? extendsMaybeSource<? extendsT>> fallbackSupplier)
MaybeSource returned for the failureThrowable of the currentMaybe by a function instead of signaling the error viaonError.
You can use this to prevent errors from propagating or to supply fallback data should errors be encountered.
onErrorResumeNext does not operate by default on a particularScheduler.fallbackSupplier - a function that returns aMaybeSource that will take over if the currentMaybe encounters an errorMaybe instanceNullPointerException - iffallbackSupplier isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final @NonNullMaybe<T> onErrorReturn(@NonNullFunction<? superThrowable,? extendsT> itemSupplier)
Throwable error signaled by the currentMaybe instead of signaling the error viaonError.
You can use this to prevent errors from propagating or to supply fallback data should errors be encountered.
onErrorReturn does not operate by default on a particularScheduler.itemSupplier - a function that returns a single value that will be emitted as success value the currentMaybe signals anonError eventMaybe instanceNullPointerException - ifitemSupplier isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final @NonNullMaybe<T> onErrorReturnItem(@NonNullT item)
Maybe fails instead of signaling the error viaonError.
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 particularScheduler.item - the value that is emitted asonSuccess in case the currentMaybe signals anonErrorMaybe instanceNullPointerException - ifitem isnull@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final @NonNullMaybe<T> onTerminateDetach()
MaybeObserver if the sequence is terminated or downstream callsdispose().
onTerminateDetach does not operate by default on a particularScheduler.Maybe instance the sequence is terminated or downstream callsdispose()@BackpressureSupport(value=FULL)@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final @NonNullFlowable<T> repeat()
Flowable that repeats the sequence of items emitted by the currentMaybe indefinitely.
repeat does not operate by default on a particularScheduler.Flowable instance@BackpressureSupport(value=FULL)@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final @NonNullFlowable<T> repeat(long times)
Flowable that repeats the sequence of items emitted by the currentMaybe at mostcount times.
repeat does not operate by default on a particularScheduler.times - the number of times the currentMaybe items are repeated, a count of 0 will yield an empty sequenceFlowable instanceIllegalArgumentException - iftimes is negative@BackpressureSupport(value=FULL)@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final @NonNullFlowable<T> repeatUntil(@NonNullBooleanSupplier stop)
Flowable that repeats the sequence of items emitted by the currentMaybe until the provided stop function returnstrue.
repeatUntil does not operate by default on a particularScheduler.stop - a boolean supplier that is called when the currentFlowable completes and unless it returnsfalse, the currentFlowable is resubscribedFlowable instanceNullPointerException - ifstop isnull@BackpressureSupport(value=FULL)@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final @NonNullFlowable<T> repeatWhen(@NonNullFunction<? superFlowable<Object>,? extendsPublisher<?>> handler)
Flowable that emits the same values as the currentMaybe with the exception of anonComplete. AnonComplete notification from the source will result in the emission of avoid item to theFlowable provided as an argument to thenotificationHandler function. If thatPublisher callsonComplete oronError thenrepeatWhen will callonComplete oronError on the child observer. Otherwise, this operator will resubscribe to the currentMaybe.
Publisher to honor backpressure as well. If this expectation is violated, the operatormay throw anIllegalStateException.repeatWhen does not operate by default on a particularScheduler.handler - receives aPublisher of notifications with which a user can complete or error, aborting the repeat.Flowable instanceNullPointerException - ifhandler isnull@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final @NonNullMaybe<T> retry()
Maybe that mirrors the currentMaybe, resubscribing to it if it callsonError (infinite retry count).
If the currentMaybe callsMaybeObserver.onError(java.lang.Throwable), this operator will resubscribe to the currentMaybe rather than propagating theonError call.
retry does not operate by default on a particularScheduler.Maybe instance@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final @NonNullMaybe<T> retry(@NonNullBiPredicate<? superInteger,? superThrowable> predicate)
Maybe that mirrors the currentMaybe, resubscribing to it if it callsonError and the predicate returnstrue for that specific exception and retry count.
retry does not operate by default on a particularScheduler.predicate - the predicate that determines if a resubscription may happen in case of a specific exception and retry countMaybe instanceNullPointerException - ifpredicate isnullretry(),ReactiveX operators documentation: Retry@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final @NonNullMaybe<T> retry(long times)
Maybe that mirrors the currentMaybe, resubscribing to it if it callsonError up to a specified number of retries.
If the currentMaybe callsMaybeObserver.onError(java.lang.Throwable), this operator will resubscribe to the currentMaybe for a maximum ofcount resubscriptions rather than propagating theonError call.
retry does not operate by default on a particularScheduler.times - the number of times to resubscribe if the currentMaybe failsMaybe instanceIllegalArgumentException - iftimes is negative@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final @NonNullMaybe<T> retry(long times,@NonNullPredicate<? superThrowable> predicate)
times or until the predicate returnsfalse, whichever happens first.
retry does not operate by default on a particularScheduler.times - the number of times to resubscribe if the currentMaybe failspredicate - the predicate called with the failureThrowable and should returntrue to trigger a retry.Maybe instanceNullPointerException - ifpredicate isnullIllegalArgumentException - iftimes is negative@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final @NonNullMaybe<T> retry(@NonNullPredicate<? superThrowable> predicate)
Maybe if it fails and the predicate returnstrue.
retry does not operate by default on a particularScheduler.predicate - the predicate that receives the failureThrowable and should returntrue to trigger a retry.Maybe instanceNullPointerException - ifpredicate isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final @NonNullMaybe<T> retryUntil(@NonNullBooleanSupplier stop)
true.
retryUntil does not operate by default on a particularScheduler.stop - the function that should returntrue to stop retryingMaybe instanceNullPointerException - ifstop isnull@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final @NonNullMaybe<T> retryWhen(@NonNullFunction<? superFlowable<Throwable>,? extendsPublisher<?>> handler)
Maybe that emits the same values as the currentMaybe with the exception of anonError. AnonError notification from the source will result in the emission of aThrowable item to theFlowable provided as an argument to thenotificationHandler function. If the returnedPublisher callsonComplete oronError thenretry will callonComplete oronError on the child subscription. Otherwise, this operator will resubscribe to the currentMaybe.
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 innerPublisher returned by the handler function should signal eitheronNext,onError oronComplete in response to the receivedThrowable to indicate the operator should retry or terminate. If the upstream to the operator is asynchronous, signallingonNext followed byonComplete immediately may result in the sequence to be completed immediately. Similarly, if this innerPublisher signalsonError oronComplete while the upstream is active, the sequence is terminated with the same signal immediately.
The following example demonstrates how to retry an asynchronous source with a delay:
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 particularScheduler.handler - receives aPublisher of notifications with which a user can complete or error, aborting the retryMaybe instanceNullPointerException - ifhandler isnull@SchedulerSupport(value="none")public final void safeSubscribe(@NonNullMaybeObserver<? superT> observer)
MaybeObserver, catches anyRuntimeExceptions thrown by itsMaybeObserver.onSubscribe(Disposable),MaybeObserver.onSuccess(Object),MaybeObserver.onError(Throwable) orMaybeObserver.onComplete() methods and routes those to the global error handler viaRxJavaPlugins.onError(Throwable). By default, theMaybe protocol forbids theonXXX methods to throw, but someMaybeObserver 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 particularScheduler.observer - the potentially misbehavingMaybeObserverNullPointerException - ifobserver isnullsubscribe(Consumer,Consumer, Action)@CheckReturnValue@NonNull@SchedulerSupport(value="none")@BackpressureSupport(value=FULL)public final @NonNullFlowable<T> startWith(@NonNullCompletableSource other)
Flowable which first runs the otherCompletableSource then the currentMaybe if the other completed normally.
Flowable honors the backpressure of the downstream consumer.startWith does not operate by default on a particularScheduler.other - the otherCompletableSource to run firstFlowable instanceNullPointerException - ifother isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")@BackpressureSupport(value=FULL)public final @NonNullFlowable<T> startWith(@NonNullSingleSource<T> other)
Flowable which first runs the otherSingleSource then the currentMaybe if the other succeeded normally.
Flowable honors the backpressure of the downstream consumer.startWith does not operate by default on a particularScheduler.other - the otherSingleSource to run firstFlowable instanceNullPointerException - ifother isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")@BackpressureSupport(value=FULL)public final @NonNullFlowable<T> startWith(@NonNullMaybeSource<T> other)
Flowable which first runs the otherMaybeSource then the currentMaybe if the other succeeded or completed normally.
Flowable honors the backpressure of the downstream consumer.startWith does not operate by default on a particularScheduler.other - the otherMaybeSource to run firstFlowable instanceNullPointerException - ifother isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final @NonNullObservable<T> startWith(@NonNullObservableSource<T> other)
Observable which first delivers the events of the otherObservableSource then runs the currentMaybe.
startWith does not operate by default on a particularScheduler.other - the otherObservableSource to run firstObservable instanceNullPointerException - ifother isnull@CheckReturnValue@NonNull@BackpressureSupport(value=FULL)@SchedulerSupport(value="none")public final @NonNullFlowable<T> startWith(@NonNullPublisher<T> other)
Flowable which first delivers the events of the otherPublisher then runs the currentMaybe.
Flowable honors the backpressure of the downstream consumer and expects the otherPublisher to honor it as well.startWith does not operate by default on a particularScheduler.other - the otherPublisher to run firstFlowable instanceNullPointerException - ifother isnull@SchedulerSupport(value="none")@NonNullpublic final @NonNullDisposable subscribe()
Maybe and ignoresonSuccess andonComplete emissions. If theMaybe emits an error, it is wrapped into anOnErrorNotImplementedException and routed to theRxJavaPlugins.onError(Throwable) handler.
subscribe does not operate by default on a particularScheduler.Disposable instance that can be used for disposing the subscription at any timesubscribe(Consumer, Consumer, Action, DisposableContainer)@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final @NonNullDisposable subscribe(@NonNullConsumer<? superT> onSuccess)
Maybe and provides a callback to handle the items it emits. If theMaybe emits an error, it is wrapped into anOnErrorNotImplementedException and routed to theRxJavaPlugins.onError(Throwable) handler.
subscribe does not operate by default on a particularScheduler.onSuccess - theConsumer<T> you have designed to accept a success value from theMaybeDisposable instance that can be used for disposing the subscription at any timeNullPointerException - ifonSuccess isnullsubscribe(Consumer, Consumer, Action, DisposableContainer)@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final @NonNullDisposable subscribe(@NonNullConsumer<? superT> onSuccess,@NonNullConsumer<? superThrowable> 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 particularScheduler.onSuccess - theConsumer<T> you have designed to accept a success value from theMaybeonError - theConsumer<Throwable> you have designed to accept any error notification from theMaybeDisposable instance that can be used for disposing the subscription at any timeNullPointerException - ifonSuccess isnull, or ifonError isnullsubscribe(Consumer, Consumer, Action, DisposableContainer)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final @NonNullDisposable subscribe(@NonNullConsumer<? superT> onSuccess,@NonNullConsumer<? superThrowable> onError,@NonNullAction 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 particularScheduler.onSuccess - theConsumer<T> you have designed to accept a success value from theMaybeonError - theConsumer<Throwable> you have designed to accept any error notification from theMaybeonComplete - theAction you have designed to accept a completion notification from theMaybeDisposable instance that can be used for disposing the subscription at any timeNullPointerException - ifonSuccess,onError oronComplete isnullsubscribe(Consumer, Consumer, Action, DisposableContainer)@SchedulerSupport(value="none")@NonNullpublic final @NonNullDisposable subscribe(@NonNullConsumer<? superT> onSuccess,@NonNullConsumer<? superThrowable> onError,@NonNullAction onComplete,@NonNullDisposableContainer container)
DisposableMaybeObserver, adds it to the givenDisposableContainer and ensures, that if the upstream terminates or this particularDisposable is disposed, theMaybeObserver is removed from the given composite. TheMaybeObserver will be removed after the callback for the terminal event has been invoked.
subscribe does not operate by default on a particularScheduler.onSuccess - the callback for upstream itemsonError - the callback for an upstream erroronComplete - the callback for an upstream completion without any value or errorcontainer - theDisposableContainer (such asCompositeDisposable) to add and remove the createdDisposableMaybeObserverDisposable that allows disposing the particular subscription.NullPointerException - ifonSuccess,onError,onComplete orcontainer isnull@SchedulerSupport(value="none")public final void subscribe(@NonNullMaybeObserver<? superT> observer)
MaybeSourceMaybeObserver to thisMaybeSource instance.subscribe in interface MaybeSource<T>observer - theMaybeObserver, notnullprotected abstract void subscribeActual(@NonNullMaybeObserver<? superT> observer)
MaybeObservers.There is no need to call any of the plugin hooks on the currentMaybe instance or theMaybeObserver; all hooks and basic safeguards have been applied bysubscribe(MaybeObserver) before this method gets called.
observer - theMaybeObserver to handle, notnull@CheckReturnValue@NonNull@SchedulerSupport(value="custom")public final @NonNullMaybe<T> subscribeOn(@NonNullScheduler scheduler)
Maybe on the specifiedScheduler.
Scheduler this operator will use.scheduler - theScheduler to perform subscription actions onMaybe instanceNullPointerException - ifscheduler isnullobserveOn(io.reactivex.rxjava3.core.Scheduler)@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final <E extendsMaybeObserver<? superT>> E subscribeWith(E observer)
MaybeObserver (subclass) to thisMaybe and returns the givenMaybeObserver 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 particularScheduler.E - the type of theMaybeObserver to use and returnobserver - theMaybeObserver (subclass) to use and return, notnullobserverNullPointerException - ifobserver isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final @NonNullMaybe<T> switchIfEmpty(@NonNullMaybeSource<? extendsT> other)
Maybe that emits the items emitted by the currentMaybe or the items of an alternateMaybeSource if the currentMaybe is empty.
switchIfEmpty does not operate by default on a particularScheduler.other - the alternateMaybeSource to subscribe to if the main does not emit any itemsMaybe instanceNullPointerException - ifother isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final @NonNullSingle<T> switchIfEmpty(@NonNullSingleSource<? extendsT> other)
Single that emits the items emitted by the currentMaybe or the item of an alternateSingleSource if the currentMaybe is empty.
switchIfEmpty does not operate by default on a particularScheduler.History: 2.1.4 - experimental
other - the alternateSingleSource to subscribe to if the main does not emit any itemsSingle instanceNullPointerException - ifother isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <U> @NonNullMaybe<T> takeUntil(@NonNullMaybeSource<U> other)
Maybe that emits the items emitted by the currentMaybe until a secondMaybeSource emits an item.
takeUntil does not operate by default on a particularScheduler.U - the type of items emitted byotherother - theMaybeSource whose first emitted item will causetakeUntil to stop emitting items from the currentMaybeMaybe instanceNullPointerException - ifother isnull@BackpressureSupport(value=UNBOUNDED_IN)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <U> @NonNullMaybe<T> takeUntil(@NonNullPublisher<U> other)
Maybe that emits the item emitted by the currentMaybe until a secondPublisher 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 particularScheduler.U - the type of items emitted byotherother - thePublisher whose first emitted item will causetakeUntil to stop emitting items from the sourcePublisherMaybe instanceNullPointerException - ifother isnull@CheckReturnValue@NonNull@SchedulerSupport(value="io.reactivex:computation")public final @NonNullMaybe<Timed<T>> timeInterval()
Maybe and signals it as a tuple (Timed) success value.
If the currentMaybe is empty or fails, the resultingMaybe will pass along the signals to the downstream. To measure the time to termination, usematerialize() and applySingle.timeInterval().
timeInterval uses thecomputationScheduler for determining the current time upon subscription and upon receiving the success item from the currentMaybe.Maybe instance@CheckReturnValue@NonNull@SchedulerSupport(value="custom")public final @NonNullMaybe<Timed<T>> timeInterval(@NonNullScheduler scheduler)
Maybe and signals it as a tuple (Timed) success value.
If the currentMaybe is empty or fails, the resultingMaybe will pass along the signals to the downstream. To measure the time to termination, usematerialize() and applySingle.timeInterval(Scheduler).
timeInterval uses the providedScheduler for determining the current time upon subscription and upon receiving the success item from the currentMaybe.scheduler - theScheduler used for providing the current timeMaybe instanceNullPointerException - ifscheduler isnull@CheckReturnValue@NonNull@SchedulerSupport(value="io.reactivex:computation")public final @NonNullMaybe<Timed<T>> timeInterval(@NonNullTimeUnit unit)
Maybe and signals it as a tuple (Timed) success value.
If the currentMaybe is empty or fails, the resultingMaybe will pass along the signals to the downstream. To measure the time to termination, usematerialize() and applySingle.timeInterval(TimeUnit).
timeInterval uses thecomputationScheduler for determining the current time upon subscription and upon receiving the success item from the currentMaybe.unit - the time unit for measurementMaybe instanceNullPointerException - ifunit isnull@CheckReturnValue@NonNull@SchedulerSupport(value="custom")public final @NonNullMaybe<Timed<T>> timeInterval(@NonNullTimeUnit unit,@NonNullScheduler scheduler)
Maybe and signals it as a tuple (Timed) success value.
If the currentMaybe is empty or fails, the resultingMaybe will pass along the signals to the downstream. To measure the time to termination, usematerialize() and applySingle.timeInterval(TimeUnit, Scheduler).
timeInterval uses the providedScheduler for determining the current time upon subscription and upon receiving the success item from the currentMaybe.unit - the time unit for measurementscheduler - theScheduler used for providing the current timeMaybe instanceNullPointerException - ifunit orscheduler isnull@CheckReturnValue@NonNull@SchedulerSupport(value="io.reactivex:computation")public final @NonNullMaybe<Timed<T>> timestamp()
Maybe with the current time (in milliseconds) of its reception, using thecomputationScheduler as time source, then signals them as aTimed instance.
If the currentMaybe is empty or fails, the resultingMaybe will pass along the signals to the downstream. To measure the time to termination, usematerialize() and applySingle.timestamp().
timestamp uses thecomputationScheduler for determining the current time upon receiving the success item from the currentMaybe.Maybe instance@CheckReturnValue@NonNull@SchedulerSupport(value="custom")public final @NonNullMaybe<Timed<T>> timestamp(@NonNullScheduler scheduler)
Maybe with the current time (in milliseconds) of its reception, using the givenScheduler as time source, then signals them as aTimed instance.
If the currentMaybe is empty or fails, the resultingMaybe will pass along the signals to the downstream. To measure the time to termination, usematerialize() and applySingle.timestamp(Scheduler).
timestamp uses the providedScheduler for determining the current time upon receiving the success item from the currentMaybe.scheduler - theScheduler used for providing the current timeMaybe instanceNullPointerException - ifscheduler isnull@CheckReturnValue@NonNull@SchedulerSupport(value="io.reactivex:computation")public final @NonNullMaybe<Timed<T>> timestamp(@NonNullTimeUnit unit)
Maybe with the current time of its reception, using thecomputationScheduler as time source, then signals it as aTimed instance.
If the currentMaybe is empty or fails, the resultingMaybe will pass along the signals to the downstream. To measure the time to termination, usematerialize() and applySingle.timestamp(TimeUnit).
timestamp uses thecomputationScheduler, for determining the current time upon receiving the success item from the currentMaybe.unit - the time unit for measurementMaybe instanceNullPointerException - ifunit isnull@CheckReturnValue@NonNull@SchedulerSupport(value="custom")public final @NonNullMaybe<Timed<T>> timestamp(@NonNullTimeUnit unit,@NonNullScheduler scheduler)
Maybe with the current time of its reception, using the givenScheduler as time source, then signals it as aTimed instance.
If the currentMaybe is empty or fails, the resultingMaybe will pass along the signals to the downstream. To measure the time to termination, usematerialize() and applySingle.timestamp(TimeUnit, Scheduler).
timestamp uses the providedScheduler, which is used for determining the current time upon receiving the success item from the currentMaybe.unit - the time unit for measurementscheduler - theScheduler used for providing the current timeMaybe instanceNullPointerException - ifunit orscheduler isnull@CheckReturnValue@SchedulerSupport(value="io.reactivex:computation")@NonNullpublic final @NonNullMaybe<T> timeout(long timeout,@NonNullTimeUnit unit)
Maybe that mirrors the currentMaybe 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 resultingMaybe terminates and notifiesMaybeObservers of aTimeoutException.
timeout operates by default on thecomputationScheduler.timeout - maximum duration between emitted items before a timeout occursunit - the unit of time that applies to thetimeout argument.Maybe instanceNullPointerException - ifunit isnull@CheckReturnValue@NonNull@SchedulerSupport(value="io.reactivex:computation")public final @NonNullMaybe<T> timeout(long timeout,@NonNullTimeUnit unit,@NonNullMaybeSource<? extendsT> fallback)
Maybe that mirrors the currentMaybe 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 currentMaybe is disposed and resultingMaybe begins instead to mirror a fallbackMaybeSource.
timeout operates by default on thecomputationScheduler.timeout - maximum duration between items before a timeout occursunit - the unit of time that applies to thetimeout argumentfallback - the fallbackMaybeSource to use in case of a timeoutMaybe instanceNullPointerException - ifunit orfallback isnull@CheckReturnValue@NonNull@SchedulerSupport(value="custom")public final @NonNullMaybe<T> timeout(long timeout,@NonNullTimeUnit unit,@NonNullScheduler scheduler,@NonNullMaybeSource<? extendsT> fallback)
Maybe that mirrors the currentMaybe but applies a timeout policy for each emitted item using a specifiedScheduler. If the next item isn't emitted within the specified timeout duration starting from its predecessor, the currentMaybe is disposed and resultingMaybe begins instead to mirror a fallbackMaybeSource.
Scheduler this operator will use.timeout - maximum duration between items before a timeout occursunit - the unit of time that applies to thetimeout argumentfallback - theMaybeSource to use as the fallback in case of a timeoutscheduler - theScheduler to run the timeout timers onMaybe instanceNullPointerException - iffallback,unit orscheduler isnull@CheckReturnValue@SchedulerSupport(value="custom")@NonNullpublic final @NonNullMaybe<T> timeout(long timeout,@NonNullTimeUnit unit,@NonNullScheduler scheduler)
Maybe that mirrors the currentMaybe but applies a timeout policy for each emitted item, where this policy is governed on a specifiedScheduler. If the next item isn't emitted within the specified timeout duration starting from its predecessor, the resultingMaybe terminates and notifiesMaybeObservers of aTimeoutException.
Scheduler this operator will use.timeout - maximum duration between items before a timeout occursunit - the unit of time that applies to thetimeout argumentscheduler - theScheduler to run the timeout timers onMaybe instanceNullPointerException - ifunit orscheduler isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <U> @NonNullMaybe<T> timeout(@NonNullMaybeSource<U> timeoutIndicator)
Maybe didn't signal an event before thetimeoutIndicatorMaybeSource signals, aTimeoutException is signaled instead.
timeout does not operate by default on a particularScheduler.U - the value type of thetimeoutIndicator - theMaybeSource that indicates the timeout by signalingonSuccess oronComplete.Maybe instanceNullPointerException - iftimeoutIndicator isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <U> @NonNullMaybe<T> timeout(@NonNullMaybeSource<U> timeoutIndicator,@NonNullMaybeSource<? extendsT> fallback)
Maybe didn't signal an event before thetimeoutIndicatorMaybeSource signals, the currentMaybe is disposed and thefallbackMaybeSource subscribed to as a continuation.
timeout does not operate by default on a particularScheduler.U - the value type of thetimeoutIndicator - theMaybeSource that indicates the timeout by signalingonSuccess oronComplete.fallback - theMaybeSource that is subscribed to if the currentMaybe times outMaybe instanceNullPointerException - iftimeoutIndicator orfallback isnull@BackpressureSupport(value=UNBOUNDED_IN)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <U> @NonNullMaybe<T> timeout(@NonNullPublisher<U> timeoutIndicator)
Maybe source didn't signal an event before thetimeoutIndicatorPublisher signals, aTimeoutException is signaled instead.
timeoutIndicatorPublisher is consumed in an unbounded manner and is cancelled after its first item.timeout does not operate by default on a particularScheduler.U - the value type of thetimeoutIndicator - thePublisher that indicates the timeout by signalingonSuccess oronComplete.Maybe instanceNullPointerException - iftimeoutIndicator isnull@BackpressureSupport(value=UNBOUNDED_IN)@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <U> @NonNullMaybe<T> timeout(@NonNullPublisher<U> timeoutIndicator,@NonNullMaybeSource<? extendsT> fallback)
Maybe didn't signal an event before thetimeoutIndicatorPublisher signals, the currentMaybe is disposed and thefallbackMaybeSource subscribed to as a continuation.
timeoutIndicatorPublisher is consumed in an unbounded manner and is cancelled after its first item.timeout does not operate by default on a particularScheduler.U - the value type of thetimeoutIndicator - theMaybeSource that indicates the timeout by signalingonSuccess oronCompletefallback - theMaybeSource that is subscribed to if the currentMaybe times outMaybe instanceNullPointerException - iftimeoutIndicator orfallback isnull@CheckReturnValue@NonNull@SchedulerSupport(value="custom")public final @NonNullMaybe<T> unsubscribeOn(@NonNullScheduler scheduler)
Maybe which makes sure when aMaybeObserver disposes theDisposable, that call is propagated up on the specifiedScheduler.
unsubscribeOn callsdispose() of the upstream on theScheduler you specify.scheduler - the target scheduler where to execute the disposalMaybe instanceNullPointerException - ifscheduler isnull@CheckReturnValue@NonNull@SchedulerSupport(value="none")public final <U,R> @NonNullMaybe<R> zipWith(@NonNullMaybeSource<? extends U> other,@NonNullBiFunction<? superT,? super U,? extends R> zipper)
MaybeSource signal a success value then applies the givenBiFunction to those values and emits theBiFunction's resulting value to downstream.
If either this or the otherMaybeSource is empty or signals an error, the resultingMaybe will terminate immediately and dispose the other source.
zipWith does not operate by default on a particularScheduler.U - the type of items emitted by theotherMaybeSourceR - the type of items emitted by the resultingMaybeother - the otherMaybeSourcezipper - a function that combines the pairs of items from the twoMaybeSources to generate the items to be emitted by the resultingMaybeMaybe instanceNullPointerException - ifother orzipper isnull@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final @NonNullTestObserver<T> test()
TestObserver and subscribes it to thisMaybe.test does not operate by default on a particularScheduler.TestObserver instance@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final @NonNullTestObserver<T> test(boolean dispose)
TestObserver optionally in cancelled state, then subscribes it to thisMaybe.test does not operate by default on a particularScheduler.dispose - iftrue, theTestObserver will be disposed before subscribing to thisMaybe.TestObserver instance@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic static <T> @NonNullMaybe<T> fromOptional(@NonNullOptional<T> optional)
just(Object) or an empty optional into anempty()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, usedefer(Supplier) aroundfromOptional:
Maybe.defer(() -> Maybe.fromOptional(createOptional()));fromOptional does not operate by default on a particularScheduler.T - the element type of the optional valueoptional - the optional value to convert into aMaybeMaybe instanceNullPointerException - ifoptional isnulljust(Object),empty()@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic static <T> @NonNullMaybe<T> fromCompletionStage(@NonNullCompletionStage<T> stage)
CompletionStage-based asynchronous calculation.
Note that the operator takes an already instantiated, running or terminatedCompletionStage. If theCompletionStage is to be created per consumer upon subscription, usedefer(Supplier) aroundfromCompletionStage:
Maybe.defer(() -> Maybe.fromCompletionStage(createCompletionStage())); If theCompletionStage completes withnull, the resultingMaybe is completed viaonComplete.
Canceling the flow can't cancel the execution of theCompletionStage becauseCompletionStage itself doesn't support cancellation. Instead, the operator detaches from theCompletionStage.
fromCompletionStage does not operate by default on a particularScheduler.T - the element type of theCompletionStagestage - theCompletionStage to convert toMaybe and signal its terminal value or errorMaybe instanceNullPointerException - ifstage isnull@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final <R> @NonNullMaybe<R> mapOptional(@NonNullFunction<? superT,Optional<? extends R>> mapper)
Optional and emits the contained item if not empty.
mapOptional does not operate by default on a particularScheduler.R - the non-null output typemapper - the function that receives the upstream success item and should return anon-emptyOptional to emit as the success output or anemptyOptional to complete theMaybeMaybe instanceNullPointerException - ifmapper isnullmap(Function),filter(Predicate)@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final @NonNullCompletionStage<T> toCompletionStage()
NoSuchElementException if the upstream is empty) via aCompletionStage.
The upstream can be canceled by converting the resultingCompletionStage intoCompletableFuture viaCompletionStage.toCompletableFuture() and callingCompletableFuture.cancel(boolean) on it. The upstream will be also cancelled if the resultingCompletionStage is converted to and completed manually byCompletableFuture.complete(Object) orCompletableFuture.completeExceptionally(Throwable).
CompletionStages don't have a notion of emptiness and allownulls, therefore, one can either usetoCompletionStage(Object) withnull or turn the upstream into a sequence ofOptionals and default toOptional.empty():
CompletionStage<Optional<T>> stage = source.map(Optional::of).toCompletionStage(Optional.empty());toCompletionStage does not operate by default on a particularScheduler.CompletionStage instancetoCompletionStage(Object)@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final @NonNullCompletionStage<T> toCompletionStage(@NullableT defaultItem)
CompletionStage.
The upstream can be canceled by converting the resultingCompletionStage intoCompletableFuture viaCompletionStage.toCompletableFuture() and callingCompletableFuture.cancel(boolean) on it. The upstream will be also cancelled if the resultingCompletionStage is converted to and completed manually byCompletableFuture.complete(Object) orCompletableFuture.completeExceptionally(Throwable).
CompletionStages don't have a notion of emptiness and allownulls, therefore, one can either use adefaultItem ofnull or turn the flow into a sequence ofOptionals and default toOptional.empty():
CompletionStage<Optional<T>> stage = source.map(Optional::of).toCompletionStage(Optional.empty());toCompletionStage does not operate by default on a particularScheduler.defaultItem - the item to signal if the upstream is emptyCompletionStage instance@CheckReturnValue@SchedulerSupport(value="none")@BackpressureSupport(value=FULL)@NonNullpublic final <R> @NonNullFlowable<R> flattenStreamAsFlowable(@NonNullFunction<? superT,? extendsStream<? extends R>> mapper)
Stream and emits its items to the downstream consumer as aFlowable.
The operator closes theStream upon cancellation and when it terminates. The exceptions raised when closing aStream are routed to the global error handler (RxJavaPlugins.onError(Throwable). If aStream should not be closed, turn it into anIterable and useflattenAsFlowable(Function):
source.flattenAsFlowable(item -> createStream(item)::iterator); Primitive streams are not supported and items have to be boxed manually (e.g., viaIntStream.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 particularScheduler.R - the element type of theStream and the outputFlowablemapper - the function that receives the upstream success item and should return aStream of values to emit.Flowable instanceNullPointerException - ifmapper isnullflattenAsFlowable(Function),flattenStreamAsObservable(Function)@CheckReturnValue@SchedulerSupport(value="none")@NonNullpublic final <R> @NonNullObservable<R> flattenStreamAsObservable(@NonNullFunction<? superT,? extendsStream<? extends R>> mapper)
Stream and emits its items to the downstream consumer as anObservable.
The operator closes theStream upon cancellation and when it terminates. The exceptions raised when closing aStream are routed to the global error handler (RxJavaPlugins.onError(Throwable). If aStream should not be closed, turn it into anIterable and useflattenAsObservable(Function):
source.flattenAsObservable(item -> createStream(item)::iterator); Primitive streams are not supported and items have to be boxed manually (e.g., viaIntStream.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 particularScheduler.R - the element type of theStream and the outputObservablemapper - the function that receives the upstream success item and should return aStream of values to emit.Observable instanceNullPointerException - ifmapper isnullflattenAsObservable(Function),flattenStreamAsFlowable(Function)