Skip to content

Commit 879f4ba

Browse files
committed
refactor(project): Cleanup WatchHandler debounce
1 parent 449af24 commit 879f4ba

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

packages/project/lib/build/helpers/WatchHandler.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,26 +65,21 @@ class WatchHandler extends EventEmitter {
6565
}
6666

6767
async #fileChanged(project, filePath) {
68-
// Collect changes (grouped by project), then trigger callbacks (debounced)
68+
// Collect changes (grouped by project), then trigger callbacks
6969
const resourcePath = project.getVirtualPath(filePath);
7070
if (!this.#sourceChanges.has(project)) {
7171
this.#sourceChanges.set(project, new Set());
7272
}
7373
this.#sourceChanges.get(project).add(resourcePath);
7474

7575
// Trigger callbacks debounced
76-
if (!this.#fileChangeHandlerTimeout) {
77-
this.#fileChangeHandlerTimeout = setTimeout(async () => {
78-
await this.#handleResourceChanges();
79-
this.#fileChangeHandlerTimeout = null;
80-
}, 100);
81-
} else {
76+
if (this.#fileChangeHandlerTimeout) {
8277
clearTimeout(this.#fileChangeHandlerTimeout);
83-
this.#fileChangeHandlerTimeout = setTimeout(async () => {
84-
await this.#handleResourceChanges();
85-
this.#fileChangeHandlerTimeout = null;
86-
}, 100);
8778
}
79+
this.#fileChangeHandlerTimeout = setTimeout(async () => {
80+
await this.#handleResourceChanges();
81+
this.#fileChangeHandlerTimeout = null;
82+
}, 100);
8883
}
8984

9085
async #handleResourceChanges() {

0 commit comments

Comments
 (0)