File size: 695 Bytes
09a6f7f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import Store from '../store/store.js';
/**
* @classdesc Abstract class for UI components.
*/
export default class Component {
/**
* @constructor
* @param props {{store: Store, element: HTMLElement, eventName: string}}
*/
constructor(props = {}) {
this.render = this.render || function () { };
// Adds props.eventName with this.render() as callback function to the list of events handled by the UI state manager
if (props.store instanceof Store) {
props.store.events.subscribe(props.eventName, () => this.render());
}
if (props.hasOwnProperty('element')) {
this.element = props.element;
}
}
} |