fix error callbacks not being stored

This commit is contained in:
Jacob Nguyen
2023-09-09 01:08:56 -05:00
parent cafca503f9
commit 374a12bb92
2 changed files with 8 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ import { CoreModuleStore } from '../contracts';
* For interacting with modules, use the ModuleManager instead.
*/
export class ModuleStore implements CoreModuleStore {
onError = new WeakMap<Module, Function>();
metadata = new WeakMap<Module, CommandMeta>();
commands = new Map<string, string>();
}

View File

@@ -11,6 +11,13 @@ import { CommandType } from '../enums';
export class DefaultModuleManager implements ModuleManager {
constructor(private moduleStore: CoreModuleStore) {}
getErrorCallback(m: Module): Function | undefined {
return this.moduleStore.onError.get(m);
}
setErrorCallback(m: Module, c: Function): void {
this.moduleStore.onError.set(m, c);
}
getByNameCommandType<T extends CommandType>(name: string, commandType: T) {
const id = this.get(Id.create(name, commandType));
if (!id) {