My parent class is structured as follows:
class SomeClass {
public someProperty: number | undefined;
constructor(value: number) {
this.someProperty = value;
}
public on(eventType: string, fn: Function) {
}
}
class Parent {
protected static getTransform(value: number) {
return value + 180;
}
public transform: SomeClass;
constructor(value: number) {
this.transform = this.createTransform(value);
}
protected createTransform(value: number) {
const transform = new SomeClass(value);
transform.on('rotate', this.rotate);
return transform;
}
protected rotate(event: any) {
this.transform.someProperty = Parent.getTransform(event.transform);
}
}
To implement a child class with different logic for the transform property calculation, I have the following code snippet in mind:
class Child extends Parent {
protected static getTransform(value: number) {
return value + 90;
}
constructor(value: number) {
super(value);
}
}
Despite no errors, my implemented approach does not seem to work as expected. How can I achieve the desired outcome? Playground