anki/ts/editor/change-timer.ts
2021-09-15 13:33:20 +02:00

19 lines
453 B
TypeScript

// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
export class ChangeTimer {
private value: number | null = null;
schedule(action: () => void, delay: number) {
this.clear();
this.value = setTimeout(action, delay);
}
clear() {
if (this.value) {
clearTimeout(this.value);
this.value = null;
}
}
}