aboutsummaryrefslogtreecommitdiffstats
path: root/subprojects/frontend/src/utils/ConditionVariable.ts
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2022-08-25 00:14:51 +0200
committerLibravatar Kristóf Marussy <kristof@marussy.com>2022-08-25 00:14:51 +0200
commit71491e03468795404751d2edfe58ce78714a5ed1 (patch)
tree14131145cdd704b606f3677e61981be6ab921241 /subprojects/frontend/src/utils/ConditionVariable.ts
parentfix(frontend): editor font thickness (diff)
downloadrefinery-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.ts10
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');
6export type Condition = () => boolean; 6export type Condition = () => boolean;
7 7
8export default class ConditionVariable { 8export 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) {