feat: fix poroject.onSimulatorHostReady in workspace mode

This commit is contained in:
liujuping 2023-02-09 15:27:27 +08:00 committed by 林熠
parent f44b5aca89
commit bf5fece16b
2 changed files with 4 additions and 4 deletions

View File

@ -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);

View File

@ -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;
}