⬅️ Back to Table of Contents
📄 index.ts
📊 Analysis Summary
Metric |
Count |
🔧 Functions |
2 |
📦 Imports |
6 |
📊 Variables & Constants |
2 |
📐 Interfaces |
1 |
📑 Type Aliases |
1 |
📚 Table of Contents
🛠️ File Location:
📂 packages/core/useTimestamp/index.ts
📦 Imports
Name |
Source |
Pausable |
@vueuse/shared |
ShallowRef |
vue |
timestamp |
@vueuse/shared |
useIntervalFn |
@vueuse/shared |
shallowRef |
vue |
useRafFn |
../useRafFn |
Variables & Constants
Name |
Type |
Kind |
Value |
Exported |
cb |
() => void |
const |
`callback |
|
? () => { |
|
|
|
|
update() |
|
|
|
|
callback(ts.value) |
|
|
|
|
} |
|
|
|
|
: update` |
✗ |
|
|
|
controls |
Pausable |
const |
`interval === 'requestAnimationFrame' |
|
? useRafFn(cb, { immediate }) |
|
|
|
|
: useIntervalFn(cb, interval, { immediate })` |
✗ |
|
|
|
Functions
useTimestamp(options: UseTimestampOptions<false>): ShallowRef<number>
Code
export function useTimestamp(options?: UseTimestampOptions<false>): ShallowRef<number>
-
JSDoc:
/**
* Reactive current timestamp.
*
* @see https://vueuse.org/useTimestamp
* @param options
*/
-
Parameters:
options: UseTimestampOptions<false>
- Return Type:
ShallowRef<number>
update(): any
Code
() => ts.value = timestamp() + offset
Interfaces
UseTimestampOptions<Controls extends boolean>
Interface Code
export interface UseTimestampOptions<Controls extends boolean> {
/**
* Expose more controls
*
* @default false
*/
controls?: Controls
/**
* Offset value adding to the value
*
* @default 0
*/
offset?: number
/**
* Update the timestamp immediately
*
* @default true
*/
immediate?: boolean
/**
* Update interval, or use requestAnimationFrame
*
* @default requestAnimationFrame
*/
interval?: 'requestAnimationFrame' | number
/**
* Callback on each update
*/
callback?: (timestamp: number) => void
}
Properties
Name |
Type |
Optional |
Description |
controls |
Controls |
✓ |
|
offset |
number |
✓ |
|
immediate |
boolean |
✓ |
|
interval |
'requestAnimationFrame' | number |
✓ |
|
callback |
(timestamp: number) => void |
✓ |
|
Type Aliases
UseTimestampReturn
type UseTimestampReturn = ReturnType<typeof useTimestamp>;