deep inheritance (3+ levels) and injectFromBase
decorator
#899
-
I've three or more classes with inheritance and property injection. Do i need that on all abtract classes in the hierachy or only on the last / final class? @injectable()
abstract class A {
@inject('x') x: string;
}
@injectable()
@injectFromBase() // do i need this?
abstract class B extends A {
@inject('y') y: string;
}
@injectable()
@injectFromBase()
class C extends B {
@inject('z') z: string;
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hey @viceice,
Exactly, you need to specify it in every level of the hierarchy starting with the first child class. Out of curiosity, is it painful to go this way? Tbh I could easily provide a decorator that injects from every ancestor class, but I though it makes sense to do it this way. I'm always looking for user feedback, so feel free to describe your experience. It doesn't mean I will automatically change the API as you wish, but I'll keep your opinnion in mind 🙂 |
Beta Was this translation helpful? Give feedback.
inversify@7.8.1
comes with an injectFromHierarchy decorator. I hope you like it 🙂