Skip to content

Commit 08f7e38

Browse files
joaomariolagojoaoantoniocardoso
authored andcommitted
core:frontend:helper: Remove callPeriodically
* Remove callPeriodycally and stopCallPeriodically to prefer using of OneMoreTime when intervals are needed
1 parent f27c983 commit 08f7e38

File tree

1 file changed

+0
-35
lines changed

1 file changed

+0
-35
lines changed

core/frontend/src/utils/helper_functions.ts

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,41 +7,6 @@ export function sleep(interval: number): Promise<number> {
77
return new Promise((resolve) => setTimeout(resolve, interval))
88
}
99

10-
const periodic_tasks_counter: Map<() => Promise<void>, number> = new Map()
11-
12-
/* Call a given function periodically for a given interval. */
13-
/**
14-
* @param func - Function to be called.
15-
* @param interval - Time in milliseconds to wait after the previous request is done
16-
* */
17-
export async function callPeriodically(
18-
func: () => Promise<void>,
19-
interval: number,
20-
automated_call?: boolean,
21-
): Promise<void> {
22-
let current_count = periodic_tasks_counter.get(func) ?? 0
23-
if (!automated_call) {
24-
current_count += 1
25-
periodic_tasks_counter.set(func, current_count)
26-
}
27-
if (current_count <= 0) {
28-
periodic_tasks_counter.set(func, 0)
29-
return
30-
}
31-
await func()
32-
await sleep(interval)
33-
callPeriodically(func, interval, true)
34-
}
35-
36-
/* Stop Callingg a given function periodically. */
37-
/**
38-
* @param function_name - Function to be called.
39-
* */
40-
export function stopCallingPeriodically(func: () => Promise<void>): void {
41-
const current_count = periodic_tasks_counter.get(func) ?? 1
42-
periodic_tasks_counter.set(func, current_count - 1)
43-
}
44-
4510
/* Cast a string into a proper javascript type. */
4611
/**
4712
* @param value - String to be cast

0 commit comments

Comments
 (0)