As we know enqueueing multiple actions are all sent to the server at the same time.
The issue I am having is that the time each action takes to complete is not the same. Lets say I want to show a spinner until the all actions have completed. How can I tell that all are done.
The setup is basically:
doInit: function (component, event, helper) {
var action1 = component.get(.....);
action1.setCallback(this, function (result) {
......
});
var action2 = component.get(.....);
action2.setCallback(this, function (result) {
......
});
var action3 = component.get(.....);
action3.setCallback(this, function (result) {
......
});
$A.enqueueAction(action1);
$A.enqueueAction(action2);
$A.enqueueAction(action3);
}
Now I want to do this when and only when ALL 3 actions have completed:
$A.util.addClass(component.find("spinner"), "slds-hide");
Assuming the length of time it takes to make the roundtrip for each action can be variable and unpredictable just placing it inside a give callback may remove the spinner while other actions are still processing.
So the question, where to put that line to ensure it is only done once all actions have made the roundtrip?