I think it is a problem new comers from imperative(blocking) world to the new reactive one will face one day.
Codes better than words.
// blocking code
public Class1 createObj1(Class0 obj0) {
return null;
}
public Class2 createObj2
(Class1 obj1, Class0 obj0) {
return null;
}
public Class2 foo(Class0 obj0) {
Class1 obj1 = createObj1(obj0);
Class2 obj2 = createObj2(obj1, obj0);
return obj2;
}
// equivalent reactive code
public Mono createObj1Mono(Class0 obj0) {
return null;
}
public Mono createObj2Mono
(Class1 obj1, Class0 obj0) {
return null;
}
public Mono fooMono(Mono obj0Mono) {
return obj0Mono
.flatMap(obj0 ->
createObject1Mono(obj0)
.zipWith(Mono.just(obj0))
)
.flatMap(t ->
createObj2Mono(t.getT1(), t.getT2()));
}