import { onMounted, onUnmounted, ref, shallowRef } from 'vue'; export function useNow(update_ms: number) { const handle = shallowRef(undefined); const now = ref(Date.now()); onMounted(() => { handle.value = setInterval(() => { now.value = Date.now(); }, update_ms); }); onUnmounted(() => { if (handle.value) { clearInterval(handle.value); } }); return now; }