continuing refactoring

This commit is contained in:
zadam
2020-01-15 21:36:01 +01:00
parent f98a20928c
commit 7963de0abc
12 changed files with 138 additions and 118 deletions

View File

@@ -0,0 +1,24 @@
export default class Component {
/** @param {AppContext} appContext */
constructor(appContext) {
this.appContext = appContext;
/** @type Component[] */
this.children = [];
}
eventReceived(name, data) {
const fun = this[name + 'Listener'];
if (typeof fun === 'function') {
fun.call(this, data);
}
for (const child of this.children) {
child.eventReceived(name, data);
}
}
trigger(name, data) {
this.appContext.trigger(name, data);
}
}