MCPcopy Create free account
hub / github.com/codeaashu/claude-code / useAnimationTimer

Function useAnimationTimer

src/ink/hooks/use-interval.ts:13–34  ·  view source on GitHub ↗
(intervalMs: number)

Source from the content-addressed store, hash-verified

11 * frame index) from the shared clock.
12 */
13export function useAnimationTimer(intervalMs: number): number {
14 const clock = useContext(ClockContext)
15 const [time, setTime] = useState(() => clock?.now() ?? 0)
16
17 useEffect(() => {
18 if (!clock) return
19
20 let lastUpdate = clock.now()
21
22 const onChange = (): void => {
23 const now = clock.now()
24 if (now - lastUpdate >= intervalMs) {
25 lastUpdate = now
26 setTime(now)
27 }
28 }
29
30 return clock.subscribe(onChange, false)
31 }, [clock, intervalMs])
32
33 return time
34}
35
36/**
37 * Interval hook backed by the shared Clock.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected