Re: Proposal: defer keyword

2018-09-20 Thread Ayush Gupta
ms odd given > that synchronous database operations (your example) are extremely rare and > in JavaScript. It seems to me like promises would fit this case pretty > well, but I may have missed something. > > Ben > > Le jeu. 20 sept. 2018 05 h 32, Ayush Gupta a > écrit : > &

Re: Proposal: defer keyword

2018-09-20 Thread Ayush Gupta
teresting language feature I hadn't heard of before. > > Any reason your use case couldn't be covered by a try/catch in the > synchronous case, and a promise.finally() in the async case? > > Ben > > Le jeu. 20 sept. 2018 05 h 21, Ayush Gupta a > écrit : > >> Hi, >&

Proposal: defer keyword

2018-09-20 Thread Ayush Gupta
be called no matter when/if the function returns or throws // do your work } ``` Regards Ayush Gupta ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Re: Proposal: Conditional `catch` in Promises

2018-04-25 Thread Ayush Gupta
andard kind of). >>> Node appends an `err.code`, and the DOM adds a similar type, just using a >>> common error subclass. And in some cases where errors are planned (but >>> exceptions are more convenient), you sometimes see non-errors thrown. So >>> there needs to be a

Re: Re: Proposal: Conditional `catch` in Promises

2018-04-24 Thread Ayush Gupta
We could potentially provide the same functionality in `try/catch` by extending the signature of `catch` to ```js try { } catch(, ) { } ``` If `` evaluates to truthy, invoke the `catch` block, otherwise don't. ___ es-discuss mailing list

Proposal: Conditional `catch` in Promises

2018-04-24 Thread Ayush Gupta
I propose that in `Promises`, we accept another function which returns a `boolean` as an argument to `catch`. It will enable us to write code like this: ```js return somePromise .catch((reason) => reason instanceof ValidationError, reason => handleValidationError(reason)) // handle

Re: Re: Proposal: Allow Promise callbacks to be removed

2018-04-24 Thread Ayush Gupta
In situations like this, I personally would use Event Emitters instead of promises. ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss