From bf5fece16b7e93cabe775cd12e50152d2cea2f0b Mon Sep 17 00:00:00 2001 From: liujuping Date: Thu, 9 Feb 2023 15:27:27 +0800 Subject: [PATCH] feat: fix poroject.onSimulatorHostReady in workspace mode --- packages/designer/src/project/project.ts | 4 ++++ packages/shell/src/api/project.ts | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/designer/src/project/project.ts b/packages/designer/src/project/project.ts index 082554846..b5a553627 100644 --- a/packages/designer/src/project/project.ts +++ b/packages/designer/src/project/project.ts @@ -369,6 +369,10 @@ export class Project implements IProject { } onSimulatorReady(fn: (args: any) => void): () => void { + if (this._simulator) { + fn(this._simulator); + return () => {}; + } this.emitter.on('lowcode_engine_simulator_ready', fn); return () => { this.emitter.removeListener('lowcode_engine_simulator_ready', fn); diff --git a/packages/shell/src/api/project.ts b/packages/shell/src/api/project.ts index 04feb81f3..a409cbcd5 100644 --- a/packages/shell/src/api/project.ts +++ b/packages/shell/src/api/project.ts @@ -192,12 +192,8 @@ export class Project implements IPublicApiProject { */ onSimulatorHostReady(fn: (host: IPublicApiSimulatorHost) => void): IPublicTypeDisposable { const offFn = this[projectSymbol].onSimulatorReady((simulator: BuiltinSimulatorHost) => { - this[simulatorHostSymbol] = simulator; fn(SimulatorHost.create(simulator)!); }); - if (this[simulatorHostSymbol]) { - fn(SimulatorHost.create(this[simulatorHostSymbol])!); - } return offFn; }