StringRecord<string | number | symbol, T> => Promise<StringRecord<string | number | symbol, T>>
This takes an object where the values are probably promises and returns a promise that has that same object but with the resolved values.
Here's a good example of this function in use:
await allObjectP({
merge: mergeResource(session),
current: storeCurrent(session.id),
account: pullAccount(session.relationship.account.data.id, client),
})
// {merge, current, account}
If we use allP
or Promise.all
we're getting an array back, but that's annoying to destructure. The allObjectP
function gives us the concurrency we want with a named interface for the returned resolutions.