Reputation: 1561
Setup:
public Mono<String> getResult(Mono<Boolean> flagMono, Mono<String> resultMono) {
return flagMono.map(flag -> {
if (flag) return "FLAG IS TRUE, SKIP RESULT";
return resultMono.block(); // how to do without blocking?
});
}
Hopefully, what I'm trying to accomplish is clear and it's just a matter of writing it out correctly. I would like to return the string constant if flag
is true, otherwise return the string result returned by resultMono
in a non-blocking way.
Upvotes: 0
Views: 344
Reputation: 2220
public Mono<String> getResult(Mono<Boolean> flagMono, Mono<String> resultMono) {
return flagMono.flatMap(flag -> {
if (flag) return Mono.just("FLAG IS TRUE, SKIP RESULT");
return resultMono;
});
}
Upvotes: 2