Skip to content

Commit

Permalink
chore: update code
Browse files Browse the repository at this point in the history
  • Loading branch information
bytemain committed Dec 5, 2023
1 parent 2a5df3d commit 2201f13
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/helper/hook-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,8 @@ function runOneHook<
if (hook.awaitPromise) {
promise = promise || Promise.resolve();
promise = promise.then(() => {
// notice: here we return hook's result, and the return statement on the next will return undefined.
// notice: here we return hook's result
// and the return statement on the next condition branch will return undefined.
return hook.hook(joinPoint);
});
} else if (promise) {
Expand Down
6 changes: 3 additions & 3 deletions src/injector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,19 +386,19 @@ export class Injector {
return instance;
};

const preprocessedHooks: IValidAspectHook[] = hookMetadata.map((metadata) => {
const preprocessedHooks = hookMetadata.map((metadata) => {
const wrapped = (...args: any[]) => {
const instance = getInstance();
return instance[metadata.prop].call(instance, ...args);
};
return {
awaitPromise: metadata.options.await,
priority: metadata.options.priority || 0,
priority: metadata.options.priority,
hook: wrapped,
method: metadata.targetMethod,
target: metadata.target,
type: metadata.type,
};
} as IValidAspectHook;
});
toDispose = this.hookStore.createHooks(preprocessedHooks);
}
Expand Down

0 comments on commit 2201f13

Please sign in to comment.