RE: Proposal: Promise.prototype.Finally
Here is the current design for Promise.prototype.finally. I agree it is a useful feature. https://github.com/domenic/promises-unwrapping/issues/18 ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Proposal: Promise.prototype.Finally
Yes. Needed it recently. Ended up doing .then(f).catch(f) which can be survived but feels stupid. David Le 18/08/2014 21:20, Domenic Denicola a écrit : Here is the current design for Promise.prototype.finally. I agree it is a useful feature. https://github.com/domenic/promises-unwrapping/issues/18 ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
Re: Proposal: Promise.prototype.Finally
On Mon, Aug 18, 2014 at 12:30 PM, David Bruant bruan...@gmail.com wrote: Yes. Needed it recently. Ended up doing .then(f).catch(f) which can be survived but feels stupid. And doesn't have the correct pass-through behavior, unless you've got a switch in f that makes it return or throw based on whether the argument is an Exception. ~TJ ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
RE: Proposal: Promise.prototype.Finally
Domenic, I like the addition that your version of `finally` can itself return a Promise, which I hadn't considered (as I hadn't had a need for it myself yet). Is the consensus that this won't make it into Promise until at least ES7, and then only if there's enough of a call for it? To be honest, if ES7 has something like async/await then it won't need Promise.prototype.finally. Promise.prototype.finally is primarily a feature needed for Promises without async/await (e.g. in the ES6 timeframe, or ES7 if async/await is deferred to a later revision). Ron From: Domenic Denicola dome...@domenicdenicola.com Sent: Monday, August 18, 2014 3:20 PM To: Ron Buckton; EcmaScript Subject: RE: Proposal: Promise.prototype.Finally Here is the current design for Promise.prototype.finally. I agree it is a useful feature. https://github.com/domenic/promises-unwrapping/issues/18 ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss
RE: Proposal: Promise.prototype.Finally
Is the consensus that this won't make it into Promise until at least ES7, and then only if there's enough of a call for it? Although I find the arbitrary division of features into ES6 and ES7 distasteful personally: yes, ES6 will not be adding new APIs. That doesn't mean that Promise.prototype.finally won't ship in all major browsers before other ES6 features do. But it does mean that we won't be submitting a document to the Ecma general assembly with Promise.prototype.finally before we submit one with proper tail calls. To be honest, if ES7 has something like async/await then it won't need Promise.prototype.finally. That's mostly true, I suppose, but it can increase brevity in some cases: ```js function doThingySafely() { return doThingy().finally(cleanup); } // vs. async function doThingySafely() { try { return await doThingy(); } finally { return cleanup(); } } ``` ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss