awaitAll
to replace await Promise.all
calls. awaitAll
to replace await Promise.all
calls.Also, many times you want to limit the concurrency of your promise execution which isn't something you can do with an array of promises. You'd be back to using `await` + something like https://www.npmjs.com/package/promise.map.
I'm someone that used to use `co` where you could go:
const [a, b] = yield [promiseA(), promiseB()]
But I prefer the simplicity and consistency of having to use something like Promise.all or require('promise.map').You have a point with concurrency, but handling concurrency is an another beast altogether.
How does one get to the point where they want to await multiple promises, yet they need to be insulated from the very presence of the `Promise` object?
const [foo, bar, baz] = await returnerOfPromiseCollection();
That would assume there was either a) a catch in that collect or b) some error checking, but still...The code is awaiting an array, which is already "resolved" and its returned right away. Its contents are not relevant to `await`.
Yes, once you have a promise you have to deal with it as such through the whole chain.
I prefer something like p-settle most of the time https://github.com/sindresorhus/p-settle
const awaitAll = Promise.all.bind(Promise);
async function foo() {
var [val1, val2] = await awaitAll([func1, func1]);
}
It isn't ideal but it's a little cleaner const log = console.log.bind(console),
query = document.querySelector.bind(document),
queryAll = document.querySelectorAll.bind(document); await all([fn1, fn2]) ;)
i wonder when we will get s-expressions for function calls (awaitAll [fn1, fn2])https://github.com/nextorigin/riemann-query-parser/blob/mast...
const awaitAll = (futures) => futures.map(f => await f);
edit: this is wrong but I can't delete it. Haven't used async as much as promises.