client/debouncer: report pending updates before destroying
Some checks are pending
Checks / main (push) Waiting to run

This commit is contained in:
Adorian Doran 2025-11-19 00:57:45 +02:00
parent 79dc5e4344
commit c25859cee9

View File

@ -14,12 +14,15 @@ export default class Debouncer<T> {
updateValue(value: T) { updateValue(value: T) {
this.lastValue = value; this.lastValue = value;
this.destroy(); if (this.timeoutId !== null) {
clearTimeout(this.timeoutId);
}
this.timeoutId = setTimeout(this.reportUpdate.bind(this), this.debounceInterval); this.timeoutId = setTimeout(this.reportUpdate.bind(this), this.debounceInterval);
} }
destroy() { destroy() {
if (this.timeoutId !== null) { if (this.timeoutId !== null) {
this.reportUpdate();
clearTimeout(this.timeoutId); clearTimeout(this.timeoutId);
} }
} }