mirror of
https://github.com/primefaces/primevue.git
synced 2025-05-08 16:37:15 +00:00
Refactor #3965 - Added hooks
keyword to control all lifecycle methods to self/global PT options
This commit is contained in:
parent
d9baf298d5
commit
3442acade4
2 changed files with 32 additions and 2 deletions
|
@ -382,10 +382,40 @@ export default {
|
|||
}
|
||||
}
|
||||
},
|
||||
beforeCreate() {
|
||||
this.pt?.hooks?.['beforeCreate']?.();
|
||||
this.$primevue?.config?.pt?.[this.$.type.name]?.hooks?.['beforeCreate']?.();
|
||||
},
|
||||
created() {
|
||||
this._hook('created');
|
||||
},
|
||||
beforeMount() {
|
||||
loadBaseStyle();
|
||||
this._hook('beforeMount');
|
||||
},
|
||||
mounted() {
|
||||
this._hook('mounted');
|
||||
},
|
||||
beforeUpdate() {
|
||||
this._hook('beforeUpdate');
|
||||
},
|
||||
updated() {
|
||||
this._hook('updated');
|
||||
},
|
||||
beforeUnmount() {
|
||||
this._hook('beforeUnmount');
|
||||
},
|
||||
unmounted() {
|
||||
this._hook('unmounted');
|
||||
},
|
||||
methods: {
|
||||
_hook(hookName) {
|
||||
const selfHook = this._getOptionValue(this.pt, `hooks.${hookName}`);
|
||||
const globalHook = this._getOptionValue(this.globalPT, `hooks.${hookName}`);
|
||||
|
||||
selfHook?.();
|
||||
globalHook?.();
|
||||
},
|
||||
_getHostInstance(instance) {
|
||||
return instance ? (this.$options.hostName ? (instance.$.type.name === this.$options.hostName ? instance : this._getHostInstance(instance.$parentInstance)) : instance.$parentInstance) : undefined;
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue