Let's say we have an application with a lot of lists and therefor some basic components
export class SimpleListComponent { ... }
export class ExtendedListComponent extends SimpleListComponent { ... }
... which we can easily extend. They carry all the basic functionality for our lists (e.g. switch pages, count results,...). We use those two basic components for two different lists of heroes:
export class HeroSimpleListComponent extends SimpleListComponent { ... }
export class HeroExtendedListComponent extends ExtendedListComponent { ... }
Unfortunately we still would have to duplicate a lot of our code because HeroSlimListComponent
and HeroExtendedListComponent
share a lot of their functionalites (e.g. load heroes, route to hero, ...).
My first try was to pass the class which we need to extend
export class ExtendedListComponent<T = SimpleListComponent> extends T { ... }
but that does not work. Additionally I found this post which states, that multiple inheritance is not possible within typescript. Still I have the feeling that I'm missing some basic angular component connected solution here.
Thanks in advance for your help!