This was in the October release notes, does anyone have a simple example of how it can be used?
Inheritance of Bindables - Now you can inherit custom elements to inherit the bindable properties! This addresses the most common request for basic component inheritance scenarios.
I have come custom elements which have some bindable properties that are the same but the templates aren’t.
I assume that the constructor still needs to be handled by the subclass, like below. How about abstract superclasses, also below?
export abstract class ClassA {
@bindable amount: number;
constructor(protected additionService: AdditionService) {
}
get doubleAmount(): number {
return this.additionService.add(this.amount, this.amount);
}
}
@inject(AdditionService, MultiplyService)
@customElement("triple-amount") // Is this valid for webpack, or does PLATFORM.moduleName('./triple-amount) need to be used?
export class ClassB extends ClassA {
// additionService not marked private or protected
constructor(additionService: AdditionService,
private multiplyService: MultiplyService) {
super(additionService);
}
get tripleAmount(): number {
return this.multiplyService.multiply(this.amount, 3);
}
}
The documentation is a little light, or just not clear enough.
yes you will need to call the base constructor with any arguments it expects - its not an aurelia concept, this is typescript/es6 syntax. see super - JavaScript | MDN (mozilla.org).