useIntervalFn
Wrapper for setInterval
with controls
Demo
Usage
js
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 immediately after calling `resume`
*
* @default false
*/
immediateCallback?: boolean
}
export type UseIntervalFnReturn = Pausable
/**
* Wrapper for `setInterval` with controls
*
* @see https://vueuse.org/useIntervalFn
* @param cb
* @param interval
* @param options
*/
export declare function useIntervalFn(
cb: Fn,
interval?: MaybeRefOrGetter<number>,
options?: UseIntervalFnOptions,
): UseIntervalFnReturn
Source
Contributors
Changelog
v13.1.0
on v12.8.0
on v12.3.0
on 59f75
- feat(toValue): deprecate toValue
from @vueuse/shared
in favor of Vue's nativev11.2.0
on cb644
- refactor!: remove isFunction
and isString
utils4d757
- feat(types)!: rename MaybeComputedRef
to MaybeRefOrGetter
0a72b
- feat(toValue): rename resolveUnref
to toValue