This commit is contained in:
zadam
2020-01-18 18:01:16 +01:00
parent b25c1d6fa8
commit b00a9f4415
12 changed files with 91 additions and 102 deletions

View File

@@ -1,16 +1,22 @@
export default class Component {
/** @param {AppContext} appContext */
constructor(appContext) {
this.componentId = `component-${this.constructor.name}`;
this.appContext = appContext;
/** @type Component[] */
this.children = [];
this.initialized = Promise.resolve();
}
eventReceived(name, data) {
async eventReceived(name, data) {
await this.initialized;
console.log(`Received ${name} to ${this.componentId}`);
const fun = this[name + 'Listener'];
if (typeof fun === 'function') {
fun.call(this, data);
await fun.call(this, data);
}
for (const child of this.children) {