Consider the following code:
var result1;
var result1Promise = getSomeValueAsync().then(x => result1 = x);
var result2;
var result2Promise = getSomeValueAsync().then(x => result2 = x);
await Promise.all([result1Promise, result2Promise]);
// Are result1 and result2 guaranteed to have been set at this point?
console.log(result1 + result2); // Will this always work? Or could result1 and/or result2 be undefined because then() has not been executed yet?
When I use the then() method, is it guaranteed to have been executed in-order? E.g. then() will not execute immediately after Promise.all has been resolved?
It seems to work ok in Chrome, but what I'm really looking for is a guarantee that it will always work accroding to some spec?
I'd rather not use Promise.all(...).then(some callback) because then I'm back to using callbacks again...