diff options
author | 2022-08-25 00:14:51 +0200 | |
---|---|---|
committer | 2022-08-25 00:14:51 +0200 | |
commit | 71491e03468795404751d2edfe58ce78714a5ed1 (patch) | |
tree | 14131145cdd704b606f3677e61981be6ab921241 /subprojects/frontend/src/utils/ConditionVariable.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/ConditionVariable.ts')
-rw-r--r-- | subprojects/frontend/src/utils/ConditionVariable.ts | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/subprojects/frontend/src/utils/ConditionVariable.ts b/subprojects/frontend/src/utils/ConditionVariable.ts index c8fae9e8..1d3431f7 100644 --- a/subprojects/frontend/src/utils/ConditionVariable.ts +++ b/subprojects/frontend/src/utils/ConditionVariable.ts | |||
@@ -6,22 +6,22 @@ const log = getLogger('utils.ConditionVariable'); | |||
6 | export type Condition = () => boolean; | 6 | export type Condition = () => boolean; |
7 | 7 | ||
8 | export default class ConditionVariable { | 8 | export default class ConditionVariable { |
9 | condition: Condition; | 9 | private readonly condition: Condition; |
10 | 10 | ||
11 | defaultTimeout: number; | 11 | private readonly defaultTimeout: number; |
12 | 12 | ||
13 | listeners: PendingTask<void>[] = []; | 13 | private listeners: PendingTask<void>[] = []; |
14 | 14 | ||
15 | constructor(condition: Condition, defaultTimeout = 0) { | 15 | constructor(condition: Condition, defaultTimeout = 0) { |
16 | this.condition = condition; | 16 | this.condition = condition; |
17 | this.defaultTimeout = defaultTimeout; | 17 | this.defaultTimeout = defaultTimeout; |
18 | } | 18 | } |
19 | 19 | ||
20 | async waitFor(timeoutMs: number | null = null): Promise<void> { | 20 | async waitFor(timeoutMs?: number | undefined): Promise<void> { |
21 | if (this.condition()) { | 21 | if (this.condition()) { |
22 | return; | 22 | return; |
23 | } | 23 | } |
24 | const timeoutOrDefault = timeoutMs || this.defaultTimeout; | 24 | const timeoutOrDefault = timeoutMs ?? this.defaultTimeout; |
25 | let nowMs = Date.now(); | 25 | let nowMs = Date.now(); |
26 | const endMs = nowMs + timeoutOrDefault; | 26 | const endMs = nowMs + timeoutOrDefault; |
27 | while (!this.condition() && nowMs < endMs) { | 27 | while (!this.condition() && nowMs < endMs) { |