Using Promise Callbacks For Multiple Events Without Global Variables
I have a promise wrapped in a function. I will call this function multiple times using different input parameters. Each time the promise resolves I push the resolved value into a s
Solution 1:
I would suggest you using of Promise.all
with passing an array of your promises. Invoking then
will let you to handle all response when all of the promises are resolved.
Reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all
for (i=0;i<numberOfPromiseCalls;i++){
storageArray.push(promiseWrapper(inputParams[i]));
}
Promise.all(storageArray).then(responses => {
// responses is an array of all promises responses
});
Post a Comment for "Using Promise Callbacks For Multiple Events Without Global Variables"