Re: Re: Async Class

2018-02-15 Thread Dimitrian Nine
"Is an async factory function/method not sufficient to do this?"

Maybe, but i think it question similiar to "factory vs class":
we can use Сlass now, but why not to extend it to Async then?

"Also, note that you can return promises out of the constructor (and I've
done it before)"

Like callback? Maybe, but again it simillial to "await vs callback" then.

I just like Class,Async and Await patterns.
And think:this some sugar can be useful for some people like me...
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Re: Async Class

2018-02-16 Thread Dimitrian Nine
 "It gets ugly(ier) when you want to extend that. :-) "

Ok, i get it, but yes i prefer some more sugar like as i suggested before.
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Async Class

2018-02-15 Thread Dimitrian Nine
I cant find: was or not that proposal...

But can we have Async Class with async constructor and async super?

//AsyncClass
async_class AsyncClass { // keyword async_class(example)
constructor() {
await something(); //now constructor async too
}}

//AsyncObj in some async method
let NewAsyncObj = await AsyncClass(); // create async obj

//Extends
async_class ExtAsyncClass extends AsyncClass{
constructor() {
await super(); // now we can await super too
await something();
}}
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Re: Async Class

2018-02-16 Thread Dimitrian Nine
 "You can just call an async method from the constructor (without await) -
and then let that async method handle all the asynchronicity."

Not sure about it - how control? callback?
I prefer async/await then.

"I think async constructor would make more sense than async class"

Maybe: i use it for class more for difference between class and async class
was more visible.
But yes in total idea about async constructor.
Both variants work for me.
What more useful - i dont sure...
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Re: Async Class

2018-02-22 Thread Dimitrian Nine
"why a static factory"

And more notes:
"return img" - this is cut version
In my example you get obj - not image.

And my sample was simple.
I hope not so long left to class private var + decorators

And sample can be then more complex with it:

async class Class{
@some_decorator
static private method(){}
static var = some_var
}

and have not onle one Extends
Class
ExtClass
ExtExtClass

Maybe i try to force events, but time never waits...
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Re: Async Class

2018-02-18 Thread Dimitrian Nine
 "I think awaitNew MyObject() would fit the thrust of your idea more"

For me more good my first version... async class = return Promise(obj)
But i can agree with others decisions, if in the end i get: easy way to
async new

Some people ask me for some more interesting sample...
Maybe it can help - try create:
```js
//some module
async class FilterImg{
constructor(path,filters){
this.img = await load(path);
if (filters) {await this.use_filters(filters);}
}}
async use_filters(filters){
await filter1(this.image);
await filter2(this.image);
}}//class
export default FilterImg;
//end module

void async finction(){
let FilterImg = (await import(url)).default;
async class ExtFilterImg extends FilterImg{
constructor(path,filters){
await super(path);
if (filters) {await this.use_extFilters(filters);}
}}//class

let extFilter_img = await new FilterImg(path,filters);
console.log(extFilter_img.src+' '+extFilter_img.filters);
}();
```
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Re: Async Class

2018-02-18 Thread Dimitrian Nine
"new MyObject() would return a promise "

I have one idea about it, but not sure good or not...

async class and then newAsync

Maybe this way more good for someone...
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Re: Async Class

2018-02-18 Thread Dimitrian Nine
 "Long story short, introducing this feature would slow down new/
Reflect.construct"
"since this might suggest it returning a Promise, which it mustn't "

Can it help: if async class constructor will be return Promise(obj) and i
suggest before use newAsync for that practice?

Slow... but how much?
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Re: Async Class

2018-02-19 Thread Dimitrian Nine
"why a static factory"

I answered earlier:
<>

Yes, you can, but for me more easy to work with classes.
And i just want to extend the functionality for work with async - that all.
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Re: Async Class

2018-02-19 Thread Dimitrian Nine
"ES classes are about 90% sugar"
"ES classes aren't like traditional classes"

Yes and i just want to more sugar for them - just simple.
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Re: Async Class

2018-02-24 Thread Dimitrian Nine
```js
class Test{
constructor(){}
async init(){}
static async newA(){
let obj = new Test(); obj.init(); return obj
}}
let t = Test.newA();

class ExtTest extends Test(){
constructor(){
super(); // we cant init here
//now we must recreate new/init for ExtTest too
}}
```
Or with my proposal we can easily do all async operation in constructor
```js
async class Test{
constructor(){
}}
async class ExtTest extends Test(){
constructor(){
await super();
}}
```
Definition for async class = that async create and return Promise(obj)
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Re: Async Class

2018-02-25 Thread 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


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 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


Re: Re: Async Class

2019-08-27 Thread Dimitrian Nine
 Claude Pache
> class consists not only of its constructor
How i see it - seems all think that my idea not bad, but we have semantic
hell.
My thougth was Class is wrapper for constructor object
And Async Class is same wrapper for constructor Promise of object

kai zhu
>class-factories are good enough

For all? Not for me - i want more clean and native methods.
> if the below Browser/Page classes were also "async"

And way you described - try to Extends Browser Class. How you do that?
I think my wrapper more easy and simple.
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Symbols and SymbolAt

2019-09-08 Thread Dimitrian Nine
Maybe i don't know something, but want to proposal idea:
We have emojis and other symbols, that have many codepoints
And 'emoji'.length > 1
My idea that we have something like
'emoji'.symbols - and get array of symbols, where symbol is array of
codepoints
And maybe method SymbolAt
'emoji'.SymobolAt(0) = array of codepoints

Examples:
'123456emoji789'.symbols.length = 10
'123456emoji789'.SymbolAt(6) = codepoints of emoji
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Symbols and SymbolAt

2019-09-08 Thread Dimitrian Nine
Thanks i found same ideas here:

https://esdiscuss.org/topic/string-prototype-symbolat-improved-string-prototype-charat
https://esdiscuss.org/topic/working-with-grapheme-clusters

But topics was created - 6 years ago... And no news for working on it?
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Re: Async Class

2020-02-12 Thread Dimitrian Nine
Update: [now we have proposal 1 stage][1]
[1]:  https://github.com/bmeck/proposal-async-init/issues/1
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss