I'd prefer a "new Promise" literal analogous to {} for objects and '' for strings:
```js p\ resolve=> setTimeout( resolve, forHowLong) \ ``` I think the "this.resolve" proposal wouldn't work for methods, for example. On Thu, 12 Apr 2018 at 23:25 Michał Wadas <michalwa...@gmail.com> wrote: > Is it codyfing of glorious The Deferred anti-pattern? > https://github.com/petkaantonov/bluebird/wiki/Promise-Anti-patterns#the-deferred-anti-pattern > > On Thu, Apr 12, 2018 at 6:07 PM, Luiz Felipe Frazão Gonçalves < > luizfelipefrazaogoncal...@gmail.com> wrote: > >> *One new proposal for EcmaScript.* >> Promised Functions >> >> Like async/await, the promised functions would be preceded by a keyword. >> In the case, promised, it would change the default behavior of the >> function, making it behave as a promise. >> >> I will use as an example a classic sleep function: >> >> function sleep(forHowLong) { >> return new Promise((resolve, reject) => { >> setTimeout(function() { >> resolve(); >> >> /** * For reject: * * reject(Error('Some error')); >> */ >> }, forHowLong); >> }); >> } >> >> I think to avoid the huge amount of callbacks, there should be a syntax >> similar to this: >> >> promised function sleep(forHowLong) { >> setTimeout(function() { >> this.resolve(); // could even create a keyword like "resolve" >> >> /** * For reject: * * this.reject(Error('Some error')); >> */ >> }, forHowLong); >> } >> >> Note that the hypothetical keyword "promised" before the function >> statement makes it act as a promise. >> >> Just a crazy idea I had. :) >> >> _______________________________________________ >> 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 >
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss