Async Class

Naveen Chawla naveen.chwl at gmail.com
Sun Feb 18 09:07:03 UTC 2018


There is no rule that says you must propagate every promise.
`initializeAsync` doesn't return anything, so the constructor just kicks
off the async process.

On Sun, 18 Feb 2018, 2:02 pm T.J. Crowder, <tj.crowder at farsightsoftware.com>
wrote:

> On Sun, Feb 18, 2018 at 8:27 AM, Naveen Chawla <naveen.chwl at gmail.com>
> wrote:
> >
> > Like this:
> >
> > ```js
> > class MyObject{
> >     constructor(){
> >         initializeAsync();
> >     }
> >
> >     async initializeAsync(){
> >         await doSomething();
> >         await doSomethingElse();
> >         //etc.
> >     }
> > }
> > ```
>
> That constructor breaks one of the main rules of promises: Either handle
> the rejection, or propagate the promise.
>
> -- T.J. Crowder
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20180218/7ca6c918/attachment.html>


More information about the es-discuss mailing list