T - the value typepublic abstract class Maybe<T> extends java.lang.Object implements MaybeSource<T>
The main consumer type of Maybe is MaybeObserver whose methods are called
in a sequential fashion following this protocol:
onSubscribe (onSuccess | onError | onComplete)?.
| Constructor and Description |
|---|
Maybe() |
| Modifier and Type | Method and Description |
|---|---|
static <T> Maybe<T> |
amb(java.lang.Iterable<? extends MaybeSource<? extends T>> sources)
Runs multiple Maybe sources and signals the events of the first one that signals (cancelling
the rest).
|
static <T> Maybe<T> |
ambArray(MaybeSource<? extends T>... sources)
Runs multiple Maybe sources and signals the events of the first one that signals (cancelling
the rest).
|
<U> Maybe<U> |
cast(java.lang.Class<? extends U> clazz)
Casts the success value of the current Maybe into the target type or signals a
ClassCastException if not compatible.
|
<R> Maybe<R> |
compose(Function<? super Maybe<T>,? extends MaybeSource<R>> transformer)
Transform a Maybe by applying a particular Transformer function to it.
|
static <T> Flowable<T> |
concat(java.lang.Iterable<? extends MaybeSource<? extends T>> sources)
Concatenate the single values, in a non-overlapping fashion, of the MaybeSource sources provided by
an Iterable sequence.
|
static <T> Flowable<T> |
concat(MaybeSource<? extends T> source1,
MaybeSource<? extends T> source2)
Returns a Flowable that emits the items emitted by two MaybeSources, one after the other.
|
static <T> Flowable<T> |
concat(MaybeSource<? extends T> source1,
MaybeSource<? extends T> source2,
MaybeSource<? extends T> source3)
Returns a Flowable that emits the items emitted by three MaybeSources, one after the other.
|
static <T> Flowable<T> |
concat(MaybeSource<? extends T> source1,
MaybeSource<? extends T> source2,
MaybeSource<? extends T> source3,
MaybeSource<? extends T> source4)
Returns a Flowable that emits the items emitted by four MaybeSources, one after the other.
|
static <T> Flowable<T> |
concat(org.reactivestreams.Publisher<? extends MaybeSource<? extends T>> sources)
Concatenate the single values, in a non-overlapping fashion, of the MaybeSource sources provided by
a Publisher sequence.
|
static <T> Flowable<T> |
concat(org.reactivestreams.Publisher<? extends MaybeSource<? extends T>> sources,
int prefetch)
Concatenate the single values, in a non-overlapping fashion, of the MaybeSource sources provided by
a Publisher sequence.
|
static <T> Flowable<T> |
concatArray(MaybeSource<? extends T>... sources)
Concatenate the single values, in a non-overlapping fashion, of the MaybeSource sources in the array.
|
<R> Maybe<R> |
concatMap(Function<? super T,? extends MaybeSource<? extends R>> mapper)
Returns a Maybe that is based on applying a specified function to the item emitted by the source Maybe,
where that function returns a MaybeSource.
|
static <T> Maybe<T> |
create(MaybeOnSubscribe<T> onSubscribe)
Provides an API (via a cold Maybe) that bridges the reactive world with the callback-style world.
|
static <T> Maybe<T> |
defer(java.util.concurrent.Callable<? extends MaybeSource<? extends T>> maybeSupplier)
Calls a Callable for each individual MaybeObserver to return the actual MaybeSource source to
be subscribe to.
|
Maybe<T> |
doAfterTerminate(Action onAfterTerminate)
|
Maybe<T> |
doOnComplete(Action onComplete)
Modifies the source Maybe so that it invokes an action when it calls
onCompleted. |
Maybe<T> |
doOnDispose(Action onDispose)
Calls the shared runnable if a MaybeObserver subscribed to the current Single
disposes the common Disposable it received via onSubscribe.
|
Maybe<T> |
doOnError(Consumer<? super java.lang.Throwable> onError)
Calls the shared consumer with the error sent via onError for each
MaybeObserver that subscribes to the current Single.
|
Maybe<T> |
doOnEvent(BiConsumer<? super T,? super java.lang.Throwable> onEvent)
Calls the given onEvent callback with the (success value, null) for an onSuccess, (null, throwabe) for
an onError or (null, null) for an onComplete signal from this Maybe before delivering said
signal to the downstream.
|
Maybe<T> |
doOnSubscribe(Consumer<? super Disposable> onSubscribe)
Calls the shared consumer with the Disposable sent through the onSubscribe for each
MaybeObserver that subscribes to the current Single.
|
Maybe<T> |
doOnSuccess(Consumer<? super T> onSuccess)
Calls the shared consumer with the success value sent via onSuccess for each
MaybeObserver that subscribes to the current Single.
|
static <T> Maybe<T> |
empty()
Returns a (singleton) Maybe instance that calls
onComplete
immediately. |
static <T> Maybe<T> |
error(java.util.concurrent.Callable<? extends java.lang.Throwable> supplier)
|
static <T> Maybe<T> |
error(java.lang.Throwable exception)
Returns a Maybe that invokes a subscriber's
onError method when the
subscriber subscribes to it. |
Maybe<T> |
filter(Predicate<? super T> predicate)
Filters the success item of the Maybe via a predicate function and emitting it if the predicate
returns true, completing otherwise.
|
<R> Maybe<R> |
flatMap(Function<? super T,? extends MaybeSource<? extends R>> mapper)
Returns a Maybe that is based on applying a specified function to the item emitted by the source Maybe,
where that function returns a MaybeSource.
|
<R> Maybe<R> |
flatMap(Function<? super T,? extends MaybeSource<? extends R>> onSuccessMapper,
Function<? super java.lang.Throwable,? extends MaybeSource<? extends R>> onErrorMapper,
java.util.concurrent.Callable<? extends MaybeSource<? extends R>> onCompleteSupplier)
Maps the onSuccess, onError or onComplete signals of this Maybe into MaybeSource and emits that
MaybeSource's signals
|
static <T> Maybe<T> |
fromAction(Action run)
Returns a Maybe instance that runs the given Action for each subscriber and
emits either its exception or simply completes.
|
static <T> Maybe<T> |
fromCallable(java.util.concurrent.Callable<? extends T> callable)
Returns a
Maybe that invokes passed function and emits its result for each new MaybeObserver that subscribes
while considering null value from the callable as indication for valueless completion. |
static <T> Maybe<T> |
fromRunnable(java.lang.Runnable run)
Returns a Maybe instance that runs the given Action for each subscriber and
emits either its exception or simply completes.
|
Maybe<T> |
ignoreElement()
Ignores the item emitted by the source Maybe and only calls
onCompleted or onError. |
static <T> Maybe<T> |
just(T item)
Returns a
Maybe that emits a specified item. |
<R> Maybe<R> |
lift(MaybeOperator<? extends R,? super T> lift)
Lifts a function to the current Maybe and returns a new Maybe that when subscribed to will pass the
values of the current Maybe through the MaybeOperator function.
|
<R> Maybe<R> |
map(Function<? super T,? extends R> mapper)
Returns a Maybe that applies a specified function to the item emitted by the source Maybe and
emits the result of this function application.
|
static <T> Flowable<T> |
merge(java.lang.Iterable<? extends MaybeSource<? extends T>> sources)
Merges an Iterable sequence of MaybeSource instances into a single Flowable sequence,
running all MaybeSources at once.
|
static <T> Maybe<T> |
merge(MaybeSource<? extends MaybeSource<? extends T>> source)
Flattens a
Single that emits a Single into a single Single that emits the item
emitted by the nested Single, without any transformation. |
static <T> Flowable<T> |
merge(MaybeSource<? extends T> source1,
MaybeSource<? extends T> source2)
Flattens two Singles into a single Observable, without any transformation.
|
static <T> Flowable<T> |
merge(MaybeSource<? extends T> source1,
MaybeSource<? extends T> source2,
MaybeSource<? extends T> source3)
Flattens three Singles into a single Observable, without any transformation.
|
static <T> Flowable<T> |
merge(MaybeSource<? extends T> source1,
MaybeSource<? extends T> source2,
MaybeSource<? extends T> source3,
MaybeSource<? extends T> source4)
Flattens four Singles into a single Observable, without any transformation.
|
static <T> Flowable<T> |
merge(org.reactivestreams.Publisher<? extends MaybeSource<? extends T>> sources)
Merges a Flowable sequence of MaybeSource instances into a single Flowable sequence,
running all MaybeSources at once.
|
static <T> Flowable<T> |
merge(org.reactivestreams.Publisher<? extends MaybeSource<? extends T>> sources,
int maxConcurrency)
Merges a Flowable sequence of MaybeSource instances into a single Flowable sequence,
running at most maxConcurrency MaybeSources at once.
|
static <T> Flowable<T> |
mergeArray(MaybeSource<? extends T>... sources)
Merges an array sequence of MaybeSource instances into a single Flowable sequence,
running all MaybeSources at once.
|
static <T> Maybe<T> |
never()
Returns a Maybe that never sends any items or notifications to an
MaybeObserver. |
Maybe<T> |
observeOn(Scheduler scheduler)
Wraps a Maybe to emit its item (or notify of its error) on a specified
Scheduler,
asynchronously. |
Disposable |
subscribe()
Subscribes to a Maybe and ignores
onSuccess and onComplete emissions. |
Disposable |
subscribe(Consumer<? super T> onSuccess)
Subscribes to a Maybe and provides a callback to handle the items it emits.
|
Disposable |
subscribe(Consumer<? super T> onSuccess,
Consumer<? super java.lang.Throwable> onError)
Subscribes to a Maybe and provides callbacks to handle the items it emits and any error
notification it issues.
|
Disposable |
subscribe(Consumer<? super T> onSuccess,
Consumer<? super java.lang.Throwable> onError,
Action onComplete)
Subscribes to a Maybe and provides callbacks to handle the items it emits and any error or
completion notification it issues.
|
void |
subscribe(MaybeObserver<? super T> observer)
Subscribes the given MaybeObserver to this MaybeSource instance.
|
protected abstract void |
subscribeActual(MaybeObserver<? super T> observer)
Override this method in subclasses to handle the incoming MaybeObservers.
|
Maybe<T> |
subscribeOn(Scheduler scheduler)
Asynchronously subscribes subscribers to this Maybe on the specified
Scheduler. |
<E extends MaybeObserver<? super T>> |
subscribeWith(E observer)
Subscribes a given MaybeObserver (subclass) to this Maybe and returns the given
MaybeObserver as is.
|
TestSubscriber<T> |
test()
Creates a TestSubscriber and subscribes
it to this Maybe.
|
TestSubscriber<T> |
test(boolean cancelled)
Creates a TestSubscriber optionally in cancelled state, then subscribes it to this Maybe.
|
<R> R |
to(Function<? super Maybe<T>,R> convert)
Calls the specified converter function with the current Maybe instance
during assembly time and returns its result.
|
Completable |
toCompletable()
Converts this Maybe into an Completable instance composing cancellation
through and dropping a success value if emitted.
|
Flowable<T> |
toFlowable()
Converts this Maybe into a backpressure-aware Flowable instance composing cancellation
through.
|
Observable<T> |
toObservable()
Converts this Maybe into an Observable instance composing cancellation
through.
|
Single<T> |
toSingle()
Converts this Maybe into an Single instance composing cancellation
through and turing an empty Maybe into a signal of NoSuchElementException.
|
static <T> Maybe<T> |
unsafeCreate(MaybeSource<T> onSubscribe)
Advanced use only: creates a Maybe instance without
any safeguards by using a callback that is called with a MaybeObserver.
|
static <T> Maybe<T> |
wrap(MaybeSource<T> source)
Wraps a MaybeSource instance into a new Maybe instance if not already a Maybe
instance.
|
public static <T> Maybe<T> amb(java.lang.Iterable<? extends MaybeSource<? extends T>> sources)
amb does not operate by default on a particular Scheduler.T - the value typesources - the Iterable sequence of sourcespublic static <T> Maybe<T> ambArray(MaybeSource<? extends T>... sources)
amb does not operate by default on a particular Scheduler.T - the value typesources - the array of sourcespublic static <T> Maybe<T> create(MaybeOnSubscribe<T> onSubscribe)
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);
});
create does not operate by default on a particular Scheduler.T - the value typeonSubscribe - the emitter that is called when a MaybeObserver subscribes to the returned FlowableMaybeOnSubscribe,
Cancellablepublic static <T> Flowable<T> concat(java.lang.Iterable<? extends MaybeSource<? extends T>> sources)
concat does not operate by default on a particular Scheduler.T - the value typesources - the Iterable sequence of MaybeSource instancespublic static <T> Flowable<T> concat(MaybeSource<? extends T> source1, MaybeSource<? extends T> source2)
concat does not operate by default on a particular Scheduler.T - the common value typesource1 - a MaybeSource to be concatenatedsource2 - a MaybeSource to be concatenatedpublic static <T> Flowable<T> concat(MaybeSource<? extends T> source1, MaybeSource<? extends T> source2, MaybeSource<? extends T> source3)
concat does not operate by default on a particular Scheduler.T - the common value typesource1 - a MaybeSource to be concatenatedsource2 - a MaybeSource to be concatenatedsource3 - a MaybeSource to be concatenatedpublic static <T> Flowable<T> concat(MaybeSource<? extends T> source1, MaybeSource<? extends T> source2, MaybeSource<? extends T> source3, MaybeSource<? extends T> source4)
concat does not operate by default on a particular Scheduler.T - the common value typesource1 - a MaybeSource to be concatenatedsource2 - a MaybeSource to be concatenatedsource3 - a MaybeSource to be concatenatedsource4 - a MaybeSource to be concatenatedpublic static <T> Flowable<T> concat(org.reactivestreams.Publisher<? extends MaybeSource<? extends T>> sources)
concat does not operate by default on a particular Scheduler.T - the value typesources - the Publisher of MaybeSource instancespublic static <T> Flowable<T> concat(org.reactivestreams.Publisher<? extends MaybeSource<? extends T>> sources, int prefetch)
concat does not operate by default on a particular Scheduler.T - the value typesources - the Publisher of MaybeSource instancesprefetch - the number of MaybeSources to prefetch from the Publisherpublic static <T> Flowable<T> concatArray(MaybeSource<? extends T>... sources)
concat does not operate by default on a particular Scheduler.T - the value typesources - the Publisher of MaybeSource instancespublic static <T> Maybe<T> defer(java.util.concurrent.Callable<? extends MaybeSource<? extends T>> maybeSupplier)
defer does not operate by default on a particular Scheduler.T - the value typemaybeSupplier - the Callable that is called for each individual MaybeObserver and
returns a MaybeSource instance to subscribe topublic static <T> Maybe<T> empty()
onComplete
immediately.
empty does not operate by default on a particular Scheduler.T - the value typepublic static <T> Maybe<T> error(java.lang.Throwable exception)
onError method when the
subscriber subscribes to it.
error does not operate by default on a particular Scheduler.T - the type of the item (ostensibly) emitted by the Maybeexception - the particular Throwable to pass to onErroronError method when
the subscriber subscribes to itpublic static <T> Maybe<T> error(java.util.concurrent.Callable<? extends java.lang.Throwable> supplier)
Observer's onError method when the
Observer subscribes to it.
error does not operate by default on a particular Scheduler.T - the type of the items (ostensibly) emitted by the Maybesupplier - a Callable factory to return a Throwable for each individual SubscriberMaybeObserver's onError method when
the MaybeObserver subscribes to it@SchedulerSupport(value="none") public static <T> Maybe<T> fromAction(Action run)
fromAction does not operate by default on a particular Scheduler.T - the target typerun - the runnable to run for each subscriberjava.lang.NullPointerException - if run is nullpublic static <T> Maybe<T> fromCallable(java.util.concurrent.Callable<? extends T> callable)
Maybe that invokes passed function and emits its result for each new MaybeObserver that subscribes
while considering null value from the callable as indication for valueless completion.
Allows you to defer execution of passed function until MaybeObserver subscribes to the Maybe.
It makes passed function "lazy".
Result of the function invocation will be emitted by the Maybe.
fromCallable does not operate by default on a particular Scheduler.T - the type of the item emitted by the Maybe.callable - function which execution should be deferred, it will be invoked when MaybeObserver will subscribe to the Maybe.Maybe whose MaybeObservers' subscriptions trigger an invocation of the given function.@SchedulerSupport(value="none") public static <T> Maybe<T> fromRunnable(java.lang.Runnable run)
fromRunnable does not operate by default on a particular Scheduler.T - the target typerun - the runnable to run for each subscriberjava.lang.NullPointerException - if run is nullpublic static <T> Maybe<T> just(T item)
Maybe that emits a specified item.
To convert any object into a Single that emits that object, pass that object into the
just method.
just does not operate by default on a particular Scheduler.T - the type of that itemitem - the item to emitMaybe that emits itempublic static <T> Flowable<T> merge(java.lang.Iterable<? extends MaybeSource<? extends T>> sources)
merge does not operate by default on a particular Scheduler.T - the common and resulting value typesources - the Iterable sequence of MaybeSource sourcespublic static <T> Flowable<T> merge(org.reactivestreams.Publisher<? extends MaybeSource<? extends T>> sources)
merge does not operate by default on a particular Scheduler.T - the common and resulting value typesources - the Flowable sequence of MaybeSource sourcespublic static <T> Flowable<T> merge(org.reactivestreams.Publisher<? extends MaybeSource<? extends T>> sources, int maxConcurrency)
merge does not operate by default on a particular Scheduler.T - the common and resulting value typesources - the Flowable sequence of MaybeSource sourcesmaxConcurrency - the maximum number of concurrently running MaybeSourcespublic static <T> Maybe<T> merge(MaybeSource<? extends MaybeSource<? extends T>> source)
Single that emits a Single into a single Single that emits the item
emitted by the nested Single, without any transformation.
merge does not operate by default on a particular Scheduler.T - the value type of the sources and the outputsource - a Single that emits a SingleSingle that emits the item that is the result of flattening the Single emitted
by sourcepublic static <T> Flowable<T> merge(MaybeSource<? extends T> source1, MaybeSource<? extends T> source2)
You can combine items emitted by multiple Singles so that they appear as a single Observable, by
using the merge method.
merge does not operate by default on a particular Scheduler.T - the common value typesource1 - a Single to be mergedsource2 - a Single to be mergedpublic static <T> Flowable<T> merge(MaybeSource<? extends T> source1, MaybeSource<? extends T> source2, MaybeSource<? extends T> source3)
You can combine items emitted by multiple Singles so that they appear as a single Observable, by using
the merge method.
merge does not operate by default on a particular Scheduler.T - the common value typesource1 - a Single to be mergedsource2 - a Single to be mergedsource3 - a Single to be mergedpublic static <T> Flowable<T> merge(MaybeSource<? extends T> source1, MaybeSource<? extends T> source2, MaybeSource<? extends T> source3, MaybeSource<? extends T> source4)
You can combine items emitted by multiple Singles so that they appear as a single Observable, by using
the merge method.
merge does not operate by default on a particular Scheduler.T - the common value typesource1 - a Single to be mergedsource2 - a Single to be mergedsource3 - a Single to be mergedsource4 - a Single to be mergedpublic static <T> Flowable<T> mergeArray(MaybeSource<? extends T>... sources)
merge does not operate by default on a particular Scheduler.T - the common and resulting value typesources - the array sequence of MaybeSource sourcespublic static <T> Maybe<T> never()
MaybeObserver.
This Maybe is useful primarily for testing purposes.
never does not operate by default on a particular Scheduler.T - the type of items (not) emitted by the MaybeMaybeObserverpublic static <T> Maybe<T> unsafeCreate(MaybeSource<T> onSubscribe)
unsafeCreate does not operate by default on a particular Scheduler.T - the value typeonSubscribe - the function that is called with the subscribing MaybeObserverpublic static <T> Maybe<T> wrap(MaybeSource<T> source)
wrap does not operate by default on a particular Scheduler.T - the value typesource - the source to wrappublic final <U> Maybe<U> cast(java.lang.Class<? extends U> clazz)
cast does not operate by default on a particular Scheduler.U - the target typeclazz - the type token to use for casting the success result from the current Maybepublic final <R> Maybe<R> compose(Function<? super Maybe<T>,? extends MaybeSource<R>> transformer)
This method operates on the Maybe itself whereas lift(io.reactivex.MaybeOperator<? extends R, ? super T>) operates on the Maybe's MaybeObservers.
If the operator you are creating is designed to act on the individual item emitted by a Maybe, use
lift(io.reactivex.MaybeOperator<? extends R, ? super T>). If your operator is designed to transform the source Maybe as a whole (for instance, by
applying a particular set of existing RxJava operators to it) use compose.
compose does not operate by default on a particular Scheduler.R - the value type of the Maybe returned by the transformer functiontransformer - implements the function that transforms the source Maybepublic final <R> Maybe<R> concatMap(Function<? super T,? extends MaybeSource<? extends R>> mapper)
flatMap does not operate by default on a particular Scheduler.Note that flatMap and concatMap for Maybe is the same operation.
R - the result value typemapper - a function that, when applied to the item emitted by the source Maybe, returns a MaybeSourcefunc when applied to the item emitted by the source Maybe@SchedulerSupport(value="none") public final Maybe<T> doAfterTerminate(Action onAfterTerminate)
Action to be called when this Maybe invokes either
onSuccess,
onComplete or onError.
doAfterTerminate does not operate by default on a particular Scheduler.onAfterTerminate - an Action to be invoked when the source Maybe finishesActionpublic final Maybe<T> doOnDispose(Action onDispose)
doOnSubscribe does not operate by default on a particular Scheduler.onDispose - the runnable called when the subscription is cancelled (disposed)@SchedulerSupport(value="none") public final Maybe<T> doOnComplete(Action onComplete)
onCompleted.
doOnComplete does not operate by default on a particular Scheduler.onComplete - the action to invoke when the source Maybe calls onCompletedpublic final Maybe<T> doOnError(Consumer<? super java.lang.Throwable> onError)
doOnSubscribe does not operate by default on a particular Scheduler.onError - the consumer called with the success value of onErrorpublic final Maybe<T> doOnEvent(BiConsumer<? super T,? super java.lang.Throwable> onEvent)
Exceptions thrown from the callback will override the event so the downstream receives the error instead of the original signal.
doOnEvent does not operate by default on a particular Scheduler.onEvent - the callback to call with the terminal event tuplepublic final Maybe<T> doOnSubscribe(Consumer<? super Disposable> onSubscribe)
doOnSubscribe does not operate by default on a particular Scheduler.onSubscribe - the consumer called with the Disposable sent via onSubscribepublic final Maybe<T> doOnSuccess(Consumer<? super T> onSuccess)
doOnSubscribe does not operate by default on a particular Scheduler.onSuccess - the consumer called with the success value of onSuccess@SchedulerSupport(value="none") public final Maybe<T> filter(Predicate<? super T> predicate)
filter does not operate by default on a particular Scheduler.predicate - a function that evaluates the item emitted by the source Maybe, returning true
if it passes the filtertruepublic final <R> Maybe<R> flatMap(Function<? super T,? extends MaybeSource<? extends R>> mapper)
flatMap does not operate by default on a particular Scheduler.Note that flatMap and concatMap for Maybe is the same operation.
R - the result value typemapper - a function that, when applied to the item emitted by the source Maybe, returns a MaybeSourcefunc when applied to the item emitted by the source Maybe@SchedulerSupport(value="none") public final <R> Maybe<R> flatMap(Function<? super T,? extends MaybeSource<? extends R>> onSuccessMapper, Function<? super java.lang.Throwable,? extends MaybeSource<? extends R>> onErrorMapper, java.util.concurrent.Callable<? extends MaybeSource<? extends R>> onCompleteSupplier)
flatMap does not operate by default on a particular Scheduler.R - the result typeonSuccessMapper - a function that returns a MaybeSource to merge for the success item emitted by this MaybeonErrorMapper - a function that returns a MaybeSource to merge for an onError notification from this MaybeonCompleteSupplier - a function that returns a MaybeSource to merge for an onCompleted notification this Maybe@SchedulerSupport(value="none") public final Maybe<T> ignoreElement()
onCompleted or onError.
ignoreElement does not operate by default on a particular Scheduler.onComplete or onError, based on which one is
called by the source Maybepublic final <R> Maybe<R> lift(MaybeOperator<? extends R,? super T> lift)
In other words, this allows chaining TaskExecutors together on a Maybe for acting on the values within the Maybe.
task.map(...).filter(...).lift(new OperatorA()).lift(new OperatorB(...)).subscribe()
If the operator you are creating is designed to act on the item emitted by a source Maybe, use
lift. If your operator is designed to transform the source Maybe as a whole (for instance, by
applying a particular set of existing RxJava operators to it) use compose(io.reactivex.functions.Function<? super io.reactivex.Maybe<T>, ? extends io.reactivex.MaybeSource<R>>).
lift does not operate by default on a particular Scheduler.R - the downstream's value type (output)lift - the MaybeOperator that implements the Maybe-operating function to be applied to the source Maybepublic final <R> Maybe<R> map(Function<? super T,? extends R> mapper)
map does not operate by default on a particular Scheduler.R - the result value typemapper - a function to apply to the item emitted by the Maybepublic final Maybe<T> observeOn(Scheduler scheduler)
Scheduler,
asynchronously.
Scheduler this operator will usescheduler - the Scheduler to notify subscribers onSchedulersubscribeOn(io.reactivex.Scheduler)public final <R> R to(Function<? super Maybe<T>,R> convert)
to does not operate by default on a particular Scheduler.R - the result typeconvert - the function that is called with the current Maybe instance during
assembly time that should return some value to be the resultpublic final Completable toCompletable()
create does not operate by default on a particular Scheduler.public final Flowable<T> toFlowable()
create does not operate by default on a particular Scheduler.public final Observable<T> toObservable()
create does not operate by default on a particular Scheduler.public final Single<T> toSingle()
create does not operate by default on a particular Scheduler.@SchedulerSupport(value="none") public final Disposable subscribe()
onSuccess and onComplete emissions.
If the Maybe emits an error, it is routed to the RxJavaPlugins.onError handler.
subscribe does not operate by default on a particular Scheduler.Disposable reference with which the caller can stop receiving items before
the Maybe has finished sending them@SchedulerSupport(value="none") public final Disposable subscribe(Consumer<? super T> onSuccess)
If the Flowable emits an error, it is routed to the RxJavaPlugins.onError handler.
subscribe does not operate by default on a particular Scheduler.onSuccess - the Consumer<T> you have designed to accept a success value from the MaybeDisposable reference with which the caller can stop receiving items before
the Maybe has finished sending themjava.lang.NullPointerException - if onSuccess is null@SchedulerSupport(value="none") public final Disposable subscribe(Consumer<? super T> onSuccess, Consumer<? super java.lang.Throwable> onError)
subscribe does not operate by default on a particular Scheduler.onSuccess - the Consumer<T> you have designed to accept a success value from the MaybeonError - the Consumer<Throwable> you have designed to accept any error notification from the
MaybeSubscription reference with which the caller can stop receiving items before
the Maybe has finished sending themjava.lang.IllegalArgumentException - if onSuccess is null, or
if onError is null@SchedulerSupport(value="none") public final Disposable subscribe(Consumer<? super T> onSuccess, Consumer<? super java.lang.Throwable> onError, Action onComplete)
subscribe does not operate by default on a particular Scheduler.onSuccess - the Consumer<T> you have designed to accept a success value from the MaybeonError - the Consumer<Throwable> you have designed to accept any error notification from the
MaybeonComplete - the Action you have designed to accept a completion notification from the
MaybeDisposable reference with which the caller can stop receiving items before
the Maybe has finished sending themjava.lang.IllegalArgumentException - if onSuccess is null, or
if onError is null, or
if onComplete is nullpublic final void subscribe(MaybeObserver<? super T> observer)
MaybeSourcesubscribe in interface MaybeSource<T>observer - the MaybeObserver, not nullprotected abstract void subscribeActual(MaybeObserver<? super T> observer)
observer - the MaybeObserver to handle, not nullpublic final Maybe<T> subscribeOn(Scheduler scheduler)
Scheduler.
Scheduler this operator will usescheduler - the Scheduler to perform subscription actions onSchedulerobserveOn(io.reactivex.Scheduler)public final <E extends MaybeObserver<? super T>> E subscribeWith(E observer)
Usage example:
Maybe source = Maybe.just(1);
CompositeDisposable composite = new CompositeDisposable();
MaybeObserver<Integer> ms = new MaybeObserver<>() {
// ...
};
composite.add(source.subscribeWith(ms));
E - the type of the MaybeObserver to use and returnobserver - the MaybeObserver (subclass) to use and return, not nullsubscriberjava.lang.NullPointerException - if subscriber is nullpublic final TestSubscriber<T> test()
public final TestSubscriber<T> test(boolean cancelled)
cancelled - if true, the TestSubscriber will be cancelled before subscribing to this
Maybe.