Files
t/ts/singletimer.ts
Ian Gulliver 822a4891d0 Highlighter
2024-12-22 14:59:03 -08:00

18 lines
415 B
TypeScript

export class SingleTimer {
private callback: () => void;
private delay: number;
private timer: number | undefined;
constructor(callback: () => void, delay: number) {
this.callback = callback;
this.delay = delay;
}
public start() {
if (this.timer) {
clearTimeout(this.timer);
}
this.timer = setTimeout(this.callback, this.delay);
}
}