rbuckton at chronicles.org
Mon Aug 18 12:03:08 PDT 2014
I created the following gist as a proposal for the addition of a `finally` method to the prototype of the Promise constructor, either for ES6 (if such a thing is considered valuable and could be fast tracked at this date), or for ES7. This method would take in a single callback that would be executed once when the antecedent Promise is settled regardless of whether it was fulfilled or rejected. If the callback results in a normal completion, the state of the antecedent promise would be adopted by the new Promise. However, if the callback results in an abrupt completion, the new Promise would be rejected with this reason.
You can find more details about this proposal along with amendments to the current ES6 working draft below:
Proposal for addition of Promise.prototype.finally
Proposal for addition of Promise.prototype.finally - Gist is a simple way to share snippets of text and code with others.
After working heavily with an ES6 Promise shim as of late, I have found such a feature would be very valuable. It is possible to patch the ES6 Promise API to add such a feature, however it seems like it could be a worthwhile addition that could benefit the community until such a time as an `async/await`-like syntax is available in ES7+.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss