Skip to content

Commit

Permalink
style
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoobes committed Jan 4, 2024
1 parent 18a420a commit 5004385
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/core/ioc/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ export class CoreContainer<T extends Partial<Dependencies>> extends Container<T,
assert.ok(!this.isReady(), 'Listening for dispose & init should occur prior to sern being ready.');

const { unsubscribe } = Hooks.createInitListener(this);

this.ready$
.subscribe({ complete: unsubscribe });

(this as Container<{}, {}>)
.add({ '@sern/errors': () => new DefaultServices.DefaultErrorHandling(),
.add({ '@sern/errors': () => new DefaultServices.DefaultErrorHandling,
'@sern/emitter': () => new SernEmitter,
'@sern/store': () => new ModuleStore })
.add(ctx => {
Expand All @@ -46,6 +47,9 @@ export class CoreContainer<T extends Partial<Dependencies>> extends Container<T,
}
await super.disposeAll();
}



ready() {
this.ready$.complete();
this.ready$.unsubscribe();
Expand Down
2 changes: 1 addition & 1 deletion src/core/ioc/dependency-injection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function Services<const T extends (keyof Dependencies)[]>(...keys: [...T]
}

/**
* Given the user's conf, check for any excluded dependency keys.
* Given the user's conf, check for any excluded/included dependency keys.
* Then, call conf.build to get the rest of the users' dependencies.
* Finally, update the containerSubject with the new container state
* @param conf
Expand Down
3 changes: 2 additions & 1 deletion src/core/ioc/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type HookName = 'init';
export const createInitListener = (coreContainer : CoreContainer<any>) => {
const initCalled = new Set<PropertyKey>();
const hasCallableMethod = createPredicate(initCalled);
const unsubscribe = coreContainer.on('containerUpserted', async (event) => {
const unsubscribe = coreContainer.on('containerUpserted', async event => {

if(isNotHookable(event)) {
return;
Expand All @@ -21,6 +21,7 @@ export const createInitListener = (coreContainer : CoreContainer<any>) => {
}

});

return { unsubscribe };
}

Expand Down

0 comments on commit 5004385

Please sign in to comment.