T
- the value typepublic abstract class Perhaps<T> extends Object implements Publisher<T>
Constructor and Description |
---|
Perhaps() |
Modifier and Type | Method and Description |
---|---|
static <T> Perhaps<T> |
amb(Iterable<? extends Perhaps<? extends T>> sources)
Emit the events of the Perhaps that reacts first.
|
static <T> Perhaps<T> |
ambArray(Perhaps<? extends T>... sources)
Emit the events of the Perhaps that reacts first.
|
Perhaps<T> |
ambWith(Perhaps<? extends T> other)
Signals the events of this or the other Perhaps whichever
signals first.
|
Perhaps<T> |
andThen(Nono other)
Runs this Perhaps and then runs the other Nono source, only
emitting this Perhaps' success value if the other Nono source
completes normally.
|
Flowable<T> |
andThen(Publisher<? extends T> other)
Runs this Perhaps and emits its value followed by running
the other Publisher and emitting its values.
|
T |
blockingGet()
Blockingly awaits indefinitely the success value of this Perhaps or rethrows
its error (wrapped into a RuntimeException if necessary).
|
T |
blockingGet(long timeout,
TimeUnit unit)
Blockingly awaits at most the given timeout for the success
value of this Perhaps or rethrows
its error (wrapped into a RuntimeException if necessary).
|
void |
blockingSubscribe()
Blocks until this Perhaps terminates and ignores the signals it produced.
|
void |
blockingSubscribe(Consumer<? super T> onNext)
Blocks until this Perhaps terminates and calls the onNext with the success value.
|
void |
blockingSubscribe(Consumer<? super T> onNext,
Consumer<? super Throwable> onError)
Blocks until this Perhaps terminates and calls the onNext with the success value
or calls the onError with the error Throwable.
|
void |
blockingSubscribe(Consumer<? super T> onNext,
Consumer<? super Throwable> onError,
Action onComplete)
Blocks until this Perhaps produces its terminal signal and calls the
appropriate callback(s) based on the signal type.
|
Perhaps<T> |
cache()
Caches the value or error event of the upstream Perhaps
and relays/replays it to Subscribers.
|
<R> Perhaps<R> |
compose(Function<? super Perhaps<T>,? extends Perhaps<R>> composer)
Applies a function to this Perhaps and returns the Perhaps it returned.
|
static <T> Flowable<T> |
concat(Iterable<? extends Perhaps<? extends T>> sources)
Concatenate the values in order from a sequence of Perhaps sources.
|
static <T> Flowable<T> |
concat(Publisher<? extends Perhaps<? extends T>> sources)
Concatenate the values in order from a sequence of Perhaps sources.
|
static <T> Flowable<T> |
concat(Publisher<? extends Perhaps<? extends T>> sources,
int prefetch)
Concatenate the values in order from a sequence of Perhaps sources.
|
static <T> Flowable<T> |
concatArray(Perhaps<? extends T>... sources)
Concatenate the values in order from a sequence of Perhaps sources.
|
static <T> Flowable<T> |
concatArrayDelayError(Perhaps<? extends T>... sources)
Concatenate the values in order from a sequence of Perhaps sources, delaying
errors till all sources terminate.
|
static <T> Flowable<T> |
concatDelayError(Iterable<? extends Perhaps<? extends T>> sources)
Concatenate the values in order from a sequence of Perhaps sources, delaying
errors till all sources terminate.
|
static <T> Flowable<T> |
concatDelayError(Publisher<? extends Perhaps<? extends T>> sources)
Concatenate the values in order from a sequence of Perhaps sources, delaying
errors till all sources terminate.
|
static <T> Flowable<T> |
concatDelayError(Publisher<? extends Perhaps<? extends T>> sources,
int prefetch)
Concatenate the values in order from a sequence of Perhaps sources, delaying
errors till all sources terminate.
|
static <T> Flowable<T> |
concatDelayError(Publisher<? extends Perhaps<? extends T>> sources,
int prefetch,
boolean tillTheEnd)
Concatenate the values in order from a sequence of Perhaps sources, delaying
errors till a source terminates or the whole sequence terminates.
|
Flowable<T> |
concatWith(Publisher<? extends T> other)
Runs this Perhaps and emits its value followed by running
the other Publisher and emitting its values.
|
static <T> Perhaps<T> |
create(MaybeOnSubscribe<T> onCreate)
Create a Perhaps that for each incoming Subscriber calls a callback to
emit a sync or async events in a thread-safe, backpressure-aware and
cancellation-safe manner.
|
Perhaps<T> |
defaultIfEmpty(T item)
Signal the given item if this Perhaps is empty.
|
static <T> Perhaps<T> |
defer(Supplier<? extends Perhaps<? extends T>> supplier)
Defers the creation of the actual Perhaps instance until
subscription time and for each downstream Subscriber the given
Supplier is called.
|
Perhaps<T> |
delay(long delay,
TimeUnit unit)
Delay the emission of the signals of this Perhaps by the
given amount of time.
|
Perhaps<T> |
delay(long delay,
TimeUnit unit,
Scheduler scheduler)
Delay the emission of the signals of this Perhaps by the
given amount of time.
|
Perhaps<T> |
delay(Publisher<?> other)
Delay the emission of the signals of this Perhaps till
the other Publisher signals an item or completes.
|
Perhaps<T> |
delaySubscription(long delay,
TimeUnit unit)
Delay the subscription to this Perhaps by the given time amount.
|
Perhaps<T> |
delaySubscription(long delay,
TimeUnit unit,
Scheduler scheduler)
Delay the subscription to this Perhaps by the given time amount,
running on the specified Scheduler.
|
Perhaps<T> |
delaySubscription(Publisher<?> other)
Delay the subscription to this Perhaps until the other Publisher
signals an item or completes.
|
Perhaps<T> |
doAfterNext(Consumer<? super T> onAfterNext)
Executes a callback after the value is emitted to downstream.
|
Perhaps<T> |
doAfterTerminate(Action onAfterTerminate)
Executes the callback after this Perhaps terminates and the downstream
is notified.
|
Perhaps<T> |
doFinally(Action onFinally)
Executes the callback exactly if the upstream terminates or
the downstream cancels the sequence.
|
Perhaps<T> |
doOnCancel(Action onCancel)
Executes the callback if the downstream cancels the sequence.
|
Perhaps<T> |
doOnComplete(Action onComplete)
Executes a callback when the upstream completes normally.
|
Perhaps<T> |
doOnError(Consumer<? super Throwable> onError)
Executes a callback when the upstream signals an error.
|
Perhaps<T> |
doOnNext(Consumer<? super T> onNext)
Executes a callback before the value is emitted to downstream.
|
Perhaps<T> |
doOnRequest(LongConsumer onRequest)
Executes the callback when the downstream requests from this Perhaps.
|
Perhaps<T> |
doOnSubscribe(Consumer<? super Subscription> onSubscribe)
Executes a callback when the upstream calls onSubscribe.
|
static <T> Perhaps<T> |
empty()
Returns an empty Perhaps.
|
static <T> Perhaps<T> |
error(Supplier<? extends Throwable> errorSupplier)
Returns a Perhaps that signals the error returned from
the errorSupplier to each individual Subscriber.
|
static <T> Perhaps<T> |
error(Throwable error)
Returns a Perhaps that signals the given error to Subscribers.
|
Perhaps<T> |
filter(Predicate<? super T> predicate)
Filters the value from upstream with a predicate and completes
if the filter didn't match it.
|
<R> Perhaps<R> |
flatMap(Function<? super T,? extends Perhaps<? extends R>> mapper)
Maps the upstream's value into another Perhaps and emits its
resulting events.
|
<R> Perhaps<R> |
flatMap(Function<? super T,? extends Perhaps<? extends R>> onSuccessMapper,
Function<? super Throwable,? extends Perhaps<? extends R>> onErrorMapper,
Supplier<? extends Perhaps<? extends R>> onCompleteMapper)
Maps the upstream events into other Perhaps instances and emits
its resulting events.
|
<R> Flowable<R> |
flatMapPublisher(Function<? super T,? extends Publisher<? extends R>> mapper)
Maps the upstream value into a Publisher and emits all of its events.
|
static <T> Perhaps<T> |
fromAction(Action action)
Run an action for each individual Subscriber and terminate.
|
static <T> Perhaps<T> |
fromCallable(Callable<T> callable)
Runs a Callable and emits its resulting value or its
exception; null is considered to be an indication for an empty Perhaps.
|
static <T> Perhaps<T> |
fromCompletable(CompletableSource source)
Wraps a Completable and signals its terminal events.
|
static <T> Perhaps<T> |
fromFuture(Future<? extends T> future)
When subscribed, the future is awaited blockingly and
indefinitely for its result value; null result
will yield a NoSuchElementException.
|
static <T> Perhaps<T> |
fromFuture(Future<? extends T> future,
long timeout,
TimeUnit unit)
When subscribed, the future is awaited blockingly for
a given amount of time for its result value; null result
will yield a NoSuchElementException and a timeout
will yield a TimeoutException.
|
static <T> Perhaps<T> |
fromMaybe(MaybeSource<T> source)
Wraps a Maybe and signals its events.
|
static <T> Perhaps<T> |
fromPublisher(Publisher<T> source)
Wraps a Publisher and signals its single value or completion signal or
signals IndexOutOfBoundsException if the Publisher has more than one element.
|
static <T> Perhaps<T> |
fromSingle(SingleSource<T> source)
Wraps a Single and signals its events.
|
static <T> Function<Perhaps<T>,Perhaps<T>> |
getOnAssemblyHandler()
Returns the current onAssembly handler.
|
Perhaps<T> |
hide()
Hides the identity of this Perhaps instance, including
its subscriber.
|
Nono |
ignoreElement()
Ignore the element of this Perhaps.
|
static <T> Perhaps<T> |
just(T item)
Returns a Perhaps that signals the given item.
|
<R> Perhaps<R> |
lift(Function<Subscriber<? super R>,Subscriber<? super T>> onLift)
Map the downstream Subscriber into an upstream Subscriber.
|
<R> Perhaps<R> |
map(Function<? super T,? extends R> mapper)
Maps the value of this Perhaps into another value (of possibly different
type).
|
Perhaps<T> |
mapError(Function<? super Throwable,? extends Throwable> errorMapper)
Maps the error from upstream into another Throwable error.
|
static <T> Flowable<T> |
merge(Iterable<? extends Perhaps<? extends T>> sources)
Merge the values in arbitrary order from a sequence of Perhaps sources.
|
static <T> Flowable<T> |
merge(Iterable<? extends Perhaps<? extends T>> sources,
int maxConcurrency)
Merge the values in arbitrary order from a sequence of Perhaps sources.
|
static <T> Flowable<T> |
merge(Publisher<? extends Perhaps<? extends T>> sources)
Merge the values in arbitrary order from a sequence of Perhaps sources.
|
static <T> Flowable<T> |
merge(Publisher<? extends Perhaps<? extends T>> sources,
int maxConcurrency)
Merge the values in arbitrary order from a sequence of Perhaps sources.
|
static <T> Flowable<T> |
mergeArray(int maxConcurrency,
Perhaps<? extends T>... sources)
Merge the values in arbitrary order from a sequence of Perhaps sources.
|
static <T> Flowable<T> |
mergeArray(Perhaps<? extends T>... sources)
Merge the values in arbitrary order from a sequence of Perhaps sources.
|
static <T> Flowable<T> |
mergeArrayDelayError(int maxConcurrency,
Perhaps<? extends T>... sources)
Merge the values in arbitrary order from a sequence of Perhaps sources,
delaying errors till all sources terminate.
|
static <T> Flowable<T> |
mergeArrayDelayError(Perhaps<? extends T>... sources)
Merge the values in arbitrary order from a sequence of Perhaps sources,
delaying errors till all sources terminate.
|
static <T> Flowable<T> |
mergeDelayError(Iterable<? extends Perhaps<? extends T>> sources)
Merge the values in arbitrary order from a sequence of Perhaps sources,
delaying errors till all sources terminate.
|
static <T> Flowable<T> |
mergeDelayError(Iterable<? extends Perhaps<? extends T>> sources,
int maxConcurrency)
Merge the values in arbitrary order from a sequence of Perhaps sources,
delaying errors till all sources terminate.
|
static <T> Flowable<T> |
mergeDelayError(Publisher<? extends Perhaps<? extends T>> sources)
Merge the values in arbitrary order from a sequence of Perhaps sources,
delaying errors till all sources terminate.
|
static <T> Flowable<T> |
mergeDelayError(Publisher<? extends Perhaps<? extends T>> sources,
int maxConcurrency)
Merge the values in arbitrary order from a sequence of Perhaps sources,
delaying errors till all sources terminate.
|
Flowable<T> |
mergeWith(Publisher<? extends T> other)
Merges this Perhaps with another Publisher and emits all their
values.
|
static <T> Perhaps<T> |
never()
Returns a Perhaps that never signals any item or terminal event.
|
Perhaps<T> |
observeOn(Scheduler scheduler)
Observe the events of this Perhaps on the specified scheduler.
|
protected static <T> Perhaps<T> |
onAssembly(Perhaps<T> source) |
Perhaps<T> |
onErrorComplete()
Completes in case the upstream signals an error.
|
Perhaps<T> |
onErrorResumeNext(Function<? super Throwable,? extends Perhaps<? extends T>> fallbackSupplier)
If the upstream signals an error, apply the given function to that
Throwable error and resume with the returned Perhaps.
|
Perhaps<T> |
onErrorResumeWith(Perhaps<? extends T> fallback)
If the upstream signals an error, switch to the given fallback
Perhaps.
|
Perhaps<T> |
onErrorReturnItem(T item)
If the upstream signals an error, it is replaced by a signal
of the given item and normal completion.
|
Flowable<T> |
repeat()
Repeats this Perhaps indefinitely.
|
Flowable<T> |
repeat(BooleanSupplier stop)
Repeats this Perhaps until the given boolean supplier returns true when an
repeat iteration of this Perhaps completes.
|
Flowable<T> |
repeat(long times)
Repeats this Perhaps at most the given number of times.
|
Flowable<T> |
repeatWhen(Function<? super Flowable<Object>,? extends Publisher<?>> handler)
Repeats this Perhaps when the Publisher returned by the handler function emits
an item or terminates if this Publisher terminates.
|
Perhaps<T> |
retry()
Retry this Perhaps indefinitely if it fails.
|
Perhaps<T> |
retry(long times)
Retry this Perhaps at most the given number of times if it fails.
|
Perhaps<T> |
retry(Predicate<? super Throwable> predicate)
Retry this Perhaps if the predicate returns true for the latest failure
Throwable.
|
Perhaps<T> |
retryWhen(Function<? super Flowable<Throwable>,? extends Publisher<?>> handler)
Retry this Perhaps if the Publisher returned by the handler signals an item
in response to the failure Throwable.
|
static <T> void |
setOnAssemblyHandler(Function<Perhaps<T>,Perhaps<T>> handler)
Set the onAssembly handler.
|
Disposable |
subscribe()
Subscribe to this Perhaps and ignore any signal it produces.
|
Disposable |
subscribe(Consumer<? super T> onNext)
Subscribes to this Perhaps and calls the onNext if this Perhaps succeeds.
|
Disposable |
subscribe(Consumer<? super T> onNext,
Consumer<? super Throwable> onError)
Subscribes to this Perhaps and calls the appropriate callback for the resulting signal.
|
Disposable |
subscribe(Consumer<? super T> onNext,
Consumer<? super Throwable> onError,
Action onComplete)
Subscribes to this Perhaps and calls the appropriate callback for the resulting signal.
|
void |
subscribe(Subscriber<? super T> s) |
protected abstract void |
subscribeActual(Subscriber<? super T> s)
Implement this method to react to a Subscriber subscribing to this Perhaps.
|
Perhaps<T> |
subscribeOn(Scheduler scheduler)
Subscribes to the upstream Perhaps and requests on the
specified Scheduler.
|
<E extends Subscriber<? super T>> |
subscribeWith(E s)
Subscribe with a Subscriber (subclass) and return it as is.
|
Perhaps<T> |
switchIfEmpty(Perhaps<? extends T> other)
Switch to the other Perhaps if this Perhaps is empty.
|
Perhaps<T> |
takeUntil(Publisher<?> other)
Try consuming this Perhaps until the other Publisher signals an item
or completes which then completes the Perhaps.
|
TestSubscriber<T> |
test()
Creates a TestSubscriber and subscribes it to this Perhaps.
|
TestSubscriber<T> |
test(boolean cancel)
Creates a TestSubscriber, optionally cancels it, and subscribes
it to this Perhaps.
|
TestSubscriber<T> |
test(long initialRequest)
Creates a TestSubscriber with the given initial request and
subscribes it to this Perhaps.
|
TestSubscriber<T> |
test(long initialRequest,
boolean cancel)
Creates a TestSubscriber with the given initial request,
optionally cancels it, and subscribes it to this Perhaps.
|
Perhaps<T> |
timeout(long timeout,
TimeUnit unit)
Signals a TimeoutException if the Perhaps doesn't signal an item
within the specified time.
|
Perhaps<T> |
timeout(long timeout,
TimeUnit unit,
Perhaps<? extends T> fallback)
Switch to the fallback Perhaps if this Perhaps doesn't signal an
item (or terminates) within the specified time.
|
Perhaps<T> |
timeout(long timeout,
TimeUnit unit,
Scheduler scheduler)
Signals a TimeoutException if the Perhaps doesn't signal an item
or (terminates) within the specified time.
|
Perhaps<T> |
timeout(long timeout,
TimeUnit unit,
Scheduler scheduler,
Perhaps<? extends T> fallback)
Switch to the fallback Perhaps if this Perhaps doesn't signal an
item (or terminates) within the specified time.
|
Perhaps<T> |
timeout(Publisher<?> other)
Signal a TimeoutException if the other Publisher signals an item or
completes before this Perhaps does.
|
Perhaps<T> |
timeout(Publisher<?> other,
Perhaps<? extends T> fallback)
Switch to the fallback Perhaps if the other Publisher signals an item or
completes before this Perhaps does.
|
static Perhaps<Long> |
timer(long delay,
TimeUnit unit)
Signals a 0L after the specified amount of time has passed since
subscription.
|
static Perhaps<Long> |
timer(long delay,
TimeUnit unit,
Scheduler scheduler)
Signals a 0L after the specified amount of time has passed since
subscription on the specified scheduler.
|
<R> R |
to(Function<? super Perhaps<T>,R> converter)
Applies the function, fluently to this Perhaps and returns the value it returns.
|
Flowable<T> |
toFlowable()
Convert this Perhaps into a Flowable.
|
Future<T> |
toFuture()
Converts this Perhaps into a Future and signals its single
value or null if this Perhaps is empty.
|
Maybe<T> |
toMaybe()
Convert this Perhaps into a Maybe.
|
Observable<T> |
toObservable()
Convert this Perhaps into an Observable.
|
Perhaps<T> |
unsubscribeOn(Scheduler scheduler)
If the downstream cancels, the upstream is cancelled on
the specified scheduler.
|
static <T,R> Perhaps<T> |
using(Supplier<R> resourceSupplier,
Function<? super R,? extends Perhaps<? extends T>> sourceSupplier,
Consumer<? super R> disposer)
Generate a resource and a Perhaps based on that resource and then
dispose that resource eagerly when the Perhaps terminates or the
downstream cancels the sequence.
|
static <T,R> Perhaps<T> |
using(Supplier<R> resourceSupplier,
Function<? super R,? extends Perhaps<? extends T>> sourceSupplier,
Consumer<? super R> disposer,
boolean eager)
Generate a resource and a Perhaps based on that resource and then
dispose that resource eagerly when the Perhaps terminates or the
downstream cancels the sequence.
|
static <T,R> Perhaps<R> |
zip(Iterable<? extends Perhaps<? extends T>> sources,
Function<? super Object[],? extends R> zipper)
Combines the Perhaps values of all the sources via a zipper function into a
single resulting value.
|
static <T,R> Perhaps<R> |
zipArray(Function<? super Object[],? extends R> zipper,
Perhaps<? extends T>... sources)
Combines the Perhaps values of all the sources via a zipper function into a
single resulting value.
|
<U,R> Perhaps<R> |
zipWith(Perhaps<? extends U> other,
BiFunction<? super T,? super U,? extends R> zipper)
Zips the value of this Perhaps with the other Perhaps through
a BiFunction.
|
public static <T> Function<Perhaps<T>,Perhaps<T>> getOnAssemblyHandler()
T
- the target value typepublic static <T> void setOnAssemblyHandler(Function<Perhaps<T>,Perhaps<T>> handler)
T
- the target value typehandler
- the handler, null clears the handlerpublic static <T> Perhaps<T> create(MaybeOnSubscribe<T> onCreate)
T
- the value type emittedonCreate
- the callback called for each individual subscriber with an
abstraction of the incoming Subscriber.public static <T> Perhaps<T> just(T item)
T
- the value typeitem
- the item to signal, not nullpublic static <T> Perhaps<T> empty()
T
- the value typepublic static <T> Perhaps<T> error(Throwable error)
T
- the value typeerror
- the error to signal, not nullpublic static <T> Perhaps<T> error(Supplier<? extends Throwable> errorSupplier)
T
- the value typeerrorSupplier
- the supplier called for each Subscriber to
return a Throwable to be signalledpublic static <T> Perhaps<T> never()
T
- the value typepublic static <T> Perhaps<T> fromCallable(Callable<T> callable)
T
- the value typecallable
- the callable to call for each individual Subscriberpublic static <T> Perhaps<T> fromAction(Action action)
T
- the value typeaction
- the action to call for each individual Subscriberpublic static <T> Perhaps<T> fromFuture(Future<? extends T> future)
T
- the value typefuture
- the future to awaitpublic static <T> Perhaps<T> fromFuture(Future<? extends T> future, long timeout, TimeUnit unit)
T
- the value typefuture
- the future to awaittimeout
- the timeout valueunit
- the time unitpublic static <T> Perhaps<T> fromPublisher(Publisher<T> source)
T
- the value typesource
- the source Publisherpublic static <T> Perhaps<T> fromSingle(SingleSource<T> source)
T
- the value typesource
- the sourcepublic static <T> Perhaps<T> fromMaybe(MaybeSource<T> source)
T
- the value typesource
- the sourcepublic static <T> Perhaps<T> fromCompletable(CompletableSource source)
T
- the value typesource
- the sourcepublic static <T> Perhaps<T> defer(Supplier<? extends Perhaps<? extends T>> supplier)
T
- the value typesupplier
- the Supplier called for each individual Subscriber
to return a Perhaps to be subscribe to.public static <T> Perhaps<T> amb(Iterable<? extends Perhaps<? extends T>> sources)
T
- the common value typesources
- the Iterable sequence of Perhaps sources@SafeVarargs public static <T> Perhaps<T> ambArray(Perhaps<? extends T>... sources)
T
- the common value typesources
- the array of Perhaps sourcespublic static <T> Flowable<T> concat(Iterable<? extends Perhaps<? extends T>> sources)
T
- the common base value typesources
- the sequence of sourcespublic static <T> Flowable<T> concat(Publisher<? extends Perhaps<? extends T>> sources)
T
- the common base value typesources
- the sequence of sourcespublic static <T> Flowable<T> concat(Publisher<? extends Perhaps<? extends T>> sources, int prefetch)
T
- the common base value typesources
- the sequence of sourcesprefetch
- the number of sources to prefetch from upstream@SafeVarargs public static <T> Flowable<T> concatArray(Perhaps<? extends T>... sources)
T
- the common base value typesources
- the sequence of sourcespublic static <T> Flowable<T> concatDelayError(Iterable<? extends Perhaps<? extends T>> sources)
T
- the common base value typesources
- the sequence of sourcespublic static <T> Flowable<T> concatDelayError(Publisher<? extends Perhaps<? extends T>> sources)
T
- the common base value typesources
- the sequence of sourcespublic static <T> Flowable<T> concatDelayError(Publisher<? extends Perhaps<? extends T>> sources, int prefetch)
T
- the common base value typesources
- the sequence of sourcesprefetch
- the number of sources to prefetch from upstreampublic static <T> Flowable<T> concatDelayError(Publisher<? extends Perhaps<? extends T>> sources, int prefetch, boolean tillTheEnd)
T
- the common base value typesources
- the sequence of sourcesprefetch
- the number of sources to prefetch from upstreamtillTheEnd
- if true, errors are delayed to the very end;
if false, an error will be signalled at the end of one source@SafeVarargs public static <T> Flowable<T> concatArrayDelayError(Perhaps<? extends T>... sources)
T
- the common base value typesources
- the sequence of sourcespublic static <T> Flowable<T> merge(Iterable<? extends Perhaps<? extends T>> sources)
T
- the common base value typesources
- the sequence of sourcespublic static <T> Flowable<T> merge(Iterable<? extends Perhaps<? extends T>> sources, int maxConcurrency)
T
- the common base value typesources
- the sequence of sourcesmaxConcurrency
- the maximum number of active subscriptionspublic static <T> Flowable<T> merge(Publisher<? extends Perhaps<? extends T>> sources)
T
- the common base value typesources
- the sequence of sourcespublic static <T> Flowable<T> merge(Publisher<? extends Perhaps<? extends T>> sources, int maxConcurrency)
T
- the common base value typesources
- the sequence of sourcesmaxConcurrency
- the maximum number of active subscriptions@SafeVarargs public static <T> Flowable<T> mergeArray(Perhaps<? extends T>... sources)
T
- the common base value typesources
- the sequence of sources@SafeVarargs public static <T> Flowable<T> mergeArray(int maxConcurrency, Perhaps<? extends T>... sources)
T
- the common base value typesources
- the sequence of sourcesmaxConcurrency
- the maximum number of active subscriptionspublic static <T> Flowable<T> mergeDelayError(Iterable<? extends Perhaps<? extends T>> sources)
T
- the common base value typesources
- the sequence of sourcespublic static <T> Flowable<T> mergeDelayError(Iterable<? extends Perhaps<? extends T>> sources, int maxConcurrency)
T
- the common base value typesources
- the sequence of sourcesmaxConcurrency
- the maximum number of active subscriptionspublic static <T> Flowable<T> mergeDelayError(Publisher<? extends Perhaps<? extends T>> sources)
T
- the common base value typesources
- the sequence of sourcespublic static <T> Flowable<T> mergeDelayError(Publisher<? extends Perhaps<? extends T>> sources, int maxConcurrency)
T
- the common base value typesources
- the sequence of sourcesmaxConcurrency
- the maximum number of active subscriptions@SafeVarargs public static <T> Flowable<T> mergeArrayDelayError(Perhaps<? extends T>... sources)
T
- the common base value typesources
- the sequence of sources@SafeVarargs public static <T> Flowable<T> mergeArrayDelayError(int maxConcurrency, Perhaps<? extends T>... sources)
T
- the common base value typesources
- the sequence of sourcesmaxConcurrency
- the maximum number of active subscriptionspublic static Perhaps<Long> timer(long delay, TimeUnit unit)
delay
- the delay timeunit
- the time unitpublic static Perhaps<Long> timer(long delay, TimeUnit unit, Scheduler scheduler)
delay
- the delay timeunit
- the time unitscheduler
- the scheduler to wait onpublic static <T,R> Perhaps<T> using(Supplier<R> resourceSupplier, Function<? super R,? extends Perhaps<? extends T>> sourceSupplier, Consumer<? super R> disposer)
T
- the value typeR
- the resource typeresourceSupplier
- the callback to get a resource for each subscribersourceSupplier
- the function that returns a Perhaps for the generated resourcedisposer
- the consumer of the resource once the upstream terminates or the
downstream cancelspublic static <T,R> Perhaps<T> using(Supplier<R> resourceSupplier, Function<? super R,? extends Perhaps<? extends T>> sourceSupplier, Consumer<? super R> disposer, boolean eager)
T
- the value typeR
- the resource typeresourceSupplier
- the callback to get a resource for each subscribersourceSupplier
- the function that returns a Perhaps for the generated resourcedisposer
- the consumer of the resource once the upstream terminates or the
downstream cancelseager
- if true, the resource is disposed before the terminal event is emitted
if false, the resource is disposed after the terminal event has been emittedpublic static <T,R> Perhaps<R> zip(Iterable<? extends Perhaps<? extends T>> sources, Function<? super Object[],? extends R> zipper)
T
- the common input base typeR
- the result typesources
- the sequence of Perhaps sourceszipper
- the function takin in an array of values and returns a Perhaps value@SafeVarargs public static <T,R> Perhaps<R> zipArray(Function<? super Object[],? extends R> zipper, Perhaps<? extends T>... sources)
T
- the common input base typeR
- the result typesources
- the sequence of Perhaps sourceszipper
- the function takin in an array of values and returns a Perhaps valuepublic final Perhaps<T> ambWith(Perhaps<? extends T> other)
other
- the other Perhaps instancepublic final Perhaps<T> andThen(Nono other)
other
- the other Nono source to run after thispublic final Flowable<T> andThen(Publisher<? extends T> other)
other
- the other Publisher to run after thispublic final Flowable<T> concatWith(Publisher<? extends T> other)
other
- the other Publisher to run after thispublic final Flowable<T> mergeWith(Publisher<? extends T> other)
other
- the other Publisher source instancepublic final <U,R> Perhaps<R> zipWith(Perhaps<? extends U> other, BiFunction<? super T,? super U,? extends R> zipper)
U
- the value type of the other sourceR
- the result typeother
- the other Perhaps sourcezipper
- the function receiving each source value and should
return a value to be emittedpublic final <R> Perhaps<R> map(Function<? super T,? extends R> mapper)
R
- the result value typemapper
- the function that receives the onNext value from this Perhaps
and returns another valuepublic final Perhaps<T> mapError(Function<? super Throwable,? extends Throwable> errorMapper)
errorMapper
- the function that receives the upstream error and
returns a Throwablepublic final Perhaps<T> filter(Predicate<? super T> predicate)
predicate
- the predicate receiving the upstream value and
returns true if it should be passed along.public final Nono ignoreElement()
public final Perhaps<T> hide()
This allows preventing cerain optimizations as well for diagnostic purposes.
public final <R> Perhaps<R> flatMap(Function<? super T,? extends Perhaps<? extends R>> mapper)
R
- the output value typemapper
- the function that receives the upstream's value
and returns a Perhaps to be consumed.public final <R> Perhaps<R> flatMap(Function<? super T,? extends Perhaps<? extends R>> onSuccessMapper, Function<? super Throwable,? extends Perhaps<? extends R>> onErrorMapper, Supplier<? extends Perhaps<? extends R>> onCompleteMapper)
Note that only one of the onXXXMapper is called based on what the upstream signals, i.e., the usual onNext + onComplete will pick the Perhaps of the onSuccessMapper only and never the onCompleteMapper.
R
- the result value typeonSuccessMapper
- the function called for the upstream valueonErrorMapper
- the function called for the upstream erroronCompleteMapper
- the function called when the upstream is emptypublic final <R> Flowable<R> flatMapPublisher(Function<? super T,? extends Publisher<? extends R>> mapper)
R
- the result value typemapper
- the function that maps the success value into a Publisher that
gets subscribed to and streamed furtherpublic final Perhaps<T> onErrorComplete()
public final Perhaps<T> onErrorReturnItem(T item)
item
- the item to signal in case of an errorpublic final Perhaps<T> onErrorResumeWith(Perhaps<? extends T> fallback)
fallback
- the fallback to switch to in case of an errorpublic final Perhaps<T> onErrorResumeNext(Function<? super Throwable,? extends Perhaps<? extends T>> fallbackSupplier)
fallbackSupplier
- the function that receives the upstream Throwable
and should return the fallback Perhaps that will be subscribed to as
a resumptionspublic final Perhaps<T> timeout(long timeout, TimeUnit unit)
timeout
- the time to wait for an itemunit
- the unit of timepublic final Perhaps<T> timeout(long timeout, TimeUnit unit, Scheduler scheduler)
timeout
- the time to wait for an itemunit
- the unit of timescheduler
- the scheduler to wait onpublic final Perhaps<T> timeout(long timeout, TimeUnit unit, Perhaps<? extends T> fallback)
timeout
- the time to wait for an itemunit
- the unit of timefallback
- the Perhaps to switch to if this Perhaps times outpublic final Perhaps<T> timeout(long timeout, TimeUnit unit, Scheduler scheduler, Perhaps<? extends T> fallback)
timeout
- the time to wait for an itemunit
- the unit of timescheduler
- the scheduler to wait onfallback
- the Perhaps to switch to if this Perhaps times outpublic final Perhaps<T> timeout(Publisher<?> other)
other
- the other Publisher that signals the timeoutpublic final Perhaps<T> timeout(Publisher<?> other, Perhaps<? extends T> fallback)
other
- the other Publisher that signals the timeoutfallback
- the Perhaps to switch to in case of a timeoutpublic final Perhaps<T> defaultIfEmpty(T item)
item
- the item to signalpublic final Perhaps<T> switchIfEmpty(Perhaps<? extends T> other)
other
- the other Perhaps to switch topublic final Flowable<T> repeat()
public final Flowable<T> repeat(long times)
times
- the number of times to repeatpublic final Flowable<T> repeat(BooleanSupplier stop)
stop
- the supplier of a boolean value that should return true to
stop repeating.public final Flowable<T> repeatWhen(Function<? super Flowable<Object>,? extends Publisher<?>> handler)
handler
- the function that receives Flowable that emits an item
when this Perhaps completes and returns a Publisher that should emit an item
to trigger a repeat or terminate to trigger a termination.public final Perhaps<T> retry()
public final Perhaps<T> retry(long times)
times
- the number of times, Long.MAX_VALUE means indefinitelypublic final Perhaps<T> retry(Predicate<? super Throwable> predicate)
predicate
- the predicate receiving the latest Throwable and
if returns true, the Perhaps is retried.public final Perhaps<T> retryWhen(Function<? super Flowable<Throwable>,? extends Publisher<?>> handler)
handler
- the function that receives a Flowable that signals the
failure Throwable of this Perhaps and returns a Publisher which triggers a retry
or termination.public final Perhaps<T> subscribeOn(Scheduler scheduler)
scheduler
- the scheduler to subscribe onpublic final Perhaps<T> observeOn(Scheduler scheduler)
scheduler
- the scheduler to observe events onpublic final Perhaps<T> unsubscribeOn(Scheduler scheduler)
Note that normal termination don't trigger cancellation.
scheduler
- the scheduler to unsubscribe onpublic final Perhaps<T> doOnSubscribe(Consumer<? super Subscription> onSubscribe)
onSubscribe
- the consumer called with the upstream Subscriptionpublic final Perhaps<T> doOnRequest(LongConsumer onRequest)
onRequest
- the callback called with the request amountpublic final Perhaps<T> doOnCancel(Action onCancel)
onCancel
- the action to callpublic final Perhaps<T> doOnNext(Consumer<? super T> onNext)
onNext
- the consumer called with the current value before it is
is emitted to downstream.public final Perhaps<T> doAfterNext(Consumer<? super T> onAfterNext)
onAfterNext
- the consumer called with the current value after it is
is emitted to downstream.public final Perhaps<T> doOnError(Consumer<? super Throwable> onError)
onError
- the consumer called before the error is emitted to
the downstreampublic final Perhaps<T> doOnComplete(Action onComplete)
onComplete
- the consumer called before the completion event
is emitted to the downstream.public final Perhaps<T> doAfterTerminate(Action onAfterTerminate)
onAfterTerminate
- the callback to call after the downstream is notifiedpublic final Perhaps<T> doFinally(Action onFinally)
onFinally
- the action to callpublic final Perhaps<T> delay(long delay, TimeUnit unit)
delay
- the delay amountunit
- the time unit of the delaypublic final Perhaps<T> delay(long delay, TimeUnit unit, Scheduler scheduler)
delay
- the delay amountunit
- the time unit of the delayscheduler
- the scheduler to delay onpublic final Perhaps<T> delay(Publisher<?> other)
other
- the other Publisher to delay withpublic final Perhaps<T> delaySubscription(long delay, TimeUnit unit)
delay
- the amount to delay the subscriptionunit
- the delay time unitpublic final Perhaps<T> delaySubscription(long delay, TimeUnit unit, Scheduler scheduler)
delay
- the amount to delay the subscriptionunit
- the delay time unitscheduler
- the scheduler to wait onpublic final Perhaps<T> delaySubscription(Publisher<?> other)
other
- the other Publisher that will trigger the actual
subscription to this Perhaps.public final <R> Perhaps<R> lift(Function<Subscriber<? super R>,Subscriber<? super T>> onLift)
R
- the downstream value typeonLift
- the function called with the downstream's Subscriber and
should return a Subscriber to be subscribed to this Perhaps.public final <R> R to(Function<? super Perhaps<T>,R> converter)
R
- the result typeconverter
- the function receiving this Perhaps and returns a value to be returnedpublic final <R> Perhaps<R> compose(Function<? super Perhaps<T>,? extends Perhaps<R>> composer)
R
- the result typecomposer
- the function that receives this Perhaps and should return a Perhapspublic final Perhaps<T> takeUntil(Publisher<?> other)
other
- the other Publisher instancepublic final Flowable<T> toFlowable()
public final Observable<T> toObservable()
public final Maybe<T> toMaybe()
public final Perhaps<T> cache()
public final void subscribe(Subscriber<? super T> s)
protected abstract void subscribeActual(Subscriber<? super T> s)
s
- the downstream Subscriber, never nullpublic final <E extends Subscriber<? super T>> E subscribeWith(E s)
E
- the Subscriber subclass types
- the soubscriber, not nulls
as ispublic final Disposable subscribe()
public final Disposable subscribe(Consumer<? super T> onNext)
onNext
- called when this Perhaps succeedspublic final Disposable subscribe(Consumer<? super T> onNext, Consumer<? super Throwable> onError)
onNext
- called when this Perhaps succeedsonError
- called when this Perhaps failspublic final Disposable subscribe(Consumer<? super T> onNext, Consumer<? super Throwable> onError, Action onComplete)
onNext
- called when this Perhaps succeedsonError
- called when this Perhaps failsonComplete
- called when this Perhaps succeeds after the call to onNextpublic final void blockingSubscribe()
public final void blockingSubscribe(Consumer<? super T> onNext)
onNext
- the callback to call when this Perhaps completes with a success valuepublic final void blockingSubscribe(Consumer<? super T> onNext, Consumer<? super Throwable> onError)
onNext
- the callback to call when this Perhaps completes with a success valueonError
- the callback to call when this Perhaps fails with an errorpublic final void blockingSubscribe(Consumer<? super T> onNext, Consumer<? super Throwable> onError, Action onComplete)
onNext
- called when the Perhaps succeedsonError
- called when the Perhaps failsonComplete
- called when the Perhaps succeeds after the call to onNext.public final T blockingGet()
public final T blockingGet(long timeout, TimeUnit unit)
timeout
- the time to wait for a success valueunit
- the time unit of the timeoutpublic final TestSubscriber<T> test()
public final TestSubscriber<T> test(boolean cancel)
cancel
- if true, the TestSubscriber will be cancelled before
subscribing to this Perhapspublic final TestSubscriber<T> test(long initialRequest)
initialRequest
- the initial request amount, non-negativepublic final TestSubscriber<T> test(long initialRequest, boolean cancel)
initialRequest
- the initial request amount, non-negativecancel
- if true, the TestSubscriber will be cancelled before
subscribing to this Perhaps