Skip to content

Instantly share code, notes, and snippets.

@juliandescottes
Created November 30, 2018 15:44
Show Gist options
  • Save juliandescottes/5424b841f9991068cda2aeaff678e12a to your computer and use it in GitHub Desktop.
Save juliandescottes/5424b841f9991068cda2aeaff678e12a to your computer and use it in GitHub Desktop.
class Front {
async initialize() {
throw new Error("initialize Mandatory");
}
static async createFront() {
const front = new this();
await front.initialize();
return front;
}
}
class FrontA extends Front {
async initialize() {
await new Promise(r => setTimeout(r, 100));
this._prop = 42;
this._Aprop = 42;
}
}
class FrontB extends FrontA {
async initialize() {
await super.initialize();
await new Promise(r => setTimeout(r, 100));
this._prop = 43;
this._BProp = 43;
}
}
var a = await FrontA.createFront();
var b = await FrontB.createFront();
console.log(a, b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment