Skip to content

Commit 077c41b

Browse files
committed
refactor(hooks): the facade is the injection context
Yok extends Injector on the base branch, so definitions run in runInInjectionContext(this.$injector, ...) directly and inject(Injector) inside a hook returns the facade itself.
1 parent 34ef4f2 commit 077c41b

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

lib/common/services/hooks-service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,10 +353,11 @@ export class HooksService implements IHooksService {
353353
}
354354

355355
const { context, middlewares } = createHookInvocation(hookArguments);
356-
const container = this.$injector.di;
357356

358357
try {
359-
await runInInjectionContext(container, () => definition.handler(context));
358+
await runInInjectionContext(this.$injector, () =>
359+
definition.handler(context),
360+
);
360361
} catch (err) {
361362
if (
362363
err &&

test/define-hook.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ describe("defineHook", () => {
157157

158158
await hooksService().executeBeforeHooks("case4");
159159

160-
assert.strictEqual(capture.container, (<any>testInjector).di);
160+
assert.strictEqual(capture.container, testInjector);
161161
assert.strictEqual(capture.logger, testInjector.resolve("logger"));
162162
});
163163

0 commit comments

Comments
 (0)