MCPcopy
hub / github.com/callumalpass/tasknotes / handleFileChangedDebounced

Method handleFileChangedDebounced

src/utils/TaskManager.ts:145–161  ·  view source on GitHub ↗

* Handle file changes with debouncing to prevent excessive updates

(file: TFile, cache: unknown)

Source from the content-addressed store, hash-verified

143 * Handle file changes with debouncing to prevent excessive updates
144 */
145 private handleFileChangedDebounced(file: TFile, cache: unknown): void {
146 const path = file.path;
147
148 // Cancel existing debounced handler for this file
149 const existingTimeout = this.debouncedHandlers.get(path);
150 if (existingTimeout) {
151 window.clearTimeout(existingTimeout);
152 }
153
154 // Schedule new handler
155 const timeoutId = window.setTimeout(() => {
156 this.debouncedHandlers.delete(path);
157 void this.handleFileChanged(file, cache);
158 }, this.DEBOUNCE_DELAY);
159
160 this.debouncedHandlers.set(path, timeoutId);
161 }
162
163 /**
164 * Handle file change - emit events for listeners

Callers 1

Calls 6

handleFileChangedMethod · 0.95
getMethod · 0.65
clearTimeoutMethod · 0.65
setTimeoutMethod · 0.65
deleteMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected