Promise rejections don't resolve the argument

2014-12-28 Thread raul mihaila
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

Re: Promise rejections don't resolve the argument

2014-12-28 Thread Fabrício Matté
`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

Re: Promise rejections don't resolve the argument

2014-12-28 Thread Fabrício Matté
*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

Re: Promise rejections don't resolve the argument

2014-12-28 Thread raul mihaila
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

Re: Promise rejections don't resolve the argument

2014-12-28 Thread Fabrício Matté
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