GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: project event listeners will not be invoked sometimes · zfhstudy/lowcode-engine@a0c772f

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/shell/src
    • project.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/shell/src/project.ts‎

Copy file name to clipboardExpand all lines: packages/shell/src/project.ts
+14-15Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -136,41 +136,40 @@ export default class Project {
136136
* 当前 project 内的 document 变更事件
137137
*/
138138
onChangeDocument(fn: (doc: DocumentModel) => void) {
139+
const offFn = this[projectSymbol].onCurrentDocumentChange((originalDoc) => {
140+
fn(DocumentModel.create(originalDoc)!);
141+
});
139142
if (this[projectSymbol].currentDocument) {
140143
fn(DocumentModel.create(this[projectSymbol].currentDocument)!);
141-
return () => {};
142144
}
143-
return this[projectSymbol].onCurrentDocumentChange((originalDoc) => {
144-
fn(DocumentModel.create(originalDoc)!);
145-
});
145+
return offFn;
146146
}
147147

148148
/**
149149
* 当前 project 的模拟器 ready 事件
150150
*/
151151
onSimulatorHostReady(fn: (host: SimulatorHost) => void) {
152-
if (this[simulatorHostSymbol]) {
153-
fn(SimulatorHost.create(this[simulatorHostSymbol])!);
154-
return () => {};
155-
}
156-
return this[projectSymbol].onSimulatorReady((simulator: BuiltinSimulatorHost) => {
152+
const offFn = this[projectSymbol].onSimulatorReady((simulator: BuiltinSimulatorHost) => {
157153
this[simulatorHostSymbol] = simulator;
158154
fn(SimulatorHost.create(simulator)!);
159155
});
156+
if (this[simulatorHostSymbol]) {
157+
fn(SimulatorHost.create(this[simulatorHostSymbol])!);
158+
}
159+
return offFn;
160160
}
161161

162162
/**
163163
* 当前 project 的渲染器 ready 事件
164164
*/
165165
onSimulatorRendererReady(fn: () => void) {
166-
if (this[simulatorRendererSymbol]) {
167-
fn();
168-
return () => {};
169-
}
170-
// TODO: 补充 renderer 实例
171-
return this[projectSymbol].onRendererReady((renderer: any) => {
166+
const offFn = this[projectSymbol].onRendererReady((renderer: any) => {
172167
this[simulatorRendererSymbol] = renderer;
173168
fn();
174169
});
170+
if (this[simulatorRendererSymbol]) {
171+
fn();
172+
}
173+
return offFn;
175174
}
176175
}

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.