diff options
author | Kristóf Marussy <kristof@marussy.com> | 2022-08-25 00:14:51 +0200 |
---|---|---|
committer | Kristóf Marussy <kristof@marussy.com> | 2022-08-25 00:14:51 +0200 |
commit | 71491e03468795404751d2edfe58ce78714a5ed1 (patch) | |
tree | 14131145cdd704b606f3677e61981be6ab921241 /subprojects/frontend/src/utils/Timer.ts | |
parent | fix(frontend): editor font thickness (diff) | |
download | refinery-71491e03468795404751d2edfe58ce78714a5ed1.tar.gz refinery-71491e03468795404751d2edfe58ce78714a5ed1.tar.zst refinery-71491e03468795404751d2edfe58ce78714a5ed1.zip |
refactor(frontend): xtext update improvements
Diffstat (limited to 'subprojects/frontend/src/utils/Timer.ts')
-rw-r--r-- | subprojects/frontend/src/utils/Timer.ts | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/subprojects/frontend/src/utils/Timer.ts b/subprojects/frontend/src/utils/Timer.ts index 14e9eb81..4bb1bb9c 100644 --- a/subprojects/frontend/src/utils/Timer.ts +++ b/subprojects/frontend/src/utils/Timer.ts | |||
@@ -1,33 +1,33 @@ | |||
1 | export default class Timer { | 1 | export default class Timer { |
2 | readonly callback: () => void; | 2 | private readonly callback: () => void; |
3 | 3 | ||
4 | readonly defaultTimeout: number; | 4 | private readonly defaultTimeout: number; |
5 | 5 | ||
6 | timeout: number | null = null; | 6 | private timeout: number | undefined; |
7 | 7 | ||
8 | constructor(callback: () => void, defaultTimeout = 0) { | 8 | constructor(callback: () => void, defaultTimeout = 0) { |
9 | this.callback = () => { | 9 | this.callback = () => { |
10 | this.timeout = null; | 10 | this.timeout = undefined; |
11 | callback(); | 11 | callback(); |
12 | }; | 12 | }; |
13 | this.defaultTimeout = defaultTimeout; | 13 | this.defaultTimeout = defaultTimeout; |
14 | } | 14 | } |
15 | 15 | ||
16 | schedule(timeout: number | null = null): void { | 16 | schedule(timeout?: number | undefined): void { |
17 | if (this.timeout === null) { | 17 | if (this.timeout === undefined) { |
18 | this.timeout = setTimeout(this.callback, timeout || this.defaultTimeout); | 18 | this.timeout = setTimeout(this.callback, timeout ?? this.defaultTimeout); |
19 | } | 19 | } |
20 | } | 20 | } |
21 | 21 | ||
22 | reschedule(timeout: number | null = null): void { | 22 | reschedule(timeout?: number | undefined): void { |
23 | this.cancel(); | 23 | this.cancel(); |
24 | this.schedule(timeout); | 24 | this.schedule(timeout); |
25 | } | 25 | } |
26 | 26 | ||
27 | cancel(): void { | 27 | cancel(): void { |
28 | if (this.timeout !== null) { | 28 | if (this.timeout !== undefined) { |
29 | clearTimeout(this.timeout); | 29 | clearTimeout(this.timeout); |
30 | this.timeout = null; | 30 | this.timeout = undefined; |
31 | } | 31 | } |
32 | } | 32 | } |
33 | } | 33 | } |