Hi,
I'm getting the handle with Vavr and I'm finding it very usefull (and cool) but since unfortunately the version is still under 1.0.0 there's no wide documentation above but following some GitHub issues and Vavr JavaDoc I figured something like this for a multiple execution of futures:
Future.sequence(
List.of(
Future.of(() -> doSth()),
Future.of(() -> doSthElse()),
Future.of(() -> doSthElseMore())
)
).onComplete(result -> {
//...
});
From debug, I can get that the head object contains the doSth() result and the remaining pair of results in the queue object.
What's the best practice to get the do*() results in the onComplete?
Hi @grimimirg, thank you for using Vavr!
Yes, that is exactly the way how to get multiple adync results in sync!
Another possibility would be a flatMap*-map cascade but it is only useful if you don鈥榯 want to operate on sequences:
future1.flatMap(v1 ->
future2.flatMap(v2 ->
future3.map(v3 -> buildYourResult(v1, v2, v3))
)
);
or if you prefer to create side-effects use onComplete...
I hope that helps. We will improve our documentation with Vavr 1.0.
Hi @danieldietrich thank you for your answer! I'll proceed like that.