I need to implement a version of Promise.all
that would take an array of promises and return the result as it usually does, plus also settles all promises, much like Promise.settle
does it within the Bluebird
library, except I cannot use Bluebird
, and have to rely just on the standard promise protocol.
Would that be terribly complicated to implement? Or is it too much to ask here for an idea of how to implement it? I really hope not, so I'm asking, if anyone perhaps implemented it before, to share the idea of how to do it right.
The premise for this is to be able to use it within a database transaction that needs to do commit
/rollback
once the call has finished, and it cannot have loose promises still trying to resolve outside the transaction call.
EDIT: The link provided to another question is very useful, but it is not a complete answer to the question that was asked. A generic settle
is a great example that helped a lot, but it needed to be simplified and wrapped into all
logic to fit the transactions scenario described earlier.