Closed
Description
With current design, the only way to process resolved value and be sure that unhandled exceptions are exposed, is via following
promise.then(function (value) {
setTimeout(function () {
// Process value
}, 0);
}, function (err) {
setTimeout(function () {
// Handle error
}, 0);
});
Which is poor solution for many reasons:
- Affects performance:
- Creates promise objects we don't need
- forces processing to further tick
- Unintuitive
- Verbose
In many promise implementations, there's already promise.done
, which doesn't create any new promise, and invokes callbacks naturally (outside of try/catch clause).
As done
cannot be implemented on top of available API, I think it's very important to include it in spec.
As side note, why do Promise.prototype.catch
is specified? It can be very easily configured on top of the rest of the API, and it's usability is low.