Re: Re: Async Class

2019-08-26 Thread Dimitrian Nine
 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 :

> >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
>
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Re: Async Class

2019-08-26 Thread Dimitrian Nine
 >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
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Re: Async Class

2019-08-26 Thread Isiah Meadows
Not a bad idea, but I'd *strongly* prefer the promise to be returned
from `new AsyncClass(...)` itself instead. And down that vein, `super`
with async classes should also implicitly `await` in its `super` call,
setting `this` to the value itself. For sanity reasons, `super` should
return a promise resolved with the set `this`, so you can still use it
and await it in inner arrow functions (it's possible), but it should
still do its own implicit awaiting, just so you can add properties to
the right instance. (This will also come into play with private
properties - you want those on the *instance*, not the *promise*.)

I do have a preference: `async` should decorate the `constructor`, not
the `class`. It's not the class that's async, it's the constructor
itself. You can still have sync methods elsewhere in the class, and
this doesn't do anything to affect that, hence why I'd prefer an
`async constructor(...) { ... }` instead of an `async class`.

-

Isiah Meadows
cont...@isiahmeadows.com
www.isiahmeadows.com

On Mon, Aug 26, 2019 at 11:11 AM Dimitrian Nine
 wrote:
>
> 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 :
>>
>> ([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(); ```
>
> ___
> 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


Re: Re: Async Class

2019-08-26 Thread Dimitrian Nine
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 :

> ([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(); ```
>
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss