proposal-async-init icon indicating copy to clipboard operation
proposal-async-init copied to clipboard

Fourth path, backward compatible

Open baybal opened this issue 4 years ago • 1 comments

class Query {
  constructor(data) {
    this.data = data;
  }
  async then () {
    this.somenewdata = await someAsyncFunc();
    return this;
  }
}

This way await new Query({data: 'helloworld'}) keeps the constructor synchronous, backward compatible, and keep .then working.

baybal avatar Sep 20 '20 13:09 baybal

This already works right? Thanks for the idea, I'm thinking of implementing it in a project I'm working on.

benwiley4000 avatar Oct 25 '21 17:10 benwiley4000