Can somebody please provide a rationale for why promise reject functions
don't resolve the argument, if the argument is a promise, before they pass
it to the handlers, like promise resolve functions do?
Promise.resolve(Promise.reject(3)).catch(console.log.bind(console)) // logs
3
`Promise.resolve` and the Promise executor function's `resolve` argument
lets you delegate the fulfillment of the given promise to another promise
object. That is essential for composability.
In the other hand, `Promise.reject` and the Promise executor function's
`reject` argument are to be
*By any object I mean any value.
Anyway, it would be interesting to see a real use case for passing a
promise as reject reason.
/FM
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
Maybe it would make sense only when you know that the operation fails but
you don't know the whole exact reason. Like if (something went weird but
not sure what) throw getSomeSpecificErrorFromSomewhere(). But indeed it
seems improbable that you will ever need that, and it still could be
written
Yes, delegating to another promise which then rejects should cover that use
case. `=]`
/FM
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
5 matches
Mail list logo