summaryrefslogtreecommitdiffhomepage
path: root/gui/src/shared/scheduler.ts
blob: 902254c5671d2a47969b4951b9a0a39171844bbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
export class Scheduler {
  private timer?: NodeJS.Timeout;

  public schedule(action: () => void, delay: number) {
    this.cancel();
    this.timer = global.setTimeout(action, delay);
  }

  public cancel() {
    if (this.timer) {
      clearTimeout(this.timer);
    }
  }
}