I haven't used Promise.all very often. I think I agree with the returned array being weird. You can pass an array of objects:
Promise.all([{time:promiseToBeHereOnTime(true)},{love:promiseToLove(true)},{protect:promiseToProtect(true)}]).then(content=>{console.log(content)console.log('Done! All fulfilled')}).catch(err=>{console.log(err)})/*
[ { time: Promise { 'I promise I will be there!' } },
{ love: Promise { 'I love you so much!' } },
{ protect: Promise { 'I promise I will protect you!' } } ]
Done! All fulfilled
*/
I don't know, it probably would be easier to tweak the Promise.all implementation to server a specific purpose.
You still have the problem with an array being returned though - it's ugly. Named properties would be much nicer. The specific purpose would be to avoid this:
Just spotted this, which gives another interesting approach. Still too much code duplication for my liking though. dev.to/mrm8488/using-es6-array-des...
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I haven't used Promise.all very often. I think I agree with the returned array being weird. You can pass an array of objects:
I don't know, it probably would be easier to tweak the Promise.all implementation to server a specific purpose.
You still have the problem with an array being returned though - it's ugly. Named properties would be much nicer. The specific purpose would be to avoid this:
And replace it with this:
Just spotted this, which gives another interesting approach. Still too much code duplication for my liking though. dev.to/mrm8488/using-es6-array-des...