T
- the type of the single value of this classpublic abstract class Mono<T> extends Object implements Publisher<T>
Publisher
with basic rx operators that completes successfully by emitting an element, or
with an error.
The rx operators will offer aliases for input Mono
type to preserve the "at most one"
property of the resulting Mono
. For instance flatMap
returns a
Mono
, while there is a flatMapMany(java.util.function.Function<? super T, ? extends org.reactivestreams.Publisher<? extends R>>)
alias with possibly more than 1 emission.
Mono<Void>
should be used for Publisher
that just completes without any value.
It is intended to be used in implementations and return types, input parameters should keep using raw Publisher
as much as possible.
Note that using state in the java.util.function
/ lambdas used within Mono operators
should be avoided, as these may be shared between several Subscribers
.
Flux
Constructor and Description |
---|
Mono() |
Modifier and Type | Method and Description |
---|---|
<T2> Mono<Tuple2<T,T2>> |
and(Function<T,Mono<? extends T2>> rightGenerator)
Wait for the result from this mono, use it to create a second mono via the
provided
rightGenerator function and combine both results into a Tuple2 . |
<T2,O> Mono<O> |
and(Function<T,Mono<? extends T2>> rightGenerator,
BiFunction<T,T2,O> combinator)
Wait for the result from this mono, use it to create a second mono via the
provided
rightGenerator function and combine both results into an arbitrary
O object, as defined by the provided combinator function. |
<T2> Mono<Tuple2<T,T2>> |
and(Mono<? extends T2> other)
Combine the result from this mono and another into a
Tuple2 . |
<T2,O> Mono<O> |
and(Mono<? extends T2> other,
BiFunction<? super T,? super T2,? extends O> combinator)
Combine the result from this mono and another into an arbitrary
O object,
as defined by the provided combinator function. |
<P> P |
as(Function<? super Mono<T>,P> transformer)
Transform this
Mono into a target type. |
Mono<T> |
awaitOnSubscribe()
Intercepts the onSubscribe call and makes sure calls to Subscription methods
only happen after the child Subscriber has returned from its onSubscribe method.
|
T |
block()
Block until a next signal is received, will return null if onComplete, T if onNext, throw a
Exceptions.DownstreamException if checked error or origin RuntimeException if unchecked.
|
T |
block(Duration timeout)
Block until a next signal is received, will return null if onComplete, T if onNext, throw a
Exceptions.DownstreamException if checked error or origin RuntimeException if unchecked.
|
T |
blockMillis(long timeout)
Deprecated.
use the
Duration based variants instead, will be removed in 3.1.0 |
Mono<T> |
cache()
Turn this
Mono into a hot source and cache last emitted signals for further Subscriber . |
Mono<T> |
cancelOn(Scheduler scheduler)
|
<E> Mono<E> |
cast(Class<E> clazz)
Cast the current
Mono produced type into a target produced type. |
Mono<T> |
checkpoint()
Activate assembly tracing for this particular
Mono , in case of an error
upstream of the checkpoint. |
Mono<T> |
checkpoint(String description)
Activate assembly tracing for this particular
Mono and give it
a description that will be reflected in the assembly traceback, in case of an error
upstream of the checkpoint. |
<V> Mono<V> |
compose(Function<? super Mono<T>,? extends Publisher<V>> transformer)
|
Flux<T> |
concatWith(Publisher<? extends T> other)
|
static <T> Mono<T> |
create(Consumer<MonoSink<T>> callback)
Creates a deferred emitter that can be used with callback-based
APIs to signal at most one value, a complete or an error signal.
|
Mono<T> |
defaultIfEmpty(T defaultV)
Provide a default unique value if this mono is completed without any data
|
static <T> Mono<T> |
defer(Supplier<? extends Mono<? extends T>> supplier)
Create a
Mono provider that will supply a target Mono to subscribe to for
each Subscriber downstream. |
static Mono<Long> |
delay(Duration duration)
Create a Mono which delays an onNext signal of
duration of given unit and complete on the global timer. |
static Mono<Long> |
delay(Duration duration,
Scheduler timer)
Create a Mono which delays an onNext signal by a given
duration and completes. |
Mono<T> |
delayElement(Duration delay)
Delay this
Flux element (Subscriber.onNext(T) signal) by a given
duration. |
Mono<T> |
delayElement(Duration delay,
Scheduler timer)
|
Mono<T> |
delayElementMillis(long delay)
Deprecated.
use the
Duration based variants instead, will be removed in 3.1.0 |
Mono<T> |
delayElementMillis(long delay,
TimedScheduler timer)
Deprecated.
use the
Duration based variants instead, will be removed in 3.1.0 |
static Mono<Long> |
delayMillis(long duration)
Deprecated.
use the
Duration based variants instead, will be removed in 3.1.0 |
static Mono<Long> |
delayMillis(long duration,
TimedScheduler timer)
Deprecated.
use the
Duration based variants instead, will be removed in 3.1.0 |
Mono<T> |
delaySubscription(Duration delay)
Delay the
subscription to this Mono source until the given
period elapses. |
Mono<T> |
delaySubscription(Duration delay,
Scheduler timer)
|
<U> Mono<T> |
delaySubscription(Publisher<U> subscriptionDelay)
|
Mono<T> |
delaySubscriptionMillis(long delay)
Deprecated.
use the
Duration based variants instead, will be removed in 3.1.0 |
Mono<T> |
delaySubscriptionMillis(long delay,
TimedScheduler timer)
Deprecated.
use the
Duration based variants instead, will be removed in 3.1.0 |
<X> Mono<X> |
dematerialize()
|
Mono<T> |
doAfterTerminate(BiConsumer<? super T,Throwable> afterTerminate)
Triggered after the
Mono terminates, either by completing downstream successfully or with an error. |
Mono<T> |
doFinally(Consumer<SignalType> onFinally)
Triggering afterthe
Mono terminates for any reason,
including cancellation. |
Mono<T> |
doOnCancel(Runnable onCancel)
Triggered when the
Mono is cancelled. |
Mono<T> |
doOnEach(Consumer<? super Signal<T>> signalConsumer)
Triggers side-effects when the
Mono emits an item, fails with an error
or completes successfully. |
<E extends Throwable> |
doOnError(Class<E> exceptionType,
Consumer<? super E> onError)
Triggered when the
Mono completes with an error matching the given exception type. |
Mono<T> |
doOnError(Consumer<? super Throwable> onError)
Triggered when the
Mono completes with an error. |
Mono<T> |
doOnError(Predicate<? super Throwable> predicate,
Consumer<? super Throwable> onError)
Triggered when the
Mono completes with an error matching the given exception. |
Mono<T> |
doOnNext(Consumer<? super T> onNext)
Triggered when the
Mono emits a data successfully. |
Mono<T> |
doOnRequest(LongConsumer consumer)
|
Mono<T> |
doOnSubscribe(Consumer<? super Subscription> onSubscribe)
Triggered when the
Mono is subscribed. |
Mono<T> |
doOnSuccess(Consumer<? super T> onSuccess)
Triggered when the
Mono completes successfully. |
Mono<T> |
doOnTerminate(BiConsumer<? super T,Throwable> onTerminate)
Triggered when the
Mono terminates, either by completing successfully or with an error. |
Mono<Tuple2<Long,T>> |
elapsed()
|
Mono<Tuple2<Long,T>> |
elapsed(Scheduler scheduler)
|
Mono<Tuple2<Long,T>> |
elapsed(TimedScheduler scheduler)
Deprecated.
|
static <T> Mono<T> |
empty()
Create a
Mono that completes without emitting any item. |
static <T> Mono<Void> |
empty(Publisher<T> source)
Create a new
Mono that ignores onNext (dropping them) and only react on Completion signal. |
static <T> Mono<T> |
error(Throwable error)
Create a
Mono that completes with the specified error immediately after onSubscribe. |
Mono<T> |
filter(Predicate<? super T> tester)
Test the result if any of this
Mono and replay it if predicate returns true. |
Mono<T> |
filterWhen(Function<? super T,? extends Publisher<Boolean>> asyncPredicate)
If this
Mono is valued, test the value asynchronously using a generated
Publisher<Boolean> test. |
static <T> Mono<T> |
first(Iterable<? extends Mono<? extends T>> monos)
Pick the first result coming from any of the given monos and populate a new Mono.
|
static <T> Mono<T> |
first(Mono<? extends T>... monos)
Pick the first result coming from any of the given monos and populate a new Mono.
|
<R> Flux<R> |
flatMap(Function<? super T,? extends Publisher<? extends R>> mapper)
Deprecated.
will change signature and behavior in 3.1 to reflect current
then(Function) .
flatMap will be renamed flatMapMany(Function) , so use that instead. |
<R> Flux<R> |
flatMap(Function<? super T,? extends Publisher<? extends R>> mapperOnNext,
Function<Throwable,? extends Publisher<? extends R>> mapperOnError,
Supplier<? extends Publisher<? extends R>> mapperOnComplete)
Deprecated.
will change signature and behavior in 3.1 to reflect current
then(Function) .
flatMap will be renamed flatMapMany(Function, Function, Supplier) , so use that instead. |
<R> Flux<R> |
flatMapIterable(Function<? super T,? extends Iterable<? extends R>> mapper)
|
<R> Flux<R> |
flatMapMany(Function<? super T,? extends Publisher<? extends R>> mapper)
|
<R> Flux<R> |
flatMapMany(Function<? super T,? extends Publisher<? extends R>> mapperOnNext,
Function<? super Throwable,? extends Publisher<? extends R>> mapperOnError,
Supplier<? extends Publisher<? extends R>> mapperOnComplete)
|
Flux<T> |
flux()
|
static <T> Mono<T> |
from(Publisher<? extends T> source)
|
static <T> Mono<T> |
fromCallable(Callable<? extends T> supplier)
|
static <T> Mono<T> |
fromCompletionStage(CompletionStage<? extends T> completionStage)
|
static <I> Mono<I> |
fromDirect(Publisher<? extends I> source)
|
static <T> Mono<T> |
fromFuture(CompletableFuture<? extends T> future)
|
static Mono<Void> |
fromRunnable(Runnable runnable)
Create a
Mono only producing a completion signal after using the given
runnable. |
static <T> Mono<T> |
fromSupplier(Supplier<? extends T> supplier)
|
<R> Mono<R> |
handle(BiConsumer<? super T,SynchronousSink<R>> handler)
Handle the items emitted by this
Mono by calling a biconsumer with the
output sink for each onNext. |
Mono<Boolean> |
hasElement()
Emit a single boolean true if this
Mono has an element. |
Mono<T> |
hide()
Hides the identity of this
Mono instance. |
Mono<T> |
ignoreElement()
Ignores onNext signal (dropping it) and only reacts on termination.
|
static <T> Mono<T> |
ignoreElements(Publisher<T> source)
Create a new
Mono that ignores onNext (dropping them) and only react on Completion signal. |
static <T> Mono<T> |
just(T data)
Create a new
Mono that emits the specified item. |
static <T> Mono<T> |
justOrEmpty(Optional<? extends T> data)
Create a new
Mono that emits the specified item if Optional.isPresent() otherwise only emits
onComplete. |
static <T> Mono<T> |
justOrEmpty(T data)
Create a new
Mono that emits the specified item if non null otherwise only emits
onComplete. |
Mono<T> |
log()
Observe all Reactive Streams signals and use
Logger support to handle trace implementation. |
Mono<T> |
log(String category)
Observe all Reactive Streams signals and use
Logger support to handle trace implementation. |
Mono<T> |
log(String category,
Level level,
boolean showOperatorLine,
SignalType... options)
Observe Reactive Streams signals matching the passed filter
options and
use Logger support to
handle trace
implementation. |
Mono<T> |
log(String category,
Level level,
SignalType... options)
Observe Reactive Streams signals matching the passed flags
options and use
Logger support to handle trace implementation. |
<R> Mono<R> |
map(Function<? super T,? extends R> mapper)
Transform the item emitted by this
Mono by applying a function to item emitted. |
<E extends Throwable> |
mapError(Class<E> type,
Function<? super E,? extends Throwable> mapper)
Deprecated.
use
onErrorMap(java.util.function.Function<? super java.lang.Throwable, ? extends java.lang.Throwable>) instead. Will be removed in 3.1.0. |
Mono<T> |
mapError(Function<Throwable,? extends Throwable> mapper)
Deprecated.
use
onErrorMap(java.util.function.Function<? super java.lang.Throwable, ? extends java.lang.Throwable>) instead. Will be removed in 3.1.0. |
Mono<T> |
mapError(Predicate<? super Throwable> predicate,
Function<? super Throwable,? extends Throwable> mapper)
Deprecated.
use
onErrorMap(java.util.function.Function<? super java.lang.Throwable, ? extends java.lang.Throwable>) instead. Will be removed in 3.1.0. |
Mono<Signal<T>> |
materialize()
Transform the incoming onNext, onError and onComplete signals into
Signal . |
Flux<T> |
mergeWith(Publisher<? extends T> other)
|
static <T> Mono<T> |
never()
Return a
Mono that will never signal any data, error or completion signal. |
<U> Mono<U> |
ofType(Class<U> clazz)
Evaluate the accepted value against the given
Class type. |
protected static <T> Mono<T> |
onAssembly(Mono<T> source)
|
<E extends Throwable> |
onErrorMap(Class<E> type,
Function<? super E,? extends Throwable> mapper)
Transform the error emitted by this
Mono by applying a function if the
error matches the given type, otherwise let the error flow. |
Mono<T> |
onErrorMap(Function<? super Throwable,? extends Throwable> mapper)
Transform the error emitted by this
Mono by applying a function. |
Mono<T> |
onErrorMap(Predicate<? super Throwable> predicate,
Function<? super Throwable,? extends Throwable> mapper)
Transform the error emitted by this
Mono by applying a function if the
error matches the given predicate, otherwise let the error flow. |
<E extends Throwable> |
onErrorResume(Class<E> type,
Function<? super E,? extends Mono<? extends T>> fallback)
Subscribe to a returned fallback publisher when an error matching the given type
occurs.
|
Mono<T> |
onErrorResume(Function<? super Throwable,? extends Mono<? extends T>> fallback)
Subscribe to a returned fallback publisher when any error occurs.
|
Mono<T> |
onErrorResume(Predicate<? super Throwable> predicate,
Function<? super Throwable,? extends Mono<? extends T>> fallback)
$ * Subscribe to a returned fallback publisher when an error matching the given predicate
occurs.
|
<E extends Throwable> |
onErrorReturn(Class<E> type,
T fallbackValue)
Simply emit a captured fallback value when an error of the specified type is
observed on this
Mono . |
<E extends Throwable> |
onErrorReturn(Predicate<? super Throwable> predicate,
T fallbackValue)
Simply emit a captured fallback value when an error matching the given predicate is
observed on this
Mono . |
Mono<T> |
onErrorReturn(T fallback)
Simply emit a captured fallback value when any error is observed on this
Mono . |
Mono<T> |
onTerminateDetach()
Detaches the both the child
Subscriber and the Subscription on
termination or cancellation. |
Mono<T> |
or(Mono<? extends T> other)
Emit the any of the result from this mono or from the given mono
|
<E extends Throwable> |
otherwise(Class<E> type,
Function<? super E,? extends Mono<? extends T>> fallback)
Deprecated.
Use
onErrorResume(Class, Function) instead. Will be removed in 3.1.0. |
Mono<T> |
otherwise(Function<? super Throwable,? extends Mono<? extends T>> fallback)
Deprecated.
Use
onErrorResume(Function) } instead. Will be removed in 3.1.0. |
Mono<T> |
otherwise(Predicate<? super Throwable> predicate,
Function<? super Throwable,? extends Mono<? extends T>> fallback)
Deprecated.
Use
onErrorResume(Predicate, Function) instead. Will be removed in 3.1.0. |
Mono<T> |
otherwiseIfEmpty(Mono<? extends T> alternate)
Deprecated.
Use
switchIfEmpty(reactor.core.publisher.Mono<? extends T>) instead. Will be removed in 3.1.0. |
<E extends Throwable> |
otherwiseReturn(Class<E> type,
T fallbackValue)
Deprecated.
use
onErrorReturn(Class, Object) instead. Will be removed in 3.1.0. |
<E extends Throwable> |
otherwiseReturn(Predicate<? super Throwable> predicate,
T fallbackValue)
Deprecated.
use
onErrorReturn(Predicate, Object) instead. Will be removed in 3.1.0. |
Mono<T> |
otherwiseReturn(T fallback)
Deprecated.
use
onErrorReturn(Object) instead. Will be removed in 3.1.0. |
<R> Mono<R> |
publish(Function<? super Mono<T>,? extends Mono<? extends R>> transform)
Shares a
Mono for the duration of a function that may transform it and
consume it as many times as necessary without causing multiple subscriptions
to the upstream. |
Mono<T> |
publishOn(Scheduler scheduler)
Run onNext, onComplete and onError on a supplied
Scheduler |
Flux<T> |
repeat()
Repeatedly subscribe to the source completion of the previous subscription.
|
Flux<T> |
repeat(BooleanSupplier predicate)
Repeatedly subscribe to the source if the predicate returns true after completion of the previous subscription.
|
Flux<T> |
repeat(long numRepeat)
Repeatedly subscribe to the source if the predicate returns true after completion of the previous subscription.
|
Flux<T> |
repeat(long numRepeat,
BooleanSupplier predicate)
Repeatedly subscribe to the source if the predicate returns true after completion of the previous
subscription.
|
Flux<T> |
repeatWhen(Function<Flux<Long>,? extends Publisher<?>> whenFactory)
Repeatedly subscribe to this
Mono when a companion sequence signals a number of emitted elements in
response to the flux completion signal. |
Mono<T> |
repeatWhenEmpty(Function<Flux<Long>,? extends Publisher<?>> repeatFactory)
Repeatedly subscribe to this
Mono until there is an onNext signal when a companion sequence signals a
number of emitted elements. |
Mono<T> |
repeatWhenEmpty(int maxRepeat,
Function<Flux<Long>,? extends Publisher<?>> repeatFactory)
Repeatedly subscribe to this
Mono until there is an onNext signal when a companion sequence signals a
number of emitted elements. |
Mono<T> |
retry()
Re-subscribes to this
Mono sequence if it signals any error
either indefinitely. |
Mono<T> |
retry(long numRetries)
Re-subscribes to this
Mono sequence if it signals any error
either indefinitely or a fixed number of times. |
Mono<T> |
retry(long numRetries,
Predicate<Throwable> retryMatcher)
|
Mono<T> |
retry(Predicate<Throwable> retryMatcher)
|
Mono<T> |
retryWhen(Function<Flux<Throwable>,? extends Publisher<?>> whenFactory)
|
static <T> Mono<Boolean> |
sequenceEqual(Publisher<? extends T> source1,
Publisher<? extends T> source2)
Returns a Mono that emits a Boolean value that indicates whether two Publisher sequences are the
same by comparing the items emitted by each Publisher pairwise.
|
static <T> Mono<Boolean> |
sequenceEqual(Publisher<? extends T> source1,
Publisher<? extends T> source2,
BiPredicate<? super T,? super T> isEqual)
Returns a Mono that emits a Boolean value that indicates whether two Publisher sequences are the
same by comparing the items emitted by each Publisher pairwise based on the results of a specified
equality function.
|
static <T> Mono<Boolean> |
sequenceEqual(Publisher<? extends T> source1,
Publisher<? extends T> source2,
BiPredicate<? super T,? super T> isEqual,
int bufferSize)
Returns a Mono that emits a Boolean value that indicates whether two Publisher sequences are the
same by comparing the items emitted by each Publisher pairwise based on the results of a specified
equality function.
|
MonoProcessor<T> |
subscribe()
Start the chain and request unbounded demand.
|
Disposable |
subscribe(Consumer<? super T> consumer)
|
Disposable |
subscribe(Consumer<? super T> consumer,
Consumer<? super Throwable> errorConsumer)
|
Disposable |
subscribe(Consumer<? super T> consumer,
Consumer<? super Throwable> errorConsumer,
Runnable completeConsumer)
|
Disposable |
subscribe(Consumer<? super T> consumer,
Consumer<? super Throwable> errorConsumer,
Runnable completeConsumer,
Consumer<? super Subscription> subscriptionConsumer)
|
Mono<T> |
subscribeOn(Scheduler scheduler)
|
<E extends Subscriber<? super T>> |
subscribeWith(E subscriber)
Subscribe the
Mono with the givne Subscriber and return it. |
Mono<T> |
switchIfEmpty(Mono<? extends T> alternate)
Provide an alternative
Mono if this mono is completed without data |
Mono<Void> |
then()
Return a
Mono<Void> which only replays complete and error signals
from this Mono . |
<R> Mono<R> |
then(Function<? super T,? extends Mono<? extends R>> transformer)
|
<V> Mono<V> |
then(Mono<V> other)
Ignore element from this
Mono and transform its completion signal into the
emission and completion signal of a provided Mono<V> . |
<V> Mono<V> |
then(Supplier<? extends Mono<V>> sourceSupplier)
Deprecated.
removed in 3.1, use
then(Mono) with
defer(java.util.function.Supplier<? extends reactor.core.publisher.Mono<? extends T>>) . The competing overload was causing confusion and the generic was
not symmetric with then(Mono) . |
Mono<Void> |
thenEmpty(Publisher<Void> other)
Return a
Mono<Void> that waits for this Mono to complete then
for a supplied Publisher<Void> to also complete. |
<V> Flux<V> |
thenMany(Publisher<V> other)
Ignore element from this mono and transform the completion signal into a
Flux<V> that will emit elements from the provided Publisher . |
<V> Flux<V> |
thenMany(Supplier<? extends Publisher<V>> afterSupplier)
Deprecated.
removed in 3.1, use
thenMany(Publisher) with
defer(java.util.function.Supplier<? extends reactor.core.publisher.Mono<? extends T>>) . The competing overload was called unnecessary by extended
feedback and aligns with removing of Supplier of Publisher aliases elsewhere. |
Mono<T> |
timeout(Duration timeout)
Signal a
TimeoutException in case an item doesn't arrive before the given period. |
Mono<T> |
timeout(Duration timeout,
Mono<? extends T> fallback)
Switch to a fallback
Mono in case an item doesn't arrive before the given period. |
Mono<T> |
timeout(Duration timeout,
Mono<? extends T> fallback,
Scheduler timer)
Switch to a fallback
Mono in case an item doesn't arrive before the given period. |
Mono<T> |
timeout(Duration timeout,
Scheduler timer)
Signal a
TimeoutException error in case an item doesn't arrive before the given period. |
<U> Mono<T> |
timeout(Publisher<U> firstTimeout)
Signal a
TimeoutException in case the item from this Mono has
not been emitted before the given Publisher emits. |
<U> Mono<T> |
timeout(Publisher<U> firstTimeout,
Mono<? extends T> fallback)
|
Mono<T> |
timeoutMillis(long timeout)
Deprecated.
use the
Duration based variants instead, will be removed in 3.1.0 |
Mono<T> |
timeoutMillis(long timeout,
Mono<? extends T> fallback)
Deprecated.
use the
Duration based variants instead, will be removed in 3.1.0 |
Mono<T> |
timeoutMillis(long timeout,
Mono<? extends T> fallback,
TimedScheduler timer)
Deprecated.
use the
Duration based variants instead, will be removed in 3.1.0 |
Mono<T> |
timeoutMillis(long timeout,
TimedScheduler timer)
Deprecated.
use the
Duration based variants instead, will be removed in 3.1.0 |
Mono<Tuple2<Long,T>> |
timestamp()
|
Mono<Tuple2<Long,T>> |
timestamp(Scheduler scheduler)
|
Mono<Tuple2<Long,T>> |
timestamp(TimedScheduler scheduler)
Deprecated.
|
CompletableFuture<T> |
toFuture()
Transform this
Mono into a CompletableFuture completing on onNext or onComplete and failing on
onError. |
String |
toString() |
<V> Mono<V> |
transform(Function<? super Mono<T>,? extends Publisher<V>> transformer)
|
Mono<T> |
untilOther(Publisher<?> anyPublisher)
Subscribe to this Mono and another Publisher, which will be used as a trigger for
the emission of this Mono's element.
|
Mono<T> |
untilOtherDelayError(Publisher<?> anyPublisher)
Subscribe to this Mono and another Publisher, which will be used as a trigger for
the emission of this Mono's element, mapped through a provided function.
|
static <T,D> Mono<T> |
using(Callable<? extends D> resourceSupplier,
Function<? super D,? extends Mono<? extends T>> sourceSupplier,
Consumer<? super D> resourceCleanup)
Uses a resource, generated by a supplier for each individual Subscriber, while streaming the value from a
Mono derived from the same resource and makes sure the resource is released if the
sequence terminates or
the Subscriber cancels.
|
static <T,D> Mono<T> |
using(Callable<? extends D> resourceSupplier,
Function<? super D,? extends Mono<? extends T>> sourceSupplier,
Consumer<? super D> resourceCleanup,
boolean eager)
Uses a resource, generated by a supplier for each individual Subscriber, while streaming the value from a
Mono derived from the same resource and makes sure the resource is released if the
sequence terminates or
the Subscriber cancels.
|
static <R> Mono<R> |
when(Function<? super Object[],? extends R> combinator,
Mono<?>... monos)
Aggregate given monos into a new a Mono that will be fulfilled when all of the given Monos have been fulfilled.
|
static <R> Mono<R> |
when(Iterable<? extends Mono<?>> monos,
Function<? super Object[],? extends R> combinator)
Aggregate given monos into a new a Mono that will be fulfilled when all of the given Monos have been fulfilled.
|
static Mono<Void> |
when(Iterable<? extends Publisher<Void>> sources)
Aggregate given void publishers into a new a Mono that will be
fulfilled when all of the given Monos have been fulfilled.
|
static <T1,T2> Mono<Tuple2<T1,T2>> |
when(Mono<? extends T1> p1,
Mono<? extends T2> p2)
Merge given monos into a new a Mono that will be fulfilled when all of the given Monos
have been fulfilled.
|
static <T1,T2,O> Mono<O> |
when(Mono<? extends T1> p1,
Mono<? extends T2> p2,
BiFunction<? super T1,? super T2,? extends O> combinator)
Merge given monos into a new a Mono that will be fulfilled when all of the given Monos
have been fulfilled.
|
static <T1,T2,T3> Mono<Tuple3<T1,T2,T3>> |
when(Mono<? extends T1> p1,
Mono<? extends T2> p2,
Mono<? extends T3> p3)
Merge given monos into a new a Mono that will be fulfilled when all of the given Monos
have been fulfilled.
|
static <T1,T2,T3,T4> |
when(Mono<? extends T1> p1,
Mono<? extends T2> p2,
Mono<? extends T3> p3,
Mono<? extends T4> p4)
Merge given monos into a new a Mono that will be fulfilled when all of the given Monos
have been fulfilled.
|
static <T1,T2,T3,T4,T5> |
when(Mono<? extends T1> p1,
Mono<? extends T2> p2,
Mono<? extends T3> p3,
Mono<? extends T4> p4,
Mono<? extends T5> p5)
Merge given monos into a new a Mono that will be fulfilled when all of the given Monos
have been fulfilled.
|
static <T1,T2,T3,T4,T5,T6> |
when(Mono<? extends T1> p1,
Mono<? extends T2> p2,
Mono<? extends T3> p3,
Mono<? extends T4> p4,
Mono<? extends T5> p5,
Mono<? extends T6> p6)
Merge given monos into a new a Mono that will be fulfilled when all of the given Monos
have been fulfilled.
|
static Mono<Void> |
when(Publisher<Void>... sources)
Aggregate given void publisher into a new a Mono that will be fulfilled
when all of the given sources have been fulfilled.
|
static <R> Mono<R> |
whenDelayError(Function<? super Object[],? extends R> combinator,
Mono<?>... monos)
Merge given monos into a new a Mono that will be fulfilled when all of the given Monos
have been fulfilled.
|
static <R> Mono<R> |
whenDelayError(Iterable<? extends Mono<?>> monos,
Function<? super Object[],? extends R> combinator)
Aggregate given monos into a new a Mono that will be fulfilled when all of the given Monos have been fulfilled.
|
static Mono<Void> |
whenDelayError(Iterable<? extends Publisher<Void>> sources)
Aggregate given void publishers into a new a Mono that will be
fulfilled when all of the given sources have been fulfilled.
|
static <T1,T2> Mono<Tuple2<T1,T2>> |
whenDelayError(Mono<? extends T1> p1,
Mono<? extends T2> p2)
Merge given monos into a new a Mono that will be fulfilled when all of the given Monos
have been fulfilled.
|
static <T1,T2,T3> Mono<Tuple3<T1,T2,T3>> |
whenDelayError(Mono<? extends T1> p1,
Mono<? extends T2> p2,
Mono<? extends T3> p3)
Merge given monos into a new a Mono that will be fulfilled when all of the given Mono Monos
have been fulfilled.
|
static <T1,T2,T3,T4> |
whenDelayError(Mono<? extends T1> p1,
Mono<? extends T2> p2,
Mono<? extends T3> p3,
Mono<? extends T4> p4)
Merge given monos into a new a Mono that will be fulfilled when all of the given Monos
have been fulfilled.
|
static <T1,T2,T3,T4,T5> |
whenDelayError(Mono<? extends T1> p1,
Mono<? extends T2> p2,
Mono<? extends T3> p3,
Mono<? extends T4> p4,
Mono<? extends T5> p5)
Merge given monos into a new a Mono that will be fulfilled when all of the given Monos
have been fulfilled.
|
static <T1,T2,T3,T4,T5,T6> |
whenDelayError(Mono<? extends T1> p1,
Mono<? extends T2> p2,
Mono<? extends T3> p3,
Mono<? extends T4> p4,
Mono<? extends T5> p5,
Mono<? extends T6> p6)
Merge given monos into a new a Mono that will be fulfilled when all of the given Monos
have been fulfilled.
|
static Mono<Void> |
whenDelayError(Publisher<Void>... sources)
Merge given void publishers into a new a Mono that will be fulfilled when
all of the given sources have been fulfilled.
|
static <T,V> Mono<V> |
zip(Function<? super Object[],? extends V> combinator,
Iterable<? extends Mono<? extends T>> monos)
Aggregate given monos into a new a Mono that will be fulfilled when all of the given Monos have been fulfilled.
|
static <T,V> Mono<V> |
zip(Function<? super Object[],? extends V> combinator,
Mono<? extends T>... monos)
Aggregate given monos into a new a Mono that will be fulfilled when all of the given Monos have been fulfilled.
|
public static <T> Mono<T> create(Consumer<MonoSink<T>> callback)
Bridging legacy API involves mostly boilerplate code due to the lack of standard types and methods. There are two kinds of API surfaces: 1) addListener/removeListener and 2) callback-handler.
1) addListener/removeListener pairs
To work with such API one has to instantiate the listener,
wire up the SingleEmitter inside it then add the listener
to the source:
Mono.<String>create(sink -> {
HttpListener listener = event -> {
if (event.getResponseCode() >= 400) {
sink.error(new RuntimeExeption("Failed"));
} else {
String body = event.getBody();
if (body.isEmpty()) {
sink.success();
} else {
sink.success(body.toLowerCase());
}
}
};
client.addListener(listener);
sink.onDispose(() -> client.removeListener(listener));
});
Note that this works only with single-value emitting listeners. Otherwise,
all subsequent signals are dropped. You may have to add client.removeListener(this);
to the listener's body.
2) callback handler
This requires a similar instantiation pattern such as above, but usually the
successful completion and error are separated into different methods.
In addition, the legacy API may or may not support some cancellation mechanism.
Mono.<String>create(sink -> {
Callback<String> callback = new Callback<String>() {
@Override
public void onResult(String data) {
sink.success(data.toLowerCase());
}
@Override
public void onError(Exception e) {
sink.error(e);
}
}
// without cancellation support:
client.call("query", callback);
// with cancellation support:
AutoCloseable cancel = client.call("query", callback);
sink.onDispose(() -> {
try {
cancel.close();
} catch (Exception ex) {
Exceptions.onErrorDropped(ex);
}
});
});
public static <T> Mono<T> defer(Supplier<? extends Mono<? extends T>> supplier)
Mono
provider that will supply
a target Mono
to subscribe to for
each Subscriber
downstream.
public static Mono<Long> delay(Duration duration)
duration
of given unit and complete on the global timer.
If the demand cannot be produced in time, an onError will be signalled instead.
The delay is introduced through the parallel
default Scheduler.
duration
- the duration of the delayMono
public static Mono<Long> delay(Duration duration, Scheduler timer)
duration
and completes.
If the demand cannot be produced in time, an onError will be signalled instead.
@Deprecated public static Mono<Long> delayMillis(long duration)
Duration
based variants instead, will be removed in 3.1.0duration
milliseconds and complete.
If the demand cannot be produced in time, an onError will be signalled instead.
duration
- the duration in milliseconds of the delayMono
@Deprecated public static Mono<Long> delayMillis(long duration, TimedScheduler timer)
Duration
based variants instead, will be removed in 3.1.0duration
milliseconds and complete.
If the demand cannot be produced in time, an onError will be signalled instead.
public static <T> Mono<T> empty()
Mono
that completes without emitting any item.
T
- the reified Subscriber
typeMono
public static <T> Mono<Void> empty(Publisher<T> source)
Mono
that ignores onNext (dropping them) and only react on Completion signal.
public static <T> Mono<T> error(Throwable error)
Mono
that completes with the specified error immediately after onSubscribe.
T
- the reified Subscriber
typeerror
- the onError signalMono
@SafeVarargs public static <T> Mono<T> first(Mono<? extends T>... monos)
T
- The type of the function result.monos
- The deferred monos to use.Mono
.public static <T> Mono<T> first(Iterable<? extends Mono<? extends T>> monos)
T
- The type of the function result.monos
- The monos to use.Mono
.public static <T> Mono<T> fromCompletionStage(CompletionStage<? extends T> completionStage)
T
- type of the expected valuecompletionStage
- CompletionStage
that will produce the value or null to
complete immediatelyMono
.public static <T> Mono<T> fromFuture(CompletableFuture<? extends T> future)
T
- type of the expected valuefuture
- CompletableFuture
that will produce the value or null to
complete immediatelyMono
.fromCompletionStage for a generalization
public static Mono<Void> fromRunnable(Runnable runnable)
Mono
only producing a completion signal after using the given
runnable.
public static <T> Mono<T> ignoreElements(Publisher<T> source)
Mono
that ignores onNext (dropping them) and only react on Completion signal.
public static <T> Mono<T> just(T data)
Mono
that emits the specified item.
T
- the type of the produced itemdata
- the only item to onNextMono
.public static <T> Mono<T> justOrEmpty(Optional<? extends T> data)
Mono
that emits the specified item if Optional.isPresent()
otherwise only emits
onComplete.
public static <T> Mono<T> justOrEmpty(T data)
Mono
that emits the specified item if non null otherwise only emits
onComplete.
T
- the type of the produced itemdata
- the item to onNext or onComplete if nullMono
.public static <T> Mono<T> never()
Mono
that will never signal any data, error or completion signal.
T
- the Subscriber
type targetMono
public static <T> Mono<Boolean> sequenceEqual(Publisher<? extends T> source1, Publisher<? extends T> source2)
T
- the type of items emitted by each Publishersource1
- the first Publisher to comparesource2
- the second Publisher to comparepublic static <T> Mono<Boolean> sequenceEqual(Publisher<? extends T> source1, Publisher<? extends T> source2, BiPredicate<? super T,? super T> isEqual)
T
- the type of items emitted by each Publishersource1
- the first Publisher to comparesource2
- the second Publisher to compareisEqual
- a function used to compare items emitted by each Publisherpublic static <T> Mono<Boolean> sequenceEqual(Publisher<? extends T> source1, Publisher<? extends T> source2, BiPredicate<? super T,? super T> isEqual, int bufferSize)
T
- the type of items emitted by each Publishersource1
- the first Publisher to comparesource2
- the second Publisher to compareisEqual
- a function used to compare items emitted by each PublisherbufferSize
- the number of items to prefetch from the first and second source Publisherpublic static <T,D> Mono<T> using(Callable<? extends D> resourceSupplier, Function<? super D,? extends Mono<? extends T>> sourceSupplier, Consumer<? super D> resourceCleanup, boolean eager)
T
- emitted typeD
- resource typeresourceSupplier
- a Callable
that is called on subscribesourceSupplier
- a Mono
factory derived from the supplied resourceresourceCleanup
- invoked on completioneager
- true to clean before terminating downstream subscribersMono
public static <T,D> Mono<T> using(Callable<? extends D> resourceSupplier, Function<? super D,? extends Mono<? extends T>> sourceSupplier, Consumer<? super D> resourceCleanup)
Eager resource cleanup happens just before the source termination and exceptions raised by the cleanup Consumer may override the terminal even.
public Mono<T> untilOther(Publisher<?> anyPublisher)
anyPublisher
- the publisher which first emission or termination will trigger
the emission of this Mono's value.public Mono<T> untilOtherDelayError(Publisher<?> anyPublisher)
anyPublisher
- the publisher which first emission or termination will trigger
the emission of this Mono's value.public static <T1,T2> Mono<Tuple2<T1,T2>> when(Mono<? extends T1> p1, Mono<? extends T2> p2)
Mono
.
public static <T1,T2,O> Mono<O> when(Mono<? extends T1> p1, Mono<? extends T2> p2, BiFunction<? super T1,? super T2,? extends O> combinator)
Mono
.
T1
- type of the value from source1T2
- type of the value from source2O
- output valuep1
- The first upstream Publisher
to subscribe to.p2
- The second upstream Publisher
to subscribe to.combinator
- a BiFunction
combinator function when both sources
completeMono
.public static <T1,T2,T3> Mono<Tuple3<T1,T2,T3>> when(Mono<? extends T1> p1, Mono<? extends T2> p2, Mono<? extends T3> p3)
Mono
.
T1
- type of the value from source1T2
- type of the value from source2T3
- type of the value from source3p1
- The first upstream Publisher
to subscribe to.p2
- The second upstream Publisher
to subscribe to.p3
- The third upstream Publisher
to subscribe to.Mono
.public static <T1,T2,T3,T4> Mono<Tuple4<T1,T2,T3,T4>> when(Mono<? extends T1> p1, Mono<? extends T2> p2, Mono<? extends T3> p3, Mono<? extends T4> p4)
Mono
.
T1
- type of the value from source1T2
- type of the value from source2T3
- type of the value from source3T4
- type of the value from source4p1
- The first upstream Publisher
to subscribe to.p2
- The second upstream Publisher
to subscribe to.p3
- The third upstream Publisher
to subscribe to.p4
- The fourth upstream Publisher
to subscribe to.Mono
.public static <T1,T2,T3,T4,T5> Mono<Tuple5<T1,T2,T3,T4,T5>> when(Mono<? extends T1> p1, Mono<? extends T2> p2, Mono<? extends T3> p3, Mono<? extends T4> p4, Mono<? extends T5> p5)
Mono
.
T1
- type of the value from source1T2
- type of the value from source2T3
- type of the value from source3T4
- type of the value from source4T5
- type of the value from source5p1
- The first upstream Publisher
to subscribe to.p2
- The second upstream Publisher
to subscribe to.p3
- The third upstream Publisher
to subscribe to.p4
- The fourth upstream Publisher
to subscribe to.p5
- The fifth upstream Publisher
to subscribe to.Mono
.public static <T1,T2,T3,T4,T5,T6> Mono<Tuple6<T1,T2,T3,T4,T5,T6>> when(Mono<? extends T1> p1, Mono<? extends T2> p2, Mono<? extends T3> p3, Mono<? extends T4> p4, Mono<? extends T5> p5, Mono<? extends T6> p6)
Mono
.
T1
- type of the value from source1T2
- type of the value from source2T3
- type of the value from source3T4
- type of the value from source4T5
- type of the value from source5T6
- type of the value from source6p1
- The first upstream Publisher
to subscribe to.p2
- The second upstream Publisher
to subscribe to.p3
- The third upstream Publisher
to subscribe to.p4
- The fourth upstream Publisher
to subscribe to.p5
- The fifth upstream Publisher
to subscribe to.p6
- The sixth upstream Publisher
to subscribe to.Mono
.public static Mono<Void> when(Iterable<? extends Publisher<Void>> sources)
sources
- The sources to use.Mono
.public static <R> Mono<R> when(Iterable<? extends Mono<?>> monos, Function<? super Object[],? extends R> combinator)
R
- the combined resultmonos
- The monos to use.combinator
- the function to transform the combined array into an arbitrary
object.Mono
.@SafeVarargs public static Mono<Void> when(Publisher<Void>... sources)
Mono
.
sources
- The sources to use.Mono
.public static <R> Mono<R> when(Function<? super Object[],? extends R> combinator, Mono<?>... monos)
Mono
.
R
- the combined resultmonos
- The monos to use.combinator
- the function to transform the combined array into an arbitrary
object.Mono
.public static <T1,T2> Mono<Tuple2<T1,T2>> whenDelayError(Mono<? extends T1> p1, Mono<? extends T2> p2)
public static <T1,T2,T3> Mono<Tuple3<T1,T2,T3>> whenDelayError(Mono<? extends T1> p1, Mono<? extends T2> p2, Mono<? extends T3> p3)
T1
- type of the value from source1T2
- type of the value from source2T3
- type of the value from source3p1
- The first upstream Publisher
to subscribe to.p2
- The second upstream Publisher
to subscribe to.p3
- The third upstream Publisher
to subscribe to.Mono
.public static <T1,T2,T3,T4> Mono<Tuple4<T1,T2,T3,T4>> whenDelayError(Mono<? extends T1> p1, Mono<? extends T2> p2, Mono<? extends T3> p3, Mono<? extends T4> p4)
T1
- type of the value from source1T2
- type of the value from source2T3
- type of the value from source3T4
- type of the value from source4p1
- The first upstream Publisher
to subscribe to.p2
- The second upstream Publisher
to subscribe to.p3
- The third upstream Publisher
to subscribe to.p4
- The fourth upstream Publisher
to subscribe to.Mono
.public static <T1,T2,T3,T4,T5> Mono<Tuple5<T1,T2,T3,T4,T5>> whenDelayError(Mono<? extends T1> p1, Mono<? extends T2> p2, Mono<? extends T3> p3, Mono<? extends T4> p4, Mono<? extends T5> p5)
T1
- type of the value from source1T2
- type of the value from source2T3
- type of the value from source3T4
- type of the value from source4T5
- type of the value from source5p1
- The first upstream Publisher
to subscribe to.p2
- The second upstream Publisher
to subscribe to.p3
- The third upstream Publisher
to subscribe to.p4
- The fourth upstream Publisher
to subscribe to.p5
- The fifth upstream Publisher
to subscribe to.Mono
.public static <T1,T2,T3,T4,T5,T6> Mono<Tuple6<T1,T2,T3,T4,T5,T6>> whenDelayError(Mono<? extends T1> p1, Mono<? extends T2> p2, Mono<? extends T3> p3, Mono<? extends T4> p4, Mono<? extends T5> p5, Mono<? extends T6> p6)
T1
- type of the value from source1T2
- type of the value from source2T3
- type of the value from source3T4
- type of the value from source4T5
- type of the value from source5T6
- type of the value from source6p1
- The first upstream Publisher
to subscribe to.p2
- The second upstream Publisher
to subscribe to.p3
- The third upstream Publisher
to subscribe to.p4
- The fourth upstream Publisher
to subscribe to.p5
- The fifth upstream Publisher
to subscribe to.p6
- The sixth upstream Publisher
to subscribe to.Mono
.public static Mono<Void> whenDelayError(Iterable<? extends Publisher<Void>> sources)
sources
- The sources to use.Mono
.public static <R> Mono<R> whenDelayError(Iterable<? extends Mono<?>> monos, Function<? super Object[],? extends R> combinator)
R
- the combined resultmonos
- The monos to use.combinator
- the function to transform the combined array into an arbitrary
object.Mono
.@SafeVarargs public static Mono<Void> whenDelayError(Publisher<Void>... sources)
sources
- The sources to use.Mono
.public static <R> Mono<R> whenDelayError(Function<? super Object[],? extends R> combinator, Mono<?>... monos)
R
- the combined resultmonos
- The monos to use.combinator
- the function to transform the combined array into an arbitrary
object.Mono
.@SafeVarargs public static <T,V> Mono<V> zip(Function<? super Object[],? extends V> combinator, Mono<? extends T>... monos)
public static <T,V> Mono<V> zip(Function<? super Object[],? extends V> combinator, Iterable<? extends Mono<? extends T>> monos)
public final <P> P as(Function<? super Mono<T>,P> transformer)
Mono
into a target type.
mono.as(Flux::from).subscribe()
P
- the returned instance typetransformer
- the Function
applying this Mono
Mono
to instance Pfor a bounded conversion to {@link Publisher}
public final <T2> Mono<Tuple2<T,T2>> and(Mono<? extends T2> other)
Tuple2
.
T2
- the element type of the other Mono instanceother
- the Mono
to combine withwhen(reactor.core.publisher.Mono<? extends T1>, reactor.core.publisher.Mono<? extends T2>)
public final <T2,O> Mono<O> and(Mono<? extends T2> other, BiFunction<? super T,? super T2,? extends O> combinator)
O
object,
as defined by the provided combinator
function.
T2
- the element type of the other Mono instanceO
- the element type of the combinationother
- the Mono
to combine withcombinator
- a BiFunction
combinator function when both sources
completewhen(reactor.core.publisher.Mono<? extends T1>, reactor.core.publisher.Mono<? extends T2>)
public final <T2> Mono<Tuple2<T,T2>> and(Function<T,Mono<? extends T2>> rightGenerator)
rightGenerator
function and combine both results into a Tuple2
.
T2
- the element type of the other Mono instancerightGenerator
- the Function
to generate a Mono
to combine withpublic final <T2,O> Mono<O> and(Function<T,Mono<? extends T2>> rightGenerator, BiFunction<T,T2,O> combinator)
rightGenerator
function and combine both results into an arbitrary
O
object, as defined by the provided combinator
function.
T2
- the element type of the other Mono instanceO
- the element type of the combinationrightGenerator
- the Function
to generate a Mono
to combine withcombinator
- a BiFunction
combinator function when both sources completepublic final Mono<T> awaitOnSubscribe()
This helps with child Subscribers that don't expect a recursive call from onSubscribe into their onNext because, for example, they request immediately from their onSubscribe but don't finish their preparation before that and onNext runs into a half-prepared state. This can happen with non Reactor based Subscribers.
Mono
public T block()
public T block(Duration timeout)
RuntimeException
will be thrown.
Note that each block() will subscribe a new single (MonoSink) subscriber, in other words, the result might
miss signal from hot publishers.
timeout
- maximum time period to wait for before raising a RuntimeException
@Deprecated public final T blockMillis(long timeout)
Duration
based variants instead, will be removed in 3.1.0RuntimeException
will be thrown.
Note that each block() will subscribe a new single (MonoSink) subscriber, in other words, the result might
miss signal from hot publishers.
timeout
- maximum time period to wait for in milliseconds before raising a RuntimeException
public final <E> Mono<E> cast(Class<E> clazz)
Mono
produced type into a target produced type.
public final Mono<T> cache()
Mono
into a hot source and cache last emitted signals for further Subscriber
.
Completion and Error will also be replayed.
Mono
public final Mono<T> checkpoint()
Mono
, in case of an error
upstream of the checkpoint.
It should be placed towards the end of the reactive chain, as errors triggered downstream of it cannot be observed and augmented with assembly trace.
Mono
public final Mono<T> checkpoint(String description)
Mono
and give it
a description that will be reflected in the assembly traceback, in case of an error
upstream of the checkpoint.
It should be placed towards the end of the reactive chain, as errors triggered downstream of it cannot be observed and augmented with assembly trace.
The description could for example be a meaningful name for the assembled mono or a wider correlation ID.
description
- a description to include in the assembly traceback.Mono
public final <V> Mono<V> compose(Function<? super Mono<T>,? extends Publisher<V>> transformer)
Mono
in order to generate a
target Mono
type. A transformation will occur for each
Subscriber
.
flux.compose(Mono::from).subscribe()
public final Mono<T> defaultIfEmpty(T defaultV)
defaultV
- the alternate value if this sequence is emptyMono
Flux.defaultIfEmpty(Object)
public final Mono<T> delayElement(Duration delay)
Flux
element (Subscriber.onNext(T)
signal) by a given
duration. Empty monos or error signals are not delayed.
Note that the scheduler on which the mono chain continues execution will be the
parallel
scheduler if the mono is valued, or the
current scheduler if the mono completes empty or errors.
delay
- period to delay each Subscriber.onNext(T)
signalMono
public final Mono<T> delayElement(Duration delay, Scheduler timer)
Flux
element (Subscriber.onNext(T)
signal) by a given
Duration
. Empty monos or error signals are not delayed.
Note that the scheduler on which the mono chain continues execution will be the time scheduler provided if the mono is valued, or the current scheduler if the mono completes empty or errors.
delay
- Duration
to delay each Subscriber.onNext(T)
signaltimer
- a time-capable Scheduler
instance to delay the value signal onMono
@Deprecated public final Mono<T> delayElementMillis(long delay)
Duration
based variants instead, will be removed in 3.1.0Flux
element (Subscriber.onNext(T)
signal) by a given
duration, in milliseconds. Empty monos or error signals are not delayed.
Note that the scheduler on which the mono chain continues execution will be the time scheduler provided if the mono is valued, or the current scheduler if the mono completes empty or errors.
delay
- period to delay each Subscriber.onNext(T)
signal, in millisecondsMono
@Deprecated public final Mono<T> delayElementMillis(long delay, TimedScheduler timer)
Duration
based variants instead, will be removed in 3.1.0Flux
element (Subscriber.onNext(T)
signal) by a given
duration, in milliseconds. Empty monos or error signals are not delayed.
Note that the scheduler on which the mono chain continues execution will be the
parallel
if the mono is valued, or the current scheduler if the mono
completes empty or errors.
delay
- period to delay each Subscriber.onNext(T)
signal, in millisecondstimer
- a time-capable Scheduler
instance to delay the value signal onMono
public final <U> Mono<T> delaySubscription(Publisher<U> subscriptionDelay)
U
- the other source typesubscriptionDelay
- a
Publisher
to signal by next or complete this Publisher.subscribe(Subscriber)
Mono
@Deprecated public final Mono<T> delaySubscriptionMillis(long delay)
Duration
based variants instead, will be removed in 3.1.0subscription
to this Mono
source until the given
period elapses. The delay is introduced through the parallel
default Scheduler.
@Deprecated public final Mono<T> delaySubscriptionMillis(long delay, TimedScheduler timer)
Duration
based variants instead, will be removed in 3.1.0subscription
to this Mono
source until the given
period elapses. The delay is introduced through the parallel
default Scheduler.
public final <X> Mono<X> dematerialize()
Mono
is a emits onNext, onError or onComplete Signal
. The relative Subscriber
callback will be invoked, error Signal
will trigger onError and complete Signal
will trigger
onComplete.
X
- the dematerialized typeMono
public final Mono<T> doAfterTerminate(BiConsumer<? super T,Throwable> afterTerminate)
Mono
terminates, either by completing downstream successfully or with an error.
The arguments will be null depending on success, success with data and error:
afterTerminate
- the callback to call after Subscriber.onNext(T)
, Subscriber.onComplete()
without preceding Subscriber.onNext(T)
or Subscriber.onError(java.lang.Throwable)
Mono
public final Mono<T> doFinally(Consumer<SignalType> onFinally)
Mono
terminates for any reason,
including cancellation. The terminating event (SignalType.ON_COMPLETE
,
SignalType.ON_ERROR
and SignalType.CANCEL
) is passed to the consumer,
which is executed after the signal has been passed downstream.
Note that the fact that the signal is propagated downstream before the callback is
executed means that several doFinally in a row will be executed in
reverse order. If you want to assert the execution of the callback
please keep in mind that the Mono will complete before it is executed, so its
effect might not be visible immediately after eg. a block()
.
onFinally
- the callback to execute after a terminal signal (complete, error
or cancel)Mono
public final Mono<T> doOnCancel(Runnable onCancel)
Mono
is cancelled.
onCancel
- the callback to call on Subscription.cancel()
Mono
public final Mono<T> doOnNext(Consumer<? super T> onNext)
Mono
emits a data successfully.
onNext
- the callback to call on Subscriber.onNext(T)
Mono
public final Mono<T> doOnSuccess(Consumer<? super T> onSuccess)
Mono
completes successfully.
onSuccess
- the callback to call on, argument is null if the Mono
completes without data
Subscriber.onNext(T)
or Subscriber.onComplete()
without preceding Subscriber.onNext(T)
Mono
public final Mono<T> doOnEach(Consumer<? super Signal<T>> signalConsumer)
Mono
emits an item, fails with an error
or completes successfully. All these events are represented as a Signal
that is passed to the side-effect callback. Note that this is an advanced operator,
typically used for monitoring of a Mono.signalConsumer
- the mandatory callback to call on
Subscriber.onNext(Object)
, Subscriber.onError(Throwable)
and
Subscriber.onComplete()
Mono
doOnNext(Consumer)
,
doOnError(Consumer)
,
materialize()
,
Signal
public final Mono<T> doOnError(Consumer<? super Throwable> onError)
Mono
completes with an error.
onError
- the error callback to call on Subscriber.onError(Throwable)
Mono
public final <E extends Throwable> Mono<T> doOnError(Class<E> exceptionType, Consumer<? super E> onError)
Mono
completes with an error matching the given exception type.
E
- type of the error to handleexceptionType
- the type of exceptions to handleonError
- the error handler for each errorMono
public final Mono<T> doOnError(Predicate<? super Throwable> predicate, Consumer<? super Throwable> onError)
Mono
completes with an error matching the given exception.
predicate
- the matcher for exceptions to handleonError
- the error handler for each errorMono
public final Mono<T> doOnRequest(LongConsumer consumer)
consumer
- the consumer to invoke on each requestMono
public final Mono<T> doOnSubscribe(Consumer<? super Subscription> onSubscribe)
Mono
is subscribed.
onSubscribe
- the callback to call on Subscriber.onSubscribe(Subscription)
Mono
public final Mono<T> doOnTerminate(BiConsumer<? super T,Throwable> onTerminate)
Mono
terminates, either by completing successfully or with an error.
onTerminate
- the callback to call Subscriber.onNext(T)
, Subscriber.onComplete()
without preceding Subscriber.onNext(T)
or Subscriber.onError(java.lang.Throwable)
Mono
public final Mono<Tuple2<Long,T>> elapsed()
Mono
sequence into Tuple2
of T1 Long
timemillis and T2
T
associated data. The timemillis corresponds to the elapsed time between the subscribe and the first
next signal.
Mono
that emits a tuple of time elapsed in milliseconds and matching data@Deprecated public final Mono<Tuple2<Long,T>> elapsed(TimedScheduler scheduler)
elapsed(Scheduler)
public final Mono<T> filter(Predicate<? super T> tester)
Mono
and replay it if predicate returns true.
Otherwise complete without value.
tester
- the predicate to evaluateMono
public final Mono<T> filterWhen(Function<? super T,? extends Publisher<Boolean>> asyncPredicate)
Mono
is valued, test the value asynchronously using a generated
Publisher<Boolean>
test. The value from the Mono is replayed if the
first item emitted by the test is true. It is dropped if the test is
either empty or its first emitted value is false.
Note that only the first value of the test publisher is considered, and unless it
is a Mono
, test will be cancelled after receiving that first value.
@Deprecated public final <R> Flux<R> flatMap(Function<? super T,? extends Publisher<? extends R>> mapper)
then(Function)
.
flatMap will be renamed flatMapMany(Function)
, so use that instead.Mono
into a Publisher, then forward
its emissions into the returned Flux
.
R
- the merged sequence typemapper
- the
Function
to produce a sequence of R from the the eventual passed Subscriber.onNext(T)
Flux
as the sequence is not guaranteed to be single at most@Deprecated public final <R> Flux<R> flatMap(Function<? super T,? extends Publisher<? extends R>> mapperOnNext, Function<Throwable,? extends Publisher<? extends R>> mapperOnError, Supplier<? extends Publisher<? extends R>> mapperOnComplete)
then(Function)
.
flatMap will be renamed flatMapMany(Function, Function, Supplier)
, so use that instead.Mono
into a Publisher, then forward
its emissions into the returned Flux
.
R
- the type of the produced inner sequencemapperOnNext
- the Function
to call on next data and returning a sequence to mergemapperOnError
- the Function
to call on error signal and returning a sequence to mergemapperOnComplete
- the Function
to call on complete signal and returning a sequence to mergeFlux
as the sequence is not guaranteed to be single at mostFlux.flatMap(Function, Function, Supplier)
public final <R> Flux<R> flatMapMany(Function<? super T,? extends Publisher<? extends R>> mapper)
Mono
into a Publisher, then forward
its emissions into the returned Flux
.
R
- the merged sequence typemapper
- the
Function
to produce a sequence of R from the the eventual passed Subscriber.onNext(T)
Flux
as the sequence is not guaranteed to be single at mostpublic final <R> Flux<R> flatMapMany(Function<? super T,? extends Publisher<? extends R>> mapperOnNext, Function<? super Throwable,? extends Publisher<? extends R>> mapperOnError, Supplier<? extends Publisher<? extends R>> mapperOnComplete)
Mono
into a Publisher, then forward
its emissions into the returned Flux
.
R
- the type of the produced inner sequencemapperOnNext
- the Function
to call on next data and returning a sequence to mergemapperOnError
- the Function
to call on error signal and returning a sequence to mergemapperOnComplete
- the Function
to call on complete signal and returning a sequence to mergeFlux
as the sequence is not guaranteed to be single at mostFlux.flatMap(Function, Function, Supplier)
public final <R> Flux<R> flatMapIterable(Function<? super T,? extends Iterable<? extends R>> mapper)
public final Mono<Boolean> hasElement()
Mono
has an element.
Mono
with true
if a value is emitted and false
otherwisepublic final <R> Mono<R> handle(BiConsumer<? super T,SynchronousSink<R>> handler)
Mono
by calling a biconsumer with the
output sink for each onNext. At most one SynchronousSink.next(Object)
call must be performed and/or 0 or 1 SynchronousSink.error(Throwable)
or
SynchronousSink.complete()
.R
- the transformed typehandler
- the handling BiConsumer
Mono
public final Mono<T> hide()
Mono
instance.
The main purpose of this operator is to prevent certain identity-based optimizations from happening, mostly for diagnostic purposes.
Mono
instancepublic final Mono<T> ignoreElement()
Mono
.public final Mono<T> log()
Logger
support to handle trace implementation. Default will
use Level.INFO
and java.util.logging. If SLF4J is available, it will be used instead.
The default log category will be "Mono". A generated operator suffix will complete, e.g. "reactor.Flux.Map".
Mono
Flux.log()
public final Mono<T> log(String category)
Logger
support to handle trace implementation. Default will
use Level.INFO
and java.util.logging. If SLF4J is available, it will be used instead.
category
- to be mapped into logger configuration (e.g. org.springframework
.reactor). If category ends with "." like "reactor.", a generated operator
suffix will complete, e.g. "reactor.Flux.Map".Mono
public final Mono<T> log(String category, Level level, SignalType... options)
options
and use
Logger
support to handle trace implementation. Default will use the passed
Level
and java.util.logging. If SLF4J is available, it will be used instead.
Options allow fine grained filtering of the traced signal, for instance to only capture onNext and onError:
mono.log("category", SignalType.ON_NEXT, SignalType.ON_ERROR)
category
- to be mapped into logger configuration (e.g. org.springframework
.reactor). If category ends with "." like "reactor.", a generated operator
suffix will complete, e.g. "reactor.Flux.Map".level
- the Level
to enforce for this tracing Mono (only FINEST, FINE,
INFO, WARNING and SEVERE are taken into account)options
- a vararg SignalType
option to filter log messagesMono
public final Mono<T> log(String category, Level level, boolean showOperatorLine, SignalType... options)
options
and
use Logger
support to
handle trace
implementation. Default will
use the passed Level
and java.util.logging. If SLF4J is available, it will be used instead.
Options allow fine grained filtering of the traced signal, for instance to only capture onNext and onError:
mono.log("category", Level.INFO, SignalType.ON_NEXT, SignalType.ON_ERROR)
category
- to be mapped into logger configuration (e.g. org.springframework
.reactor). If category ends with "." like "reactor.", a generated operator
suffix will complete, e.g. "reactor.Mono.Map".level
- the Level
to enforce for this tracing Mono (only FINEST, FINE,
INFO, WARNING and SEVERE are taken into account)showOperatorLine
- capture the current stack to display operator
class/line number.options
- a vararg SignalType
option to filter log messagesMono
public final <R> Mono<R> map(Function<? super T,? extends R> mapper)
Mono
by applying a function to item emitted.
R
- the transformed typemapper
- the transforming functionMono
@Deprecated public final Mono<T> mapError(Function<Throwable,? extends Throwable> mapper)
onErrorMap(java.util.function.Function<? super java.lang.Throwable, ? extends java.lang.Throwable>)
instead. Will be removed in 3.1.0.Mono
by applying a function.
@Deprecated public final <E extends Throwable> Mono<T> mapError(Class<E> type, Function<? super E,? extends Throwable> mapper)
onErrorMap(java.util.function.Function<? super java.lang.Throwable, ? extends java.lang.Throwable>)
instead. Will be removed in 3.1.0.Mono
by applying a function if the
error matches the given type, otherwise let the error flow.
@Deprecated public final Mono<T> mapError(Predicate<? super Throwable> predicate, Function<? super Throwable,? extends Throwable> mapper)
onErrorMap(java.util.function.Function<? super java.lang.Throwable, ? extends java.lang.Throwable>)
instead. Will be removed in 3.1.0.Mono
by applying a function if the
error matches the given predicate, otherwise let the error flow.
public final Mono<Signal<T>> materialize()
Signal
.
Since the error is materialized as a Signal
, the propagation will be stopped and onComplete will be
emitted. Complete signal will first emit a Signal.complete()
and then effectively complete the flux.
public final Mono<T> onErrorMap(Function<? super Throwable,? extends Throwable> mapper)
Mono
by applying a function.
public final <E extends Throwable> Mono<T> onErrorMap(Class<E> type, Function<? super E,? extends Throwable> mapper)
Mono
by applying a function if the
error matches the given type, otherwise let the error flow.
public final Mono<T> onErrorMap(Predicate<? super Throwable> predicate, Function<? super Throwable,? extends Throwable> mapper)
Mono
by applying a function if the
error matches the given predicate, otherwise let the error flow.
public final Mono<T> or(Mono<? extends T> other)
other
- the racing other Mono
to compete with for the resultMono
first(reactor.core.publisher.Mono<? extends T>...)
@Deprecated public final Mono<T> otherwise(Function<? super Throwable,? extends Mono<? extends T>> fallback)
onErrorResume(Function)
} instead. Will be removed in 3.1.0.
@Deprecated public final <E extends Throwable> Mono<T> otherwise(Class<E> type, Function<? super E,? extends Mono<? extends T>> fallback)
onErrorResume(Class, Function)
instead. Will be removed in 3.1.0.
@Deprecated public final Mono<T> otherwise(Predicate<? super Throwable> predicate, Function<? super Throwable,? extends Mono<? extends T>> fallback)
onErrorResume(Predicate, Function)
instead. Will be removed in 3.1.0.
@Deprecated public final Mono<T> otherwiseIfEmpty(Mono<? extends T> alternate)
switchIfEmpty(reactor.core.publisher.Mono<? extends T>)
instead. Will be removed in 3.1.0.Mono
if this mono is completed without data
alternate
- the alternate mono if this mono is emptyMono
on source onComplete without elements@Deprecated public final Mono<T> otherwiseReturn(T fallback)
onErrorReturn(Object)
instead. Will be removed in 3.1.0.
fallback
- the value to emit if an error occursMono
@Deprecated public final <E extends Throwable> Mono<T> otherwiseReturn(Class<E> type, T fallbackValue)
onErrorReturn(Class, Object)
instead. Will be removed in 3.1.0.Mono
E
- the error typetype
- the error type to matchfallbackValue
- alternate value on fallbackMono
@Deprecated public final <E extends Throwable> Mono<T> otherwiseReturn(Predicate<? super Throwable> predicate, T fallbackValue)
onErrorReturn(Predicate, Object)
instead. Will be removed in 3.1.0.Mono
E
- the error typepredicate
- the error predicate to matchfallbackValue
- alternate value on fallbackMono
public final Mono<T> onTerminateDetach()
Subscriber
and the Subscription
on
termination or cancellation.
This should help with odd retention scenarios when running
with non-reactor Subscriber
.
Mono
public final <R> Mono<R> publish(Function<? super Mono<T>,? extends Mono<? extends R>> transform)
Mono
for the duration of a function that may transform it and
consume it as many times as necessary without causing multiple subscriptions
to the upstream.R
- the output value typetransform
- the tranformation functionMono
public final Mono<T> publishOn(Scheduler scheduler)
Scheduler
Typically used for fast publisher, slow consumer(s) scenarios.
mono.publishOn(Schedulers.single()).subscribe()
scheduler
- a checked Scheduler.Worker
factoryMono
public final Flux<T> repeat()
Flux
on onCompletepublic final Flux<T> repeat(BooleanSupplier predicate)
predicate
- the boolean to evaluate on onComplete.Flux
on onCompletepublic final Flux<T> repeat(long numRepeat)
numRepeat
- the number of times to re-subscribe on onCompleteFlux
on onComplete up to number of repeat specifiedpublic final Flux<T> repeat(long numRepeat, BooleanSupplier predicate)
numRepeat
- the number of times to re-subscribe on completepredicate
- the boolean to evaluate on onCompleteFlux
on onComplete up to number of repeat specified OR matching
predicatepublic final Flux<T> repeatWhen(Function<Flux<Long>,? extends Publisher<?>> whenFactory)
Mono
when a companion sequence signals a number of emitted elements in
response to the flux completion signal.
If the companion sequence signals when this Mono
is active, the repeat
attempt is suppressed and any terminal signal will terminate this Flux
with
the same signal immediately.
public final Mono<T> repeatWhenEmpty(Function<Flux<Long>,? extends Publisher<?>> repeatFactory)
Mono
until there is an onNext signal when a companion sequence signals a
number of emitted elements.
If the companion sequence signals when this Mono
is active, the repeat
attempt is suppressed and any terminal signal will terminate this Mono
with the same signal immediately.
public final Mono<T> repeatWhenEmpty(int maxRepeat, Function<Flux<Long>,? extends Publisher<?>> repeatFactory)
Mono
until there is an onNext signal when a companion sequence signals a
number of emitted elements.
If the companion sequence signals when this Mono
is active, the repeat
attempt is suppressed and any terminal signal will terminate this Mono
with the same signal immediately.
Emits an IllegalStateException
if the max repeat is exceeded and different from Integer.MAX_VALUE
.
maxRepeat
- the maximum repeat number of time (infinite if Integer.MAX_VALUE
)repeatFactory
- the
Function
providing a Flux
signalling the current repeat index from 0 on onComplete and returning a Publisher
companion.Mono
on onComplete when the companion Publisher
produces an
onNext signalpublic final Mono<T> retry()
Mono
sequence if it signals any error
either indefinitely.
The times == Long.MAX_VALUE is treated as infinite retry.
Mono
on onErrorpublic final Mono<T> retry(long numRetries)
Mono
sequence if it signals any error
either indefinitely or a fixed number of times.
The times == Long.MAX_VALUE is treated as infinite retry.
numRetries
- the number of times to tolerate an errorMono
on onError up to the specified number of retries.public final Mono<T> retry(Predicate<Throwable> retryMatcher)
Mono
sequence if it signals any error
and the given Predicate
matches otherwise push the error downstream.
retryMatcher
- the predicate to evaluate if retry should occur based on a given error signalMono
on onError if the predicates matches.public final Mono<T> retry(long numRetries, Predicate<Throwable> retryMatcher)
Mono
sequence up to the specified number of retries if it signals any
error and the given Predicate
matches otherwise push the error downstream.
numRetries
- the number of times to tolerate an errorretryMatcher
- the predicate to evaluate if retry should occur based on a given error signalMono
on onError up to the specified number of retries and if the predicate
matches.public final Mono<T> retryWhen(Function<Flux<Throwable>,? extends Publisher<?>> whenFactory)
public final MonoProcessor<T> subscribe()
Runnable
task to execute to dispose and cancel the underlying Subscription
public final Disposable subscribe(Consumer<? super T> consumer)
Consumer
to this Mono
that will consume all the
sequence.
For a passive version that observe and forward incoming data see doOnSuccess(Consumer)
and
doOnError(java.util.function.Consumer)
.
consumer
- the consumer to invoke on each valueRunnable
to dispose the Subscription
public final Disposable subscribe(Consumer<? super T> consumer, Consumer<? super Throwable> errorConsumer)
Consumer
to this Mono
that will consume all the
sequence.
For a passive version that observe and forward incoming data see doOnSuccess(Consumer)
and
doOnError(java.util.function.Consumer)
.
consumer
- the consumer to invoke on each next signalerrorConsumer
- the consumer to invoke on error signalRunnable
to dispose the Subscription
public final Disposable subscribe(Consumer<? super T> consumer, Consumer<? super Throwable> errorConsumer, Runnable completeConsumer)
Consumer
to this Mono
that will consume all the
sequence.
For a passive version that observe and forward incoming data see doOnSuccess(Consumer)
and
doOnError(java.util.function.Consumer)
.
consumer
- the consumer to invoke on each valueerrorConsumer
- the consumer to invoke on error signalcompleteConsumer
- the consumer to invoke on complete signalDisposable
to dispose the Subscription
public final Disposable subscribe(Consumer<? super T> consumer, Consumer<? super Throwable> errorConsumer, Runnable completeConsumer, Consumer<? super Subscription> subscriptionConsumer)
Consumer
to this Mono
that will consume all the
sequence.
For a passive version that observe and forward incoming data see doOnSuccess(Consumer)
and
doOnError(java.util.function.Consumer)
.
consumer
- the consumer to invoke on each valueerrorConsumer
- the consumer to invoke on error signalcompleteConsumer
- the consumer to invoke on complete signalsubscriptionConsumer
- the consumer to invoke on subscribe signal, to be used
for the initial request
, or null for max requestDisposable
to dispose the Subscription
public final Mono<T> subscribeOn(Scheduler scheduler)
Mono
on a given worker assigned by the supplied Scheduler
.
mono.subscribeOn(Schedulers.parallel()).subscribe())
scheduler
- a checked Scheduler.Worker
factoryMono
public final <E extends Subscriber<? super T>> E subscribeWith(E subscriber)
Mono
with the givne Subscriber
and return it.E
- the reified type of the Subscriber
for chainingsubscriber
- the Subscriber
to subscribeSubscriber
after subscribing it to this Mono
public final Mono<T> onErrorResume(Function<? super Throwable,? extends Mono<? extends T>> fallback)
fallback
- the function to map an alternative Mono
Mono
on source onErrorFlux.onErrorResume(java.util.function.Function<? super java.lang.Throwable, ? extends org.reactivestreams.Publisher<? extends T>>)
public final <E extends Throwable> Mono<T> onErrorResume(Class<E> type, Function<? super E,? extends Mono<? extends T>> fallback)
E
- the error typetype
- the error type to matchfallback
- the Function
mapping the error to a new Mono
sequenceMono
Flux.onErrorResume(java.util.function.Function<? super java.lang.Throwable, ? extends org.reactivestreams.Publisher<? extends T>>)
public final Mono<T> onErrorResume(Predicate<? super Throwable> predicate, Function<? super Throwable,? extends Mono<? extends T>> fallback)
predicate
- the error predicate to matchfallback
- the Function
mapping the error to a new Mono
sequenceMono
Flux.onErrorResume(java.util.function.Function<? super java.lang.Throwable, ? extends org.reactivestreams.Publisher<? extends T>>)
public final Mono<T> onErrorReturn(T fallback)
Mono
.
fallback
- the value to emit if an error occursMono
public final <E extends Throwable> Mono<T> onErrorReturn(Class<E> type, T fallbackValue)
Mono
.
E
- the error typetype
- the error type to matchfallbackValue
- the value to emit if a matching error occursMono
public final <E extends Throwable> Mono<T> onErrorReturn(Predicate<? super Throwable> predicate, T fallbackValue)
Mono
.
E
- the error typepredicate
- the error predicate to matchfallbackValue
- the value to emit if a matching error occursMono
public final Mono<T> switchIfEmpty(Mono<? extends T> alternate)
Mono
if this mono is completed without data
alternate
- the alternate mono if this mono is emptyMono
on source onComplete without elementsFlux.switchIfEmpty(org.reactivestreams.Publisher<? extends T>)
public final <R> Mono<R> then(Function<? super T,? extends Mono<? extends R>> transformer)
R
- the result type boundtransformer
- the function to dynamically bind a new Mono
Mono
containing the merged valuesflatMap(Function)
remains the current one, so it is
not yet possible to anticipate this migration.public final <V> Mono<V> then(Mono<V> other)
Mono
and transform its completion signal into the
emission and completion signal of a provided Mono<V>
. Error signal is
replayed in the resulting Mono<V>
.
@Deprecated public final <V> Mono<V> then(Supplier<? extends Mono<V>> sourceSupplier)
then(Mono)
with
defer(java.util.function.Supplier<? extends reactor.core.publisher.Mono<? extends T>>)
. The competing overload was causing confusion and the generic was
not symmetric with then(Mono)
.Mono
and transform its completion signal into the
emission and completion signal of a supplied Mono<V>
. Error signal is
replayed in the resulting Mono<V>
.
public final Mono<Void> thenEmpty(Publisher<Void> other)
Mono<Void>
that waits for this Mono
to complete then
for a supplied Publisher<Void>
to also complete. The
second completion signal is replayed, or any error signal that occurs instead.
public final <V> Flux<V> thenMany(Publisher<V> other)
Flux<V>
that will emit elements from the provided Publisher
.
@Deprecated public final <V> Flux<V> thenMany(Supplier<? extends Publisher<V>> afterSupplier)
thenMany(Publisher)
with
defer(java.util.function.Supplier<? extends reactor.core.publisher.Mono<? extends T>>)
. The competing overload was called unnecessary by extended
feedback and aligns with removing of Supplier of Publisher aliases elsewhere.Flux<V>
that will emit elements from the supplier-provided Publisher
.
public final Mono<T> timeout(Duration timeout)
TimeoutException
in case an item doesn't arrive before the given period.
public final Mono<T> timeout(Duration timeout, Mono<? extends T> fallback)
Mono
in case an item doesn't arrive before the given period.
If the given Publisher
is null, signal a TimeoutException
.
public final Mono<T> timeout(Duration timeout, Scheduler timer)
TimeoutException
error in case an item doesn't arrive before the given period.
public final Mono<T> timeout(Duration timeout, Mono<? extends T> fallback, Scheduler timer)
Mono
in case an item doesn't arrive before the given period.
If the given Publisher
is null, signal a TimeoutException
.
public final <U> Mono<T> timeout(Publisher<U> firstTimeout)
TimeoutException
in case the item from this Mono
has
not been emitted before the given Publisher
emits.
public final <U> Mono<T> timeout(Publisher<U> firstTimeout, Mono<? extends T> fallback)
Publisher
in case the item from this Mono
has
not been emitted before the given Publisher
emits. The following items will be individually timed via
the factory provided Publisher
.
U
- the element type of the timeout PublisherfirstTimeout
- the timeout
Publisher
that must not emit before the first signal from this Mono
fallback
- the fallback Publisher
to subscribe when a timeout occursMono
with a fallback Publisher
@Deprecated public final Mono<T> timeoutMillis(long timeout)
Duration
based variants instead, will be removed in 3.1.0TimeoutException
error in case an item doesn't arrive before the given period.
@Deprecated public final Mono<T> timeoutMillis(long timeout, TimedScheduler timer)
Duration
based variants instead, will be removed in 3.1.0TimeoutException
error in case an item doesn't arrive before the given period.
@Deprecated public final Mono<T> timeoutMillis(long timeout, Mono<? extends T> fallback)
Duration
based variants instead, will be removed in 3.1.0Mono
in case an item doesn't arrive before the given period.
If the given Publisher
is null, signal a TimeoutException
.
@Deprecated public final Mono<T> timeoutMillis(long timeout, Mono<? extends T> fallback, TimedScheduler timer)
Duration
based variants instead, will be removed in 3.1.0Mono
in case an item doesn't arrive before the given period.
If the given Publisher
is null, signal a TimeoutException
.
public final Mono<Tuple2<Long,T>> timestamp()
Tuple2
pair of T1 Long
current system time in
millis and T2 T
associated data for the eventual item from this Mono
Mono
@Deprecated public final Mono<Tuple2<Long,T>> timestamp(TimedScheduler scheduler)
timestamp(Scheduler)
public final CompletableFuture<T> toFuture()
Mono
into a CompletableFuture
completing on onNext or onComplete and failing on
onError.
CompletableFuture
public final <V> Mono<V> transform(Function<? super Mono<T>,? extends Publisher<V>> transformer)
Mono
in order to generate a target Mono
. Unlike compose(Function)
, the
provided function is executed as part of assembly.
Function<Mono, Mono> applySchedulers = mono -> mono.subscribeOn(Schedulers.io()).publishOn(Schedulers.parallel());
mono.transform(applySchedulers).map(v -> v * v).subscribe()
V
- the item type in the returned Mono
transformer
- the Function
to immediately map this Mono
into a target Mono
instance.Mono
for deferred composition of {@link Mono} for each {@link Subscriber}
,
for a loose conversion to an arbitrary type
protected static <T> Mono<T> onAssembly(Mono<T> source)
T
- the value typesource
- the source to wrap