Skip to content

Commit a624f06

Browse files
committed
TS is not bad
1 parent 29ec8b7 commit a624f06

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

frontend/src/utils/usePollingEffect.tsx

+10-10
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@ import { useEffect, useRef } from 'react'
22

33
export function usePollingEffect(
44
asyncCallback: any,
5-
dependencies = [],
5+
dependencies: any[] = [],
66
{
77
interval = 3000, // 3 seconds,
8-
onCleanUp = () => {},
8+
onCleanUp = () => { },
99
} = {}
1010
) {
1111
const timeoutIdRef = useRef<number | null>(null)
1212
useEffect(() => {
1313
let _stopped = false
14-
;(async function pollingCallback() {
15-
try {
16-
await asyncCallback()
17-
} finally {
18-
// Set timeout after it finished, unless stopped
19-
timeoutIdRef.current = !_stopped && window.setTimeout(pollingCallback, interval)
20-
}
21-
})()
14+
; (async function pollingCallback() {
15+
try {
16+
await asyncCallback()
17+
} finally {
18+
// Set timeout after it finished, unless stopped
19+
timeoutIdRef.current = !_stopped && window.setTimeout(pollingCallback, interval)
20+
}
21+
})()
2222
// Clean up if dependencies change
2323
return () => {
2424
_stopped = true // prevent racing conditions

0 commit comments

Comments
 (0)