0
votes

Let's say I have the following flow

Mono.just("value 1")
    .zipWith(Mono.just("value 2")) 
       //Mono<Tuple2<String, String>>
    .zipWhen(TupleUtils.function((value1, value2) -> Mono.fromCallable(() -> createValue3(value1, value2)))) 
      //Mono<Tuple2<Tuple2<String, String>, String>>

And just for understanding

private String createValue3(String value1, String value2) {
    return "value 3";
}

As a result, I have

Mono<Tuple2<Tuple2<String, String>, String>>

but I need

Mono<Tuple3<String, String, String>> 

To continue frow with

.map(TupleUtils.function((value1, value2, value3) -> ...)) 

Is there any good solution for this problem?

1
I don't think there is a much better solution, especially if you need value1 AND value2 to obtain value3. zip(pub1, pub2, pub3 would have been an option otherwise.Simon Baslé

1 Answers

0
votes

Ugly solution

.map(tuple -> Tuples.of(tuple.getT1().getT1(), tuple.getT1().getT2(), tuple.getT2()))