up to speed with event modules

This commit is contained in:
Jacob Nguyen
2024-05-15 14:59:24 -05:00
parent 16a84e85d1
commit 0d82658fc5
9 changed files with 71 additions and 50 deletions

View File

@@ -4,6 +4,7 @@ import * as __Services from '../structures/default-services';
import { UnpackedDependencies } from '../../types/utility';
import type { Logging } from '../interfaces';
import { __add_container, __init_container, __swap_container, useContainerRaw } from './global';
import { EventEmitter } from 'node:events';
export function disposeAll(logger: Logging|undefined) {
useContainerRaw()
@@ -72,6 +73,7 @@ async function composeRoot(
__add_container('@sern/errors', new __Services.DefaultErrorHandling());
__add_container('@sern/cron', {})
__add_container('@sern/modules', new Map())
__add_container('@sern/emitter', new EventEmitter())
//Build the container based on the callback provided by the user
conf.build(container as Container);
@@ -97,6 +99,8 @@ export async function makeDependencies (conf: ValidDependencyConfig) {
}
__add_container('@sern/errors', new __Services.DefaultErrorHandling());
__add_container('@sern/cron', {})
__add_container('@sern/modules', new Map())
__add_container('@sern/emitter', new EventEmitter())
await useContainerRaw().ready();
} else {
await composeRoot(useContainerRaw(), conf);

View File

@@ -59,7 +59,7 @@ export async function* readRecursive(dir: string): AsyncGenerator<string> {
const files = await readdir(dir, { withFileTypes: true });
for (const file of files) {
const fullPath = path.join(dir, file.name);
const fullPath = path.posix.resolve(dir, file.name);
if (file.isDirectory()) {
if (!file.name.startsWith('!')) {
yield* readRecursive(fullPath);

View File

@@ -73,9 +73,9 @@ export function handleError<C>(crashHandler: ErrorHandling, emitter: Emitter, lo
//// Temporary until i get rxjs operators working on ts-results-es
export const filterTap = <K, R>(onErr: (e: R) => void): OperatorFunction<Result<K, R>, K> =>
concatMap(result => {
if(result.isOk()) {
return of(result.value)
}
onErr(result.error);
return EMPTY
if(result.isOk()) {
return of(result.value)
}
onErr(result.error);
return EMPTY;
})