[IMP] component: add setup lifecycle hook

This commit is contained in:
Géry Debongnie
2020-10-30 09:33:49 +01:00
committed by aab-odoo
parent 398f9f4e53
commit 19a47a7001
5 changed files with 67 additions and 52 deletions
+12
View File
@@ -209,8 +209,20 @@ export class Component<Props extends {} = any, T extends Env = Env> {
if (constr.style) {
this.__applyStyles(constr);
}
this.setup();
}
/**
* setup is run just after the component is constructed. This is the standard
* location where the component can setup its hooks. It has some advantages
* over the constructor:
* - it can be patched (useful in odoo ecosystem)
* - it does not need to propagate the arguments to the super call
*
* Note: this method should not be called manually.
*/
setup() {}
/**
* willStart is an asynchronous hook that can be implemented to perform some
* action before the initial rendering of a component.