pixel
pixel

Reputation: 26441

Reactor mapping Mono<Boolean> to Mono<Void>

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.

Upvotes: 28

Views: 24195

Answers (1)

Simon Basl&#233;
Simon Basl&#233;

Reputation: 28301

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

Upvotes: 46

Related Questions