summaryrefslogtreecommitdiffhomepage
path: root/gui/src/shared/scheduler.ts
blob: 103fe9b58487c7af188362566419d7a7c2b2c56d (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 = 0) {
    this.cancel();
    this.timer = global.setTimeout(action, delay);
  }

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