9 lines
279 B
TypeScript
9 lines
279 B
TypeScript
|
|
const now = ref(Date.now())
|
||
|
|
let timer: ReturnType<typeof setInterval> | undefined
|
||
|
|
|
||
|
|
/** A shared clock for projections and countdowns, ticking four times a second. */
|
||
|
|
export function useNow() {
|
||
|
|
timer ??= setInterval(() => (now.value = Date.now()), 250)
|
||
|
|
return readonly(now)
|
||
|
|
}
|