diff options
Diffstat (limited to 'gui/src')
| -rw-r--r-- | gui/src/shared/scheduler.ts | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/gui/src/shared/scheduler.ts b/gui/src/shared/scheduler.ts index b31f0cda7c..8ae5a2cbf0 100644 --- a/gui/src/shared/scheduler.ts +++ b/gui/src/shared/scheduler.ts @@ -2,17 +2,28 @@ import { useEffect, useMemo } from 'react'; export class Scheduler { private timer?: NodeJS.Timeout; + private running = false; public schedule(action: () => void, delay = 0) { this.cancel(); - this.timer = global.setTimeout(action, delay); + + this.running = true; + this.timer = global.setTimeout(() => { + this.running = false; + action(); + }, delay); } public cancel() { if (this.timer) { clearTimeout(this.timer); + this.running = false; } } + + public get isRunning() { + return this.running; + } } export function useScheduler() { |
