Simplify Reactor switchIfEmpty(Mono.just(...))
using defaultIfEmpty
#363
Labels
Milestone
switchIfEmpty(Mono.just(...))
using defaultIfEmpty
#363
Problem
Specifying default behavior in a Reactor publisher can be written like
switchIfEmpty(Mono.just(42))
ordefaultIfEmpty(42)
.The behavior is identical, but the latter is more concise and may have slight performance benefits due to reduced overhead.
Description of the proposed new feature
I would like to rewrite the following code:
to:
Considerations
Mono
andFlux
.{Mono|Flux}.just(...)
. Cases likeMono.fromSupplier
cannot be rewritten because they would lose the lazy-evaluation behavior.switchIfEmpty(Mono.empty())
, in which case theswitchIfEmpty
operator can simply be dropped.Participation
The text was updated successfully, but these errors were encountered: