base class usage?
BorntraegerMarc opened this issue · 7 comments
Cool stuff, thanks a lot!
Short question: Wouldn't it work to define the annotation and the base OnDestroy method in the super class of a component? For example:
@AutoUnsubscribe()
export class BaseClass implements OnDestroy {
public ngOnDestroy(): void {
}
}
and the sub class has only:
@Component({
selector: 'child',
})
export class ChildComponent extends BaseClass {
private one: Subscription;
}
Wouldn't this work?
and then if necessary the child component could still override ngOnDestroy
to do custom stuff
Yes, it should work.
But you need to call super()
, I find this annoying.
I think it's a bit cleaner :) Thanks a lot!
ah sorry @NetanelBasal one more question: In the sub class you would still need to implement an empty ngOnDestroy
method? Or I could only extend from the BaseClass
and that's it?
It should work without implementing this in the sub class, but I would test it just to be sure.
works flawlessly :)
Awesome 💪