Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply VueUse composables in Vue 3/Nuxt projects to replace custom implementations with battle-tested utilities.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/useTimestamp.md
1---2category: Animation3---45# useTimestamp67Reactive current timestamp89## Usage1011```ts12import { useTimestamp } from '@vueuse/core'1314const timestamp = useTimestamp({ offset: 0 })15```1617```ts18import { useTimestamp } from '@vueuse/core'19// ---cut---20const { timestamp, pause, resume } = useTimestamp({ controls: true })21```2223## Component Usage2425```vue26<template>27<UseTimestamp v-slot="{ timestamp, pause, resume }">28Current Time: {{ timestamp }}29<button @click="pause()">30Pause31</button>32<button @click="resume()">33Resume34</button>35</UseTimestamp>36</template>37```3839## Type Declarations4041```ts42export interface UseTimestampOptions<43Controls extends boolean,44> extends ConfigurableScheduler {45/**46* Expose more controls47*48* @default false49*/50controls?: Controls51/**52* Offset value adding to the value53*54* @default 055*/56offset?: number57/**58* Update the timestamp immediately59*60* @deprecated Please use `scheduler` option instead61* @default true62*/63immediate?: boolean64/**65* Update interval, or use requestAnimationFrame66*67* @deprecated Please use `scheduler` option instead68* @default requestAnimationFrame69*/70interval?: "requestAnimationFrame" | number71/**72* Callback on each update73*/74callback?: (timestamp: number) => void75}76export type UseTimestampReturn<Controls extends boolean> = Controls extends true77? {78timestamp: ShallowRef<number>79} & Pausable80: ShallowRef<number>81/**82* Reactive current timestamp.83*84* @see https://vueuse.org/useTimestamp85* @param options86*/87export declare function useTimestamp(88options?: UseTimestampOptions<false>,89): ShallowRef<number>90export declare function useTimestamp(options: UseTimestampOptions<true>): {91timestamp: ShallowRef<number>92} & Pausable93```94