Async Class

Dimitrian Nine dimtimeforever at gmail.com
Mon Aug 26 15:11:37 UTC 2019


Ok so much time has passed. I have learned more js. And created some
[wrapper][1] for my idea:
Class is just function constructor that return object
Async Class is async function constructor that returns promise object.
Wrapper code:
```js
class PromiseClass { //promisified class
static async new(obj){ return obj;}
constructor() {return PromiseClass.new(this); }//new
}//class
class AsyncClass extends PromiseClass{ // can ext Class|PromiseClass
static async new(obj){return await obj();}
constructor(){return AsyncClass.new(async()=>{await super(); return
this});}//new
}//AsyncClass
```
And we work with Async Class like we work with functions. I dont see here
some differents to use them. Code without wrapper be clean:
```js
async class PromiseClass { //return Promise
constructor() {}//async()=>Promise object
}//class
async class AsyncClass extends PromiseClass{ // can ext Class|PromiseClass
constructor(){ await super();} //async()=>Promise object
}//AsyncClass
```
[1]:https://repl.it/repls/InsubstantialPortlyCores
вс, 25 февр. 2018 г. в 11:47, Dimitrian Nine <dimtimeforever at gmail.com>:

> ([Classes][1]):
> [1]:
> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes
> «JavaScript classes, introduced in ECMAScript 2015, are primarily
> syntactical sugar over JavaScript's existing prototype-based inheritance.
> The class syntax does not introduce a new object-oriented inheritance model
> to JavaScript»
> «Classes are in fact "special functions"»
>
> ```js class = function Create(); ```
> all i want:
> ``` js async class = async function Create(); ```
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20190826/90ccf7bf/attachment.html>


More information about the es-discuss mailing list