On this page
useInterval
Category | Animation |
---|---|
Export Size | 620 B |
Last Changed | 2 weeks ago |
Reactive counter increases on every interval
Usage
import { useInterval } from '@vueuse/core'
// count will increase every 200ms
const counter = useInterval(200)
const { counter, reset, pause, resume } = useInterval(200, { controls: true })
Type Declarations
export interface UseIntervalOptions<Controls extends boolean> {
/**
* Expose more controls
*
* @default false
*/
controls?: Controls
/**
* Execute the update immediately on calling
*
* @default true
*/
immediate?: boolean
/**
* Callback on every interval
*/
callback?: (count: number) => void
}
export interface UseIntervalControls {
counter: Ref<number>
reset: () => void
}
/**
* Reactive counter increases on every interval
*
* @see https://vueuse.org/useInterval
* @param interval
* @param options
*/
export declare function useInterval(
interval?: MaybeRefOrGetter<number>,
options?: UseIntervalOptions<false>
): Ref<number>
export declare function useInterval(
interval: MaybeRefOrGetter<number>,
options: UseIntervalOptions<true>
): UseIntervalControls & Pausable
Source
© 2019-present Anthony Fu
Licensed under the MIT License.
https://vueuse.org/shared/useInterval/