I don’t have a Java background so maybe what I’m asking is more of a Java question than an Ignition question.
How do I handle a collection of async calls? I have a bunch of API calls to make and I want to use system.net.httpClient().getAsync every x minutes. The individual calls are unrelated other than the desired frequency.
How do I orchestrate the calls? I’d like to know when everything has completed.
C# Task.WhenAll() is what I have in mind. Don’t know the equivalent concept in Ignition / Java.
The key is that the promise is a thin wrapper around a Java CompletableFuture. Which implements the CompletionStage interface, that has numerous ways to combine results with further actions. The promise wrapper exposes the most import one: .whenComplete(), that takes a function of two arguments. This is the BiConsumer<> async interface. You should create a class implementing BiConsumer with the tracking/counting/accounting logic you wish, and attach it to each promise.
The downside to .allOf() is that you can't construct it incrementally. A well-designed consumer class could accept more promises while earlier ones are running and completing. Such a class can also process the results as it goes.