mirror of
https://github.com/sern-handler/handler
synced 2026-06-06 01:16:55 +00:00
chore: update container and init hook progress
This commit is contained in:
@@ -4,6 +4,7 @@ import { isAsyncFunction} from "node:util/types";
|
||||
import * as assert from 'node:assert'
|
||||
import { Subject } from "rxjs";
|
||||
import { ModuleStore } from "./module-store";
|
||||
import { Dependencies } from "../ioc/types";
|
||||
|
||||
/**
|
||||
* Provides all the defaults for sern to function properly.
|
||||
@@ -27,9 +28,9 @@ export class CoreContainer<T extends Partial<Dependencies>> extends Container<T,
|
||||
}
|
||||
|
||||
private listenForInsertions() {
|
||||
assert.ok(this.isReady(), "listening for init functions should only occur prior to sern being ready.")
|
||||
assert.notEqual(this.isReady(), "listening for init functions should only occur prior to sern being ready.");
|
||||
const unsubscriber = this.on('containerUpserted', e => this.callInitHooks(e));
|
||||
|
||||
const unsubscriber = this.on('containerUpserted', this.callInitHooks);
|
||||
this.ready$.subscribe({
|
||||
complete: unsubscriber
|
||||
});
|
||||
@@ -39,15 +40,15 @@ export class CoreContainer<T extends Partial<Dependencies>> extends Container<T,
|
||||
|
||||
const dep = e.newContainer;
|
||||
assert.ok(dep);
|
||||
|
||||
//Ignore any dependencies that are not objects or array
|
||||
if(typeof(dep) !== 'object' || Array.isArray(dep)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if('init' in dep && typeof dep.init === 'function') {
|
||||
isAsyncFunction(dep.init)
|
||||
? await dep.init()
|
||||
: dep.init()
|
||||
: dep.init();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import { ErrorHandling } from "../../contracts";
|
||||
/**
|
||||
* @internal
|
||||
* @since 2.0.0
|
||||
* Version 4.0.0 will internalize this api. Please refrain from using ModuleStore!
|
||||
*/
|
||||
export class DefaultErrorHandling implements ErrorHandling {
|
||||
keepAlive = 5;
|
||||
|
||||
@@ -3,6 +3,7 @@ import { LogPayload, Logging } from "../../contracts";
|
||||
/**
|
||||
* @internal
|
||||
* @since 2.0.0
|
||||
* Version 4.0.0 will internalize this api. Please refrain from using ModuleStore!
|
||||
*/
|
||||
export class DefaultLogging implements Logging {
|
||||
private date = () => new Date();
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { ModuleManager } from "../../contracts";
|
||||
import { CoreModuleStore, ModuleManager } from "../../contracts";
|
||||
import { importModule } from "../../module-loading";
|
||||
import { CommandModule } from "../../types/modules";
|
||||
import { ModuleStore } from "../module-store";
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @since 2.0.0
|
||||
* @since 2.0.0/*
|
||||
* Version 4.0.0 will internalize this api. Please refrain from using ModuleStore!
|
||||
*/
|
||||
export class DefaultModuleManager implements ModuleManager {
|
||||
constructor(private moduleStore: ModuleStore) {}
|
||||
constructor(private moduleStore: CoreModuleStore) {}
|
||||
|
||||
remove(id: string): boolean {
|
||||
throw new Error('Method not implemented.');
|
||||
|
||||
Reference in New Issue
Block a user