Async Class

Dimitrian Nine dimtimeforever at gmail.com
Tue Aug 27 04:47:00 UTC 2019


 How it says: "there is no limit to perfection" - [new wrapper][1]. Now it
works like more native:
```js

class PromiseClass {
static async new(test='test'){ this.promise= test; return this;}
constructor(...args) {
let s = async()=>PromiseClass.new.call(this,...args);
return (async r=>await s() )();
}//new
}//class
class AsyncClass extends PromiseClass{
static async new(){ return this; }
constructor(...args){
let s = async()=>{ await super(); return AsyncClass.new.call(this,...args); };
return (async r=>await s() )();
}//new
}//AsyncClass
```
[1]: https://repl.it/repls/FinancialUnknownDehardwarization


вт, 27 авг. 2019 г. в 07:42, Dimitrian Nine <dimtimeforever at gmail.com>:

> >Not a bad idea, but I'd strongly prefer the promise to be returned from
> new >AsyncClass(...) itself instead
> This about wrapper? He is just example of how functional can work right
> now.
>
> >I do have a preference: async should decorate the constructor, not the
> class
> How i say before: both variants fine for me.
> But how discussed [here][1] - not all think same.
> For me Class is just wrapper on constructor
> And Async Class is same only for async constructor.
> [1]: https://gist.github.com/goloroden/c976971e5f42c859f64be3ad7fc6f4ed
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20190827/8cee1643/attachment-0001.html>


More information about the es-discuss mailing list