Simplifies overriding class methods by allowing methods from another class to be used as overrides. Overrides are defined as own classes. They must at a minimum contain a static getter named targetClass, which should return the class to override.
So you don't need that extends Override in the class definition.
Yes you're right, I don't need the extends.
I tried it without the extends Override - I still cannot create an Override for a function of another override.
Here is the setup I tried for the advanced example:
class TextFieldOverride {
static get target(){
return {
class: TextField,
};
}
construct(config) {
if (this.type === TextField.type) {
config.clearable = true;
}
this._overridden.construct.call(this, config);
}
}
class CustomerTextFieldOverride {
static get target(){
return {
class: TextFieldOverride,
};
}
construct(config) {
if (this.type === TextField.type) {
config.cls = 'custom-cls';
}
this._overridden.construct.call(this, config);
}
}
Override.apply(TextFieldOverride);
Override.apply(CustomerTextFieldOverride);
You can use the code posted above in the advanced example - just add TextField and Override to the import and it should work.
My expectation in that case would be, that every textfield has the clearable enabled by default as well as the defined class in the DOM.
Why then don't combine all in one and use one instead of two?
We use Override to customize the default behavior. So far (with the ExtJS Version) we also use it to deploy patches (hotfixes) on systems until the app can be redeployed.
By definition we cannot put both in the same file - if we'd known before rollout, we wouldn't have to deploy a fix