I have multiple classes with a hierarchical inheritance structure as follows:
- class A (an abstract class)
- class B extends A
- class C extends B
I am looking to incorporate a service into class A to enable a function that utilizes notifications. How can I achieve this without directly adding the service to the subclasses?
My approach is somewhat similar to the example below, but I aim to find a way to avoid importing the service in the subclasses:
export class abstract A {
constructor(protected service: NewService) {}
}
export class B extends A {
constructor(protected service: NewService) {
super();
}
}
export class C extends B {
constructor(protected service: NewService) {
super();
}
}