class Mono[T] extends Publisher[T] with MapablePublisher[T] with OnErrorReturn[T] with MonoLike[T] with Filter[T] with Scannable
A Reactive Streams 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 Flux with possibly more than 1 emission. Its alternative enforcing Mono input is then.
Mono[Unit] 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 scala.Function / lambdas used within Mono operators
should be avoided, as these may be shared between several Subscribers.
- T
the type of the single value of this class
- See also
Flux
- Alphabetic
- By Inheritance
- Mono
- Scannable
- Filter
- MonoLike
- OnErrorReturn
- MapablePublisher
- Publisher
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
actuals(): Stream[_ <: Scannable]
- Definition Classes
- Scannable
-
final
def
and(other: Publisher[_]): Mono[Unit]
Join the termination signals from this mono and another source into the returned void mono
-
final
def
as[P](transformer: (Mono[T]) ⇒ P): P
Transform this Mono into a target type.
Transform this Mono into a target type.
mono.as(Flux::from).subscribe()- P
the returned instance type
- transformer
the { @link Function} applying this { @link Mono}
- returns
the transformed { @link Mono} to instance P
- See also
Mono.compose for a bounded conversion to org.reactivestreams.Publisher
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
- final def asJava(): publisher.Mono[T]
-
final
def
block(timeout: Duration): T
Block until a next signal is received, will return null if onComplete, T if onNext, throw a
Exceptions.DownstreamExceptionif checked error or origin RuntimeException if unchecked.Block until a next signal is received, will return null if onComplete, T if onNext, throw a
Exceptions.DownstreamExceptionif checked error or origin RuntimeException if unchecked. If the default timeout30 secondshas elapsed,a 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
- returns
T the result
-
final
def
block(): T
Block until a next signal is received, will return null if onComplete, T if onNext, throw a
Exceptions.DownstreamExceptionif checked error or origin RuntimeException if unchecked.Block until a next signal is received, will return null if onComplete, T if onNext, throw a
Exceptions.DownstreamExceptionif checked error or origin RuntimeException if unchecked.
- returns
T the result
-
final
def
blockOption(timeout: Duration): Option[T]
Subscribe to this Mono and block until a next signal is received, the Mono completes empty or a timeout expires.
Subscribe to this Mono and block until a next signal is received, the Mono completes empty or a timeout expires. Returns an Option for the first two cases, which can be used to replace the empty case with an Exception via exception). In case the Mono itself errors, the original exception is thrown (wrapped in a RuntimeException if it was a checked exception). If the provided timeout expires, a RuntimeException is thrown.

Note that each block() will trigger a new subscription: in other words, the result might miss signal from hot publishers.
- timeout
maximum time period to wait for before raising a RuntimeException
- returns
T the result
-
final
def
blockOption(): Option[T]
Subscribe to this {Mono Mono} and block indefinitely until a next signal is received or the Mono completes empty.
Subscribe to this {Mono Mono} and block indefinitely until a next signal is received or the Mono completes empty. Returns an Option, which can be used to replace the empty case with an Exception via exception). In case the Mono itself errors, the original exception is thrown (wrapped in a RuntimeException if it was a checked exception).

Note that each blockOptional() will trigger a new subscription: in other words, the result might miss signal from hot publishers.
- returns
T the result
- final def cache(ttl: Duration): Mono[T]
-
final
def
cache(): Mono[T]
Turn this Mono into a hot source and cache last emitted signals for further Subscriber.
-
final
def
cancelOn(scheduler: Scheduler): Mono[T]
Prepare this Mono so that subscribers will cancel from it on a specified reactor.core.scheduler.Scheduler.
-
final
def
cast[E](clazz: Class[E]): Mono[E]
Cast the current Mono produced type into a target produced type.
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
final
def
compose[V](transformer: (Mono[T]) ⇒ Publisher[V]): Mono[V]
Defer the given transformation to this Mono in order to generate a target Mono type.
Defer the given transformation to this Mono in order to generate a target Mono type. A transformation will occur for each org.reactivestreams.Subscriber.
flux.compose(Mono::from).subscribe()- V
the item type in the returned org.reactivestreams.Publisher
- transformer
the function to immediately map this Mono into a target Mono instance.
- returns
a new Mono
- See also
Mono.as for a loose conversion to an arbitrary type
-
final
def
concatWith(other: Publisher[T]): Flux[T]
Concatenate emissions of this Mono with the provided Publisher (no interleave).
-
final
def
defaultIfEmpty(defaultV: T): Mono[T]
Provide a default unique value if this mono is completed without any data
Provide a default unique value if this mono is completed without any data

- defaultV
the alternate value if this sequence is empty
- returns
a new Mono
- See also
-
final
def
delayElement(delay: Duration, timer: Scheduler): Mono[T]
Delay this Mono element (Subscriber.onNext signal) by a given Duration, on a particular Scheduler.
Delay this Mono element (Subscriber.onNext signal) by a given Duration, on a particular Scheduler. Empty monos or error signals are not delayed.

Note that the scheduler on which the mono chain continues execution will be the scheduler provided if the mono is valued, or the current scheduler if the mono completes empty or errors.
- delay
Duration by which to delay the { @link Subscriber#onNext} signal
- timer
a time-capable Scheduler instance to delay the value signal on
- returns
a delayed Mono
-
final
def
delayElement(delay: Duration): Mono[T]
Delay this Mono element (Subscriber.onNext signal) by a given duration.
Delay this Mono element (Subscriber.onNext 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
duration by which to delay the Subscriber.onNext signal
- returns
a delayed Mono
-
final
def
delaySubscription[U](subscriptionDelay: Publisher[U]): Mono[T]
Delay the subscription to this Mono until another Publisher signals a value or completes.
Delay the subscription to this Mono until another Publisher signals a value or completes.
- U
the other source type
- subscriptionDelay
a Publisher to signal by next or complete this Mono.subscribe
- returns
a delayed Mono
-
final
def
delaySubscription(delay: Duration, timer: Scheduler): Mono[T]
Delay the subscription to this Mono source until the given Duration elapses.
Delay the subscription to this Mono source until the given Duration elapses.
-
final
def
delaySubscription(delay: Duration): Mono[T]
Delay the subscription to this Mono source until the given period elapses.
Delay the subscription to this Mono source until the given period elapses.
-
final
def
delayUntil(triggerProvider: (T) ⇒ Publisher[_]): Mono[T]
Subscribe to this Mono and another Publisher that is generated from this Mono's element and which will be used as a trigger for relaying said element.
Subscribe to this Mono and another Publisher that is generated from this Mono's element and which will be used as a trigger for relaying said element.
That is to say, the resulting Mono delays until this Mono's element is emitted, generates a trigger Publisher and then delays again until the trigger Publisher terminates.
Note that contiguous calls to all delayUntil are fused together. The triggers are generated and subscribed to in sequence, once the previous trigger completes. Error is propagated immediately downstream. In both cases, an error in the source is immediately propagated.
- triggerProvider
a Function1 that maps this Mono's value into a Publisher whose termination will trigger relaying the value.
- returns
this Mono, but delayed until the derived publisher terminates.
-
final
def
dematerialize[X](): Mono[X]
A "phantom-operator" working only if this Mono is a emits onNext, onError or onComplete reactor.core.publisher.Signal.
A "phantom-operator" working only if this Mono is a emits onNext, onError or onComplete reactor.core.publisher.Signal. The relative org.reactivestreams.Subscriber callback will be invoked, error reactor.core.publisher.Signal will trigger onError and complete reactor.core.publisher.Signal will trigger onComplete.
- X
the dematerialized type
- returns
a dematerialized Mono
-
final
def
doAfterSuccessOrError(afterTerminate: Function2[_ >: T, Throwable, Unit]): Mono[T]
Triggered after the Mono terminates, either by completing downstream successfully or with an error.
Triggered after the Mono terminates, either by completing downstream successfully or with an error. The arguments will be null depending on success, success with data and error:
- null, null : completed without data
- T, null : completed with data
- null, Throwable : failed with/without data

- afterTerminate
the callback to call after org.reactivestreams.Subscriber.onNext, org.reactivestreams.Subscriber.onComplete without preceding org.reactivestreams.Subscriber.onNext or org.reactivestreams.Subscriber.onError
- returns
a new Mono
-
final
def
doAfterTerminate(afterTerminate: () ⇒ Unit): Mono[T]
Add behavior (side-effect) triggered after the Mono terminates, either by completing downstream successfully or with an error.
- final def doFinally(onFinally: (SignalType) ⇒ Unit): Mono[T]
-
final
def
doOnCancel(onCancel: () ⇒ Unit): Mono[T]
Triggered when the Mono is cancelled.
-
final
def
doOnError(predicate: (Throwable) ⇒ Boolean, onError: (Throwable) ⇒ Unit): Mono[T]
Triggered when the Mono completes with an error matching the given exception.
-
final
def
doOnError[E <: Throwable](exceptionType: Class[E], onError: (E) ⇒ Unit): Mono[T]
Triggered when the Mono completes with an error matching the given exception type.
-
final
def
doOnError(onError: (Throwable) ⇒ Unit): Mono[T]
Triggered when the Mono completes with an error.
-
final
def
doOnNext(onNext: (T) ⇒ Unit): Mono[T]
Add behavior triggered when the Mono emits a data successfully.
-
final
def
doOnRequest(consumer: (Long) ⇒ Unit): Mono[T]
Attach a
Long consumerto this Mono that will observe any request to this Mono. -
final
def
doOnSubscribe(onSubscribe: (Subscription) ⇒ Unit): Mono[T]
Triggered when the Mono is subscribed.
-
final
def
doOnSuccess(onSuccess: (T) ⇒ Unit): Mono[T]
Triggered when the Mono completes successfully.
-
final
def
doOnTerminate(onTerminate: () ⇒ Unit): Mono[T]
Add behavior triggered when the Mono terminates, either by completing successfully or with an error.
-
final
def
elapsed(scheduler: Scheduler): Mono[(Long, T)]
Map this Mono sequence into scala.Tuple2 of T1 Long timemillis and T2
Tassociated data.Map this Mono sequence into scala.Tuple2 of T1 Long timemillis and T2
Tassociated data. The timemillis corresponds to the elapsed time between the subscribe and the first next signal.
- scheduler
the Scheduler to read time from
- returns
a transforming Mono that emits a tuple of time elapsed in milliseconds and matching data
-
final
def
elapsed(): Mono[(Long, T)]
Map this Mono sequence into scala.Tuple2 of T1 Long timemillis and T2
Tassociated data. -
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
expand(expander: (T) ⇒ Publisher[_ <: T]): Flux[T]
Recursively expand elements into a graph and emit all the resulting element using a breadth-first traversal strategy.
Recursively expand elements into a graph and emit all the resulting element using a breadth-first traversal strategy.
That is: emit the value from this Mono first, then it each at a first level of recursion and emit all of the resulting values, then expand all of these at a second level and so on...
For example, given the hierarchical structure
A - AA - aa1 - AB - ab1 - a1Expands
Mono.just(A)intoA AA AB a1 aa1 ab1
- expander
the Function1 applied at each level of recursion to expand values into a Publisher, producing a graph.
- returns
this Mono expanded breadth-first to a Flux
-
final
def
expand(expander: (T) ⇒ Publisher[_ <: T], capacityHint: Int): Flux[T]
Recursively expand elements into a graph and emit all the resulting element using a breadth-first traversal strategy.
Recursively expand elements into a graph and emit all the resulting element using a breadth-first traversal strategy.
That is: emit the value from this Mono first, then it each at a first level of recursion and emit all of the resulting values, then expand all of these at a second level and so on...
For example, given the hierarchical structure
A - AA - aa1 - AB - ab1 - a1Expands
Mono.just(A)intoA AA AB a1 aa1 ab1
- expander
the Function1 applied at each level of recursion to expand values into a Publisher, producing a graph.
- capacityHint
a capacity hint to prepare the inner queues to accommodate n elements per level of recursion.
- returns
this Mono expanded breadth-first to a Flux
-
final
def
expandDeep(expander: (T) ⇒ Publisher[_ <: T]): Flux[T]
Recursively expand elements into a graph and emit all the resulting element, in a depth-first traversal order.
Recursively expand elements into a graph and emit all the resulting element, in a depth-first traversal order.
That is: emit the value from this Mono, expand it and emit the first value at this first level of recursion, and so on... When no more recursion is possible, backtrack to the previous level and re-apply the strategy.
For example, given the hierarchical structure
A - AA - aa1 - AB - ab1 - a1Expands
Mono.just(A)intoA AA aa1 AB ab1 a1
- expander
the Function1 applied at each level of recursion to expand values into a Publisher, producing a graph.
- returns
this Mono expanded depth-first to a Flux
-
final
def
expandDeep(expander: (T) ⇒ Publisher[_ <: T], capacityHint: Int): Flux[T]
Recursively expand elements into a graph and emit all the resulting element, in a depth-first traversal order.
Recursively expand elements into a graph and emit all the resulting element, in a depth-first traversal order.
That is: emit the value from this Mono, expand it and emit the first value at this first level of recursion, and so on... When no more recursion is possible, backtrack to the previous level and re-apply the strategy.
For example, given the hierarchical structure
A - AA - aa1 - AB - ab1 - a1Expands
Mono.just(A)intoA AA aa1 AB ab1 a1
- expander
the Function1 applied at each level of recursion to expand values into a Publisher, producing a graph.
- capacityHint
a capacity hint to prepare the inner queues to accommodate n elements per level of recursion.
- returns
this Mono expanded depth-first to a Flux
-
final
def
filter(tester: (T) ⇒ Boolean): Mono[T]
Test the result if any of this Mono and replay it if predicate returns true.
-
final
def
filterWhen(asyncPredicate: Function1[T, _ <: Publisher[Boolean] with MapablePublisher[Boolean]]): Mono[T]
If this Mono is valued, test the value asynchronously using a generated Publisher[Boolean] test.
If this 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.
- asyncPredicate
the function generating a Publisher of Boolean to filter the Mono with
- returns
a filtered Mono
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
flatMap[R](transformer: (T) ⇒ Mono[R]): Mono[R]
Transform the item emitted by this Mono asynchronously, returning the value emitted by another Mono (possibly changing the value type).
-
final
def
flatMapIterable[R](mapper: (T) ⇒ Iterable[R]): Flux[R]
Transform the item emitted by this Mono into Iterable, , then forward its elements into the returned Flux.
Transform the item emitted by this Mono into Iterable, , then forward its elements into the returned Flux. The prefetch argument allows to give an arbitrary prefetch size to the inner Iterable.
- R
the merged output sequence type
- mapper
the Function1 to transform input item into a sequence Iterable
- returns
a merged Flux
-
final
def
flatMapMany[R](mapperOnNext: (T) ⇒ Publisher[R], mapperOnError: (Throwable) ⇒ Publisher[R], mapperOnComplete: () ⇒ Publisher[R]): Flux[R]
Transform the signals emitted by this Mono into a Publisher, then forward its emissions into the returned Flux.
Transform the signals emitted by this Mono into a Publisher, then forward its emissions into the returned Flux.

- R
the type of the produced inner sequence
- mapperOnNext
the Function1 to call on next data and returning a sequence to merge
- mapperOnError
theFunction1 to call on error signal and returning a sequence to merge
- mapperOnComplete
the Function1 to call on complete signal and returning a sequence to merge
- returns
a new Flux as the sequence is not guaranteed to be single at most
- See also
-
final
def
flatMapMany[R](mapper: (T) ⇒ Publisher[R]): Flux[R]
Transform the item emitted by this Mono into a Publisher, then forward its emissions into the returned Flux.
- final def flux(): Flux[T]
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
handle[R](handler: (T, SynchronousSink[R]) ⇒ Unit): Mono[R]
Handle the items emitted by this Mono by calling a biconsumer with the output sink for each onNext.
-
final
def
hasElement: Mono[Boolean]
Emit a single boolean true if this Mono has an element.
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
hide: Mono[T]
Hides the identity of this Mono instance.
-
final
def
ignoreElement: Mono[T]
Ignores onNext signal (dropping it) and only reacts on termination.
Ignores onNext signal (dropping it) and only reacts on termination.

- returns
a new completable Mono.
-
def
inners(): Stream[_ <: Scannable]
- Definition Classes
- Scannable
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
isScanAvailable: Boolean
- Definition Classes
- Scannable
- implicit def jMonoVoid2jMonoUnit(jMonoVoid: publisher.Mono[Void]): publisher.Mono[Unit]
- def jScannable: core.Scannable
-
final
def
log(category: Option[String], level: Level, showOperatorLine: Boolean, options: SignalType*): Mono[T]
Observe Reactive Streams signals matching the passed filter
optionsand use reactor.util.Logger support to handle trace implementation.Observe Reactive Streams signals matching the passed filter
optionsand use reactor.util.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)
@param 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".
@param level the [[Level]] to enforce for this tracing Mono (only FINEST, FINE,
INFO, WARNING and SEVERE are taken into account)
@param showOperatorLine capture the current stack to display operator
class/line number.
@param options a vararg [[SignalType]] option to filter log messages
@return a new unaltered [[Mono]]
-
final
def
log(category: Option[String], level: Level, options: SignalType*): Mono[T]
Observe Reactive Streams signals matching the passed flags
optionsand use reactor.util.Logger support to handle trace implementation.Observe Reactive Streams signals matching the passed flags
optionsand use reactor.util.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)
@param 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".
@param level the { @link Level} to enforce for this tracing Mono (only FINEST, FINE,
INFO, WARNING and SEVERE are taken into account)
@param options a vararg [[SignalType]] option to filter log messages
@return a new [[Mono]]
-
final
def
log(category: Option[String]): Mono[T]
Observe all Reactive Streams signals and use reactor.util.Logger support to handle trace implementation.
Observe all Reactive Streams signals and use reactor.util.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".
- returns
a new Mono
-
final
def
log: Mono[T]
Observe all Reactive Streams signals and trace them using reactor.util.Logger support.
Observe all Reactive Streams signals and trace them using reactor.util.Logger support. Default will use Level.INFO and
java.util.logging. If SLF4J is available, it will be used instead.
The default log category will be "reactor.Mono", followed by a suffix generated from the source operator, e.g. "reactor.Mono.Map".
- returns
a new Mono that logs signals
- See also
Flux.log()
-
final
def
map[R](mapper: (T) ⇒ R): Mono[R]
Transform the item emitted by this Mono by applying a synchronous function to it.
Transform the item emitted by this Mono by applying a synchronous function to it.

- R
the transformed type
- mapper
the synchronous transforming Function1
- returns
a new Mono
- Definition Classes
- Mono → MapablePublisher
-
final
def
materialize(): Mono[Signal[T]]
Transform the incoming onNext, onError and onComplete signals into Signal.
Transform the incoming onNext, onError and onComplete signals into Signal. Since the error is materialized as a
Signal, the propagation will be stopped and onComplete will be emitted. Complete signal will first emit aSignal.complete()and then effectively complete the flux.
- returns
a Mono of materialized Signal
-
final
def
mergeWith(other: Publisher[_ <: T]): Flux[T]
Merge emissions of this Mono with the provided Publisher.
-
final
def
name(name: String): Mono[T]
Give a name to this sequence, which can be retrieved using reactor.core.scala.Scannable.name() as long as this is the first reachable reactor.core.scala.Scannable.parents().
Give a name to this sequence, which can be retrieved using reactor.core.scala.Scannable.name() as long as this is the first reachable reactor.core.scala.Scannable.parents().
- name
a name for the sequence
- returns
the same sequence, but bearing a name
-
def
name: String
Check this Scannable and its Scannable.parents() for a name an return the first one that is reachable.
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
ofType[U](clazz: Class[U]): Mono[U]
Evaluate the accepted value against the given Class type.
-
final
def
onErrorMap(predicate: (Throwable) ⇒ Boolean, mapper: (Throwable) ⇒ Throwable): Mono[T]
Transform the error emitted by this Mono by applying a function if the error matches the given predicate, otherwise let the error flow.
-
final
def
onErrorMap[E <: Throwable](type: Class[E], mapper: (E) ⇒ Throwable): Mono[T]
Transform the error emitted by this Mono by applying a function if the error matches the given type, otherwise let the error flow.
Transform the error emitted by this Mono by applying a function if the error matches the given type, otherwise let the error flow.
<img class="marble" src="https://raw.githubusercontent.com/reactor/reactor-core/v3.1.0.RC1/src/docs/marble/maperror.png"
- E
the error type
- type
the type to match
- mapper
the error transforming Function1
- returns
a transformed Mono
-
final
def
onErrorMap(mapper: (Throwable) ⇒ Throwable): Mono[T]
Transform the error emitted by this Mono by applying a function.
-
final
def
onErrorRecover[U <: T](pf: PartialFunction[Throwable, U]): Mono[T]
Returns a Mono that mirrors the behavior of the source, unless the source is terminated with an
onError, in which case the streaming of events fallbacks to an observable emitting a single element generated by the backup function.Returns a Mono that mirrors the behavior of the source, unless the source is terminated with an
onError, in which case the streaming of events fallbacks to an observable emitting a single element generated by the backup function.The created Mono mirrors the behavior of the source in case the source does not end with an error or if the thrown
Throwableis not matched.See onErrorResume for the version that takes a total function as a parameter.
- pf
- a function that matches errors with a backup element that is emitted when the source throws an error.
- Definition Classes
- MonoLike
-
final
def
onErrorRecoverWith[U <: T](pf: PartialFunction[Throwable, Mono[U]]): Mono[T]
Returns a Mono that mirrors the behavior of the source, unless the source is terminated with an
onError, in which case the streaming of events continues with the specified backup sequence generated by the given function.Returns a Mono that mirrors the behavior of the source, unless the source is terminated with an
onError, in which case the streaming of events continues with the specified backup sequence generated by the given function.The created Mono mirrors the behavior of the source in case the source does not end with an error or if the thrown
Throwableis not matched.See onErrorResume for the version that takes a total function as a parameter.
- pf
is a function that matches errors with a backup throwable that is subscribed when the source throws an error.
- Definition Classes
- MonoLike
-
final
def
onErrorResume(predicate: (Throwable) ⇒ Boolean, fallback: (Throwable) ⇒ Mono[_ <: T]): Mono[T]
Subscribe to a returned fallback publisher when an error matching the given predicate occurs.
-
final
def
onErrorResume[E <: Throwable](type: Class[E], fallback: (E) ⇒ Mono[_ <: T]): Mono[T]
Subscribe to a returned fallback publisher when an error matching the given type occurs.
-
final
def
onErrorResume(fallback: (Throwable) ⇒ Mono[_ <: T]): Mono[T]
Subscribe to a returned fallback publisher when any error occurs.
Subscribe to a returned fallback publisher when any error occurs.

- fallback
the function to map an alternative { @link Mono}
- returns
an alternating Mono on source onError
- See also
-
final
def
onErrorReturn(predicate: (Throwable) ⇒ Boolean, fallbackValue: T): Mono[T]
Simply emit a captured fallback value when an error matching the given predicate is observed on this Mono.
Simply emit a captured fallback value when an error matching the given predicate is observed on this Mono.
- predicate
the error predicate to match
- fallbackValue
the value to emit if a matching error occurs
- returns
a new Mono
- Definition Classes
- Mono → OnErrorReturn
-
final
def
onErrorReturn[E <: Throwable](type: Class[E], fallbackValue: T): Mono[T]
Simply emit a captured fallback value when an error of the specified type is observed on this Mono.
Simply emit a captured fallback value when an error of the specified type is observed on this Mono.
- E
the error type
- type
the error type to match
- fallbackValue
the value to emit if a matching error occurs
- returns
a new falling back Mono
- Definition Classes
- Mono → OnErrorReturn
-
final
def
onErrorReturn(fallback: T): Mono[T]
Simply emit a captured fallback value when any error is observed on this Mono.
Simply emit a captured fallback value when any error is observed on this Mono.

- fallback
the value to emit if an error occurs
- returns
a new falling back Mono
- Definition Classes
- Mono → OnErrorReturn
-
final
def
onTerminateDetach(): Mono[T]
Detaches the both the child Subscriber and the Subscription on termination or cancellation.
Detaches the both the child Subscriber and the Subscription on termination or cancellation.
This should help with odd retention scenarios when running with non-reactor Subscriber.
- returns
a detachable Mono
-
def
operatorName: String
Check this Scannable and its Scannable.parents() for a name an return the first one that is reachable.
-
final
def
or(other: Mono[_ <: T]): Mono[T]
Emit the any of the result from this mono or from the given mono
Emit the any of the result from this mono or from the given mono

- other
the racing other { @link Mono} to compete with for the result
- returns
a new Mono
- See also
-
def
parents: Stream[_ <: Scannable]
Return a Stream navigating the org.reactivestreams.Subscription chain (upward).
Return a Stream navigating the org.reactivestreams.Subscription chain (upward).
- returns
a Stream navigating the org.reactivestreams.Subscription chain (upward)
- Definition Classes
- Scannable
-
final
def
publish[R](transform: (Mono[T]) ⇒ Mono[R]): Mono[R]
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.
-
final
def
publishOn(scheduler: Scheduler): Mono[T]
Run onNext, onComplete and onError on a supplied Scheduler
Run onNext, onComplete and onError on a supplied Scheduler

Typically used for fast publisher, slow consumer(s) scenarios.
mono.publishOn(Schedulers.single()).subscribe()- scheduler
a checked { @link reactor.core.scheduler.Scheduler.Worker} factory
- returns
an asynchronously producing Mono
-
final
def
repeat(numRepeat: Long, predicate: () ⇒ Boolean): Flux[T]
Repeatedly subscribe to the source if the predicate returns true after completion of the previous subscription.
Repeatedly subscribe to the source if the predicate returns true after completion of the previous subscription. A specified maximum of repeat will limit the number of re-subscribe.
- numRepeat
the number of times to re-subscribe on complete
- predicate
the boolean to evaluate on onComplete
- returns
an eventually repeated Flux on onComplete up to number of repeat specified OR matching predicate
-
final
def
repeat(numRepeat: Long): Flux[T]
Repeatedly subscribe to the source if the predicate returns true after completion of the previous subscription.
Repeatedly subscribe to the source if the predicate returns true after completion of the previous subscription.
- numRepeat
the number of times to re-subscribe on onComplete
- returns
an eventually repeated Flux on onComplete up to number of repeat specified
-
final
def
repeat(predicate: () ⇒ Boolean): Flux[T]
Repeatedly subscribe to the source if the predicate returns true after completion of the previous subscription.
Repeatedly subscribe to the source if the predicate returns true after completion of the previous subscription.
- predicate
the boolean to evaluate on onComplete.
- returns
an eventually repeated Flux on onComplete
-
final
def
repeat(): Flux[T]
Repeatedly subscribe to the source completion of the previous subscription.
Repeatedly subscribe to the source completion of the previous subscription.
- returns
an indefinitively repeated Flux on onComplete
-
final
def
repeatWhen(whenFactory: Function1[Flux[Long], _ <: Publisher[_]]): Flux[T]
Repeatedly subscribe to this Mono when a companion sequence signals a number of emitted elements in response to the flux completion signal.
Repeatedly subscribe to this 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.
-
final
def
repeatWhenEmpty(maxRepeat: Int, repeatFactory: (Flux[Long]) ⇒ Publisher[_]): Mono[T]
Repeatedly subscribe to this Mono until there is an onNext signal when a companion sequence signals a number of emitted elements.
Repeatedly subscribe to this 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 Int.MaxValue.
- maxRepeat
the maximum repeat number of time (infinite if Int.MaxValue)
- repeatFactory
the Function1 providing a Flux signalling the current repeat index from 0 on onComplete and returning a { @link Publisher} companion.
- returns
an eventually repeated Mono on onComplete when the companion Publisher produces an onNext signal
-
final
def
repeatWhenEmpty(repeatFactory: (Flux[Long]) ⇒ Publisher[_]): Mono[T]
Repeatedly subscribe to this Mono until there is an onNext signal when a companion sequence signals a number of emitted elements.
Repeatedly subscribe to this 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.
-
final
def
retry(numRetries: Long, retryMatcher: (Throwable) ⇒ Boolean): Mono[T]
Re-subscribes to this Mono sequence up to the specified number of retries if it signals any error and the given
Predicatematches otherwise push the error downstream.Re-subscribes to this Mono sequence up to the specified number of retries if it signals any error and the given
Predicatematches otherwise push the error downstream.
- numRetries
the number of times to tolerate an error
- retryMatcher
the predicate to evaluate if retry should occur based on a given error signal
- returns
a re-subscribing Mono on onError up to the specified number of retries and if the predicate matches.
-
final
def
retry(retryMatcher: (Throwable) ⇒ Boolean): Mono[T]
Re-subscribes to this Mono sequence if it signals any error and the given
Predicatematches otherwise push the error downstream. -
final
def
retry(numRetries: Long): Mono[T]
Re-subscribes to this Mono sequence if it signals any error either indefinitely or a fixed number of times.
-
final
def
retry(): Mono[T]
Re-subscribes to this Mono sequence if it signals any error either indefinitely.
-
final
def
retryWhen(whenFactory: (Flux[Throwable]) ⇒ Publisher[_]): Mono[T]
Retries this Mono when a companion sequence signals an item in response to this Mono error signal
-
def
scan[T](key: Attr[T]): Option[T]
Introspect a component's specific state attribute, returning an associated value specific to that component, or the default value associated with the key, or null if the attribute doesn't make sense for that particular component and has no sensible default.
Introspect a component's specific state attribute, returning an associated value specific to that component, or the default value associated with the key, or null if the attribute doesn't make sense for that particular component and has no sensible default.
- key
a Attr to resolve for the component.
- returns
a value associated to the key or None if unmatched or unresolved
- Definition Classes
- Scannable
-
def
scanOrDefault[T](key: Attr[T], defaultValue: T): T
Introspect a component's specific state attribute.
Introspect a component's specific state attribute. If there's no specific value in the component for that key, fall back to returning the provided non null default.
- key
a Attr to resolve for the component.
- defaultValue
a fallback value if key resolve to { @literal null}
- returns
a value associated to the key or the provided default if unmatched or unresolved
- Definition Classes
- Scannable
-
def
scanUnsafe(key: Attr[_]): Option[AnyRef]
This method is used internally by components to define their key-value mappings in a single place.
This method is used internally by components to define their key-value mappings in a single place. Although it is ignoring the generic type of the Attr key, implementors should take care to return values of the correct type, and return None if no specific value is available.
For public consumption of attributes, prefer using Scannable.scan(Attr), which will return a typed value and fall back to the key's default if the component didn't define any mapping.
- key
a { @link Attr} to resolve for the component.
- returns
the value associated to the key for that specific component, or null if none.
- Definition Classes
- Scannable
-
final
def
single(): Mono[T]
Expect exactly one item from this Mono source or signal java.util.NoSuchElementException for an empty source.
-
final
def
subscribe(consumer: (T) ⇒ Unit, errorConsumer: (Throwable) ⇒ Unit, completeConsumer: ⇒ Unit, subscriptionConsumer: (Subscription) ⇒ Unit): Disposable
Subscribe Consumer to this Mono that will consume all the sequence.
Subscribe Consumer to this Mono that will consume all the sequence.
For a passive version that observe and forward incoming data see Mono.doOnSuccess and Mono.doOnError.
- consumer
the consumer to invoke on each value
- errorConsumer
the consumer to invoke on error signal
- completeConsumer
the consumer to invoke on complete signal
- subscriptionConsumer
the consumer to invoke on subscribe signal, to be used for the initial request, or null for max request
- returns
a new Disposable to dispose the Subscription
-
final
def
subscribe(consumer: (T) ⇒ Unit, errorConsumer: (Throwable) ⇒ Unit, completeConsumer: ⇒ Unit): Disposable
Subscribe
consumerto this Mono that will consume all the sequence.Subscribe
consumerto this Mono that will consume all the sequence.For a passive version that observe and forward incoming data see Mono.doOnSuccess and Mono.doOnError.
- consumer
the consumer to invoke on each value
- errorConsumer
the consumer to invoke on error signal
- completeConsumer
the consumer to invoke on complete signal
- returns
a new Disposable to dispose the Subscription
-
final
def
subscribe(consumer: (T) ⇒ Unit, errorConsumer: (Throwable) ⇒ Unit): Disposable
Subscribe Consumer to this Mono that will consume all the sequence.
Subscribe Consumer to this Mono that will consume all the sequence.
For a passive version that observe and forward incoming data see Mono.doOnSuccess and Mono.doOnError.
- consumer
the consumer to invoke on each next signal
- errorConsumer
the consumer to invoke on error signal
- returns
a new Runnable to dispose the org.reactivestreams.Subscription
-
final
def
subscribe(consumer: (T) ⇒ Unit): Disposable
Subscribe a Consumer to this Mono that will consume all the sequence.
Subscribe a Consumer to this Mono that will consume all the sequence.
For a passive version that observe and forward incoming data see Mono.doOnSuccess and Mono.doOnError.
- consumer
the consumer to invoke on each value
- returns
a new Runnable to dispose the Subscription
-
final
def
subscribe(): Disposable
Subscribe to this Mono and request unbounded demand.
Subscribe to this Mono and request unbounded demand.
This version doesn't specify any consumption behavior for the events from the chain, especially no error handling, so other variants should usually be preferred.

- returns
a new Disposable that can be used to cancel the underlying Subscription
-
def
subscribe(s: Subscriber[_ >: T]): Unit
- Definition Classes
- Mono → Publisher
-
final
def
subscribeOn(scheduler: Scheduler): Mono[T]
Run the requests to this Publisher Mono on a given worker assigned by the supplied Scheduler.
-
final
def
subscribeWith[E <: Subscriber[_ >: T]](subscriber: E): E
Subscribe the Mono with the givne Subscriber and return it.
Subscribe the Mono with the givne Subscriber and return it.
- E
the reified type of the Subscriber for chaining
- subscriber
the Subscriber to subscribe
- returns
the passed Subscriber after subscribing it to this { @link Mono}
-
final
def
subscriberContext(doOnContext: (Context) ⇒ Context): Mono[T]
Enrich a potentially empty downstream Context by applying a Function1 to it, producing a new Context that is propagated upstream.
Enrich a potentially empty downstream Context by applying a Function1 to it, producing a new Context that is propagated upstream.
The Context propagation happens once per subscription (not on each onNext): it is done during the
subscribe(Subscriber)phase, which runs from the last operator of a chain towards the first.So this operator enriches a Context coming from under it in the chain (downstream, by default an empty one) and passes the new enriched Context to operators above it in the chain (upstream, by way of them using
Flux#subscribe(Subscriber,Context)).- doOnContext
the function taking a previous Context state and returning a new one.
- returns
a contextualized Mono
- See also
Context
-
final
def
subscriberContext(mergeContext: Context): Mono[T]
Enrich a potentially empty downstream Context by adding all values from the given Context, producing a new Context that is propagated upstream.
Enrich a potentially empty downstream Context by adding all values from the given Context, producing a new Context that is propagated upstream.
The Context propagation happens once per subscription (not on each onNext): it is done during the
subscribe(Subscriber)phase, which runs from the last operator of a chain towards the first.So this operator enriches a Context coming from under it in the chain (downstream, by default an empty one) and passes the new enriched Context to operators above it in the chain (upstream, by way of them using Flux.subscribe(Subscriber,Context)).
- mergeContext
the Context to merge with a previous Context state, returning a new one.
- returns
a contextualized Mono
- See also
Context
-
final
def
switchIfEmpty(alternate: Mono[_ <: T]): Mono[T]
Provide an alternative Mono if this mono is completed without data
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
final
def
tag(key: String, value: String): Mono[T]
Tag this mono with a key/value pair.
Tag this mono with a key/value pair. These can be retrieved as a Stream of all tags throughout the publisher chain by using reactor.core.scala.Scannable.tags() (as traversed by reactor.core.scala.Scannable.parents()).
- key
a tag key
- value
a tag value
- returns
the same sequence, but bearing tags
-
def
tags: Stream[(String, String)]
Visit this Scannable and its Scannable.parents() and stream all the observed tags
-
final
def
take(duration: Duration, timer: Scheduler): Mono[T]
Give this Mono a chance to resolve within a specified time frame but complete if it doesn't.
Give this Mono a chance to resolve within a specified time frame but complete if it doesn't. This works a bit like Mono.timeout(Duration) except that the resulting Mono completes rather than errors when the timer expires.
The timeframe is evaluated using the provided Scheduler.
- duration
the maximum duration to wait for the source Mono to resolve.
- timer
the Scheduler on which to measure the duration.
- returns
a new Mono that will propagate the signals from the source unless no signal is received for
duration, in which case it completes.
-
final
def
take(duration: Duration): Mono[T]
Give this Mono a chance to resolve within a specified time frame but complete if it doesn't.
Give this Mono a chance to resolve within a specified time frame but complete if it doesn't. This works a bit like Mono.timeout(Duration) except that the resulting Mono completes rather than errors when the timer expires.
The timeframe is evaluated using the parallel Scheduler.
- duration
the maximum duration to wait for the source Mono to resolve.
- returns
a new Mono that will propagate the signals from the source unless no signal is received for
duration, in which case it completes.
-
final
def
takeUntilOther(other: Publisher[_]): Mono[T]
Give this Mono a chance to resolve before a companion Publisher emits.
Give this Mono a chance to resolve before a companion Publisher emits. If the companion emits before any signal from the source, the resulting Mono will complete. Otherwise, it will relay signals from the source.
- other
a companion Publisher that short-circuits the source with an onComplete signal if it emits before the source emits.
- returns
a new Mono that will propagate the signals from the source unless a signal is first received from the companion Publisher, in which case it completes.
-
final
def
then[V](other: Mono[V]): Mono[V]
Ignore element from this Mono and transform its completion signal into the emission and completion signal of a provided
Mono[V].Ignore element from this Mono and transform its completion signal into the emission and completion signal of a provided
Mono[V]. Error signal is replayed in the resultingMono[V].
-
final
def
then(): Mono[Unit]
Return a
Mono[Unit]which only replays complete and error signals from this Mono. -
final
def
thenEmpty(other: Publisher[Unit]): Mono[Unit]
Return a
Mono[Unit]that waits for this Mono to complete then for a supplied Publisher[Unit] to also complete.Return a
Mono[Unit]that waits for this Mono to complete then for a supplied Publisher[Unit] to also complete. The second completion signal is replayed, or any error signal that occurs instead.
- other
a Publisher to wait for after this Mono's termination
- returns
a new Mono completing when both publishers have completed in sequence
-
final
def
thenMany[V](other: Publisher[V]): Flux[V]
Ignore element from this mono and transform the completion signal into a
Flux[V]that will emit elements from the provided Publisher.Ignore element from this mono and transform the completion signal into a
Flux[V]that will emit elements from the provided Publisher.
- V
the element type of the supplied Publisher
- other
a Publisher to emit from after termination
- returns
a new Flux that emits from the supplied Publisher after this Mono completes.
-
final
def
timeout[U](firstTimeout: Publisher[U], fallback: Mono[_ <: T]): Mono[T]
Switch to a fallback Publisher in case the item from this Mono has not been emitted before the given Publisher emits.
Switch to a 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.
-
final
def
timeout[U](firstTimeout: Publisher[U]): Mono[T]
Signal a java.util.concurrent.TimeoutException in case the item from this Mono has not been emitted before the given Publisher emits.
Signal a java.util.concurrent.TimeoutException in case the item from this Mono has not been emitted before the given Publisher emits.
-
final
def
timeout(timeout: Duration, fallback: Option[Mono[_ <: T]], timer: Scheduler): Mono[T]
Switch to a fallback Mono in case an item doesn't arrive before the given period.
Switch to a fallback Mono in case an item doesn't arrive before the given period.
If the given
Publisheris None, signal a java.util.concurrent.TimeoutException.
-
final
def
timeout(timeout: Duration, timer: Scheduler): Mono[T]
Signal a java.util.concurrent.TimeoutException error in case an item doesn't arrive before the given period.
-
final
def
timeout(timeout: Duration, fallback: Option[Mono[_ <: T]]): Mono[T]
Switch to a fallback Mono in case an item doesn't arrive before the given period.
Switch to a fallback Mono in case an item doesn't arrive before the given period.
If the given Publisher is null, signal a java.util.concurrent.TimeoutException.
-
final
def
timeout(timeout: Duration): Mono[T]
Signal a java.util.concurrent.TimeoutException in case an item doesn't arrive before the given period.
-
final
def
timestamp(scheduler: Scheduler): Mono[(Long, T)]
Emit a Tuple2 pair of T1 Long current system time in millis and T2
Tassociated data for the eventual item from this Mono -
final
def
timestamp(): Mono[(Long, T)]
Emit a Tuple2 pair of T1 Long current system time in millis and T2
Tassociated data for the eventual item from this Mono -
final
def
toFuture: Future[T]
Transform this Mono into a Future completing on onNext or onComplete and failing on onError.
Transform this Mono into a Future completing on onNext or onComplete and failing on onError.

- returns
a Future
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
transform[V](transformer: (Mono[T]) ⇒ Publisher[V]): Mono[V]
Transform this Mono in order to generate a target Mono.
Transform this Mono in order to generate a target Mono. Unlike Mono.compose, the provided function is executed as part of assembly.
- V
the item type in the returned Mono
- transformer
the Function1 to immediately map this Mono into a target Mono instance.
- returns
a new Mono
val applySchedulers = mono => mono.subscribeOn(Schedulers.elastic()).publishOn(Schedulers.parallel()); mono.transform(applySchedulers).map(v => v * v).subscribe()
- See also
Mono.compose for deferred composition of Mono for each Subscriber
Mono.as for a loose conversion to an arbitrary type
Example: -
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )














