I need some help with handling multiple promises at the same time.
I have a Promise foo(value)
provided by a Library
. I trigger this function on an array of value :
for (var i=0; i<this.array.length; i++) {
var aPromise = Library.foo(this.array[i]);
aPromise.then(function(result) {
//I NEED TO KNOW HERE THE VALUE OF this.array[i] LINKED TO THE ACTUAL PROMISE RESULT
alert(array[i]/*not working*/ + " return > " + result);
}).catch[...];
}
I do not find a way to get a link between the which argument has been used to trigger the promise and the actual result of it. Is there a clean way to do it ?
- The Promise is provided by an external Library that I cannot modify.
- I tried to create my own Promise calling that Promise so I can build my own returned object with the inputs and output but I was unsuccessful.
Thanks !