From 5e975438acea89c11c80bab1bc92d71d42c745eb Mon Sep 17 00:00:00 2001 From: akitaSummer Date: Sat, 14 Sep 2024 17:18:21 +0800 Subject: [PATCH] fix: fix this --- core/metadata/src/factory/LoadUnitFactory.ts | 24 ++++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/core/metadata/src/factory/LoadUnitFactory.ts b/core/metadata/src/factory/LoadUnitFactory.ts index 710a65d3..50dbe560 100644 --- a/core/metadata/src/factory/LoadUnitFactory.ts +++ b/core/metadata/src/factory/LoadUnitFactory.ts @@ -15,7 +15,7 @@ export class LoadUnitFactory { private static loadUnitIdMap: Map = new Map(); protected static async getLoanUnit(ctx: LoadUnitLifecycleContext, type: EggLoadUnitTypeLike) { - const creator = this.loadUnitCreatorMap.get(type); + const creator = LoadUnitFactory.loadUnitCreatorMap.get(type); if (!creator) { throw new Error(`not find creator for load unit type ${type}`); } @@ -23,21 +23,21 @@ export class LoadUnitFactory { } static async createLoadUnit(unitPath: string, type: EggLoadUnitTypeLike, loader: Loader): Promise { - if (this.loadUnitMap.has(unitPath)) { - return this.loadUnitMap.get(unitPath)!.loadUnit; + if (LoadUnitFactory.loadUnitMap.has(unitPath)) { + return LoadUnitFactory.loadUnitMap.get(unitPath)!.loadUnit; } const ctx: LoadUnitLifecycleContext = { unitPath, loader, }; - const loadUnit = await this.getLoanUnit(ctx, type); + const loadUnit = await LoadUnitFactory.getLoanUnit(ctx, type); await LoadUnitLifecycleUtil.objectPreCreate(ctx, loadUnit); if (loadUnit.init) { await loadUnit.init(ctx); } await LoadUnitLifecycleUtil.objectPostCreate(ctx, loadUnit); - this.loadUnitMap.set(unitPath, { loadUnit, ctx }); - this.loadUnitIdMap.set(loadUnit.id, loadUnit); + LoadUnitFactory.loadUnitMap.set(unitPath, { loadUnit, ctx }); + LoadUnitFactory.loadUnitIdMap.set(loadUnit.id, loadUnit); return loadUnit; } @@ -46,28 +46,28 @@ export class LoadUnitFactory { unitPath, loader, }; - return await this.getLoanUnit(ctx, type); + return await LoadUnitFactory.getLoanUnit(ctx, type); } static async destroyLoadUnit(loadUnit: LoadUnit) { - const { ctx } = this.loadUnitMap.get(loadUnit.unitPath)!; + const { ctx } = LoadUnitFactory.loadUnitMap.get(loadUnit.unitPath)!; try { await LoadUnitLifecycleUtil.objectPreDestroy(ctx, loadUnit); if (loadUnit.destroy) { await loadUnit.destroy(ctx); } } finally { - this.loadUnitMap.delete(loadUnit.unitPath); - this.loadUnitIdMap.delete(loadUnit.id); + LoadUnitFactory.loadUnitMap.delete(loadUnit.unitPath); + LoadUnitFactory.loadUnitIdMap.delete(loadUnit.id); LoadUnitLifecycleUtil.clearObjectLifecycle(loadUnit); } } static getLoadUnitById(id: Id): LoadUnit | undefined { - return this.loadUnitIdMap.get(id); + return LoadUnitFactory.loadUnitIdMap.get(id); } static registerLoadUnitCreator(type: EggLoadUnitTypeLike, creator: LoadUnitCreator) { - this.loadUnitCreatorMap.set(type, creator); + LoadUnitFactory.loadUnitCreatorMap.set(type, creator); } }