useIntervalFn
Wrapper for setInterval
with controls
Demo
Usage
js
import { useIntervalFn } from '@vueuse/core'
const { pause, resume, isActive } = useIntervalFn(() => {
/* your function */
}, 1000)
import { useIntervalFn } from '@vueuse/core'
const { pause, resume, isActive } = useIntervalFn(() => {
/* your function */
}, 1000)
Type Declarations
typescript
export interface UseIntervalFnOptions {
/**
* Start the timer immediately
*
* @default true
*/
immediate?: boolean
/**
* Execute the callback immediate after calling this function
*
* @default false
*/
immediateCallback?: boolean
}
/**
* Wrapper for `setInterval` with controls
*
* @param cb
* @param interval
* @param options
*/
export declare function useIntervalFn(
cb: Fn,
interval?: MaybeComputedRef<number>,
options?: UseIntervalFnOptions
): Pausable
export interface UseIntervalFnOptions {
/**
* Start the timer immediately
*
* @default true
*/
immediate?: boolean
/**
* Execute the callback immediate after calling this function
*
* @default false
*/
immediateCallback?: boolean
}
/**
* Wrapper for `setInterval` with controls
*
* @param cb
* @param interval
* @param options
*/
export declare function useIntervalFn(
cb: Fn,
interval?: MaybeComputedRef<number>,
options?: UseIntervalFnOptions
): Pausable
Source
Contributors
Anthony Fu
Jelf
sun0day
Enzo Innocenzi
wwj
Matvey Melishev
meteorlxy
Aurélio A. Heckert
xuxuhahaha
Hogne Vevle
Daiki Ojima