Skip to content

Commit c25859c

Browse files
committed
client/debouncer: report pending updates before destroying
1 parent 79dc5e4 commit c25859c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

apps/client/src/utils/debouncer.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@ export default class Debouncer<T> {
1414

1515
updateValue(value: T) {
1616
this.lastValue = value;
17-
this.destroy();
17+
if (this.timeoutId !== null) {
18+
clearTimeout(this.timeoutId);
19+
}
1820
this.timeoutId = setTimeout(this.reportUpdate.bind(this), this.debounceInterval);
1921
}
2022

2123
destroy() {
2224
if (this.timeoutId !== null) {
25+
this.reportUpdate();
2326
clearTimeout(this.timeoutId);
2427
}
2528
}

0 commit comments

Comments
 (0)