class Control {
#position = 0;
on(eventName, listener) {
if (typeof this['on' + eventName] !== 'function') {
throw new Error('Event "' + eventName + '" not exists');
}
this.addEventListener(eventName, listener);
}
fire(eventName) {
let event = new CustomEvent(eventName, {detail: this});
return this.dispatchEvent(event);
}
onmove() {
this.#position += 10;
return this.fire('move'));
}
}