Reactive programming

Etc..

First (If you have 3 possible Mono sources and you only want to keep the fastest one, you can use the first static method)

  1. Return the mono which returns its value faster
1
2
3
4

Mono<User> useFastestMono(Mono<User> mono1, Mono<User> mono2) {
return Mono.first(mono1, mono2);
}

firstEmitting (For Flux, a similar result can be achieved using the firstEmitting static method. )

  1. Return the flux which returns the first value faster
    1
    2
    3
    4

    Flux<User> useFastestFlux(Flux<User> flux1, Flux<User> flux2) {
    return Flux.firstEmitting(flux1, flux2);
    }

then (Sometimes you’re not interested in elements of a Flux. If you want to still keep a Flux type, you can use ignoreElements(). But if you really just want the completion, represented as a Mono, you can use then() instead:)

  1. Convert the input Flux to a Mono that represents the complete signal of the flux
    1
    2
    3
    4

    Mono<Void> fluxCompletion(Flux<User> flux) {
    return flux.then();
    }