24
votes

I have function that return Mono<Boolean> and I want to map it to Mono<Void> (since this is something I return in my Controller method).

Is there any better way to return such Mono instead of .flatMap { Mono.empty<Void>() }?

I can't use .map{ null } because mapping function cannot accept nulls.

1

1 Answers

35
votes

yes, simply use booleanMono.then(). it only propagates the terminal signals (onComplete or onError) as a Mono<Void>, ditching the onNext event.