Skip to content

Commit

Permalink
Getter cannot be spread and make execution invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrebodin committed May 9, 2022
1 parent 1db90d8 commit e7acb6c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/core/utils/lib/hooks.js
Expand Up @@ -20,17 +20,19 @@ const createHook = () => {
};

return {
get handlers() {
getHandlers() {
return state.handlers;
},

register(handler) {
state.handlers.push(handler);

return this;
},

delete(handler) {
state.handlers = remove(eq(handler), state.handlers);

return this;
},

Expand All @@ -49,7 +51,7 @@ const createAsyncSeriesHook = () => ({
...createHook(),

async call(context) {
for (const handler of this.handlers) {
for (const handler of this.getHandlers()) {
await handler(context);
}
},
Expand All @@ -66,7 +68,7 @@ const createAsyncSeriesWaterfallHook = () => ({
async call(param) {
let res = param;

for (const handler of this.handlers) {
for (const handler of this.getHandlers()) {
res = await handler(res);
}

Expand All @@ -83,7 +85,7 @@ const createAsyncParallelHook = () => ({
...createHook(),

async call(context) {
const promises = this.handlers.map(handler => handler(cloneDeep(context)));
const promises = this.getHandlers().map(handler => handler(cloneDeep(context)));

return Promise.all(promises);
},
Expand Down

0 comments on commit e7acb6c

Please sign in to comment.