feat: invokeComposed
This commit is contained in:
parent
c321637157
commit
ed77e966ca
|
@ -45,6 +45,18 @@ export default class Plugins {
|
|||
}), {});
|
||||
}
|
||||
|
||||
invokeComposed(hook, arg) {
|
||||
if (!this.hooks[hook]) {
|
||||
return arg;
|
||||
}
|
||||
const parts = hook.split('/');
|
||||
const key = parts.pop();
|
||||
const plugins = this.config[parts.join('/')][key];
|
||||
const fns = plugins
|
||||
.map((plugin) => this.hooks[hook].find(({plugin: candidate}) => plugin === candidate).fn);
|
||||
return fns.reverse().reduce((r, fn) => fn(r, this), arg);
|
||||
}
|
||||
|
||||
invokeFlat(hook, ...args) {
|
||||
if (!this.hooks[hook]) {
|
||||
return [];
|
||||
|
|
Loading…
Reference in New Issue
Block a user