MCPcopy Index your code
hub / github.com/codeaashu/claude-code / useInterval

Function useInterval

src/ink/hooks/use-interval.ts:43–67  ·  view source on GitHub ↗
(
  callback: () => void,
  intervalMs: number | null,
)

Source from the content-addressed store, hash-verified

41 * one wake-up. Pass `null` for intervalMs to pause.
42 */
43export function useInterval(
44 callback: () => void,
45 intervalMs: number | null,
46): void {
47 const callbackRef = useRef(callback)
48 callbackRef.current = callback
49
50 const clock = useContext(ClockContext)
51
52 useEffect(() => {
53 if (!clock || intervalMs === null) return
54
55 let lastUpdate = clock.now()
56
57 const onChange = (): void => {
58 const now = clock.now()
59 if (now - lastUpdate >= intervalMs) {
60 lastUpdate = now
61 callbackRef.current()
62 }
63 }
64
65 return clock.subscribe(onChange, false)
66 }, [clock, intervalMs])
67}
68

Callers 11

AutoUpdaterFunction · 0.85
NativeAutoUpdaterFunction · 0.85
DevBarFunction · 0.85
SystemAPIErrorMessageFunction · 0.85
TeamsDialogFunction · 0.85
BtwSideQuestionFunction · 0.85
useMemoryUsageFunction · 0.85
useInboxPollerFunction · 0.85
useSwarmPermissionPollerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected