Skip to content

useIntervalFn

Category
Export Size
375 B
Last Changed
10 months ago

Wrapper for setInterval with controls

Demo

Yo!

interval:

Usage

ts
import { 
useIntervalFn
} from '@vueuse/core'
const {
pause
,
resume
,
isActive
} =
useIntervalFn
(() => {
/* your function */ }, 1000)

Type Declarations

ts
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

SourceDemoDocs

Contributors

Anthony Fu
Anthony Fu
Vida Xie
Robin
Jelf
SerKo
IlyaL
OrbisK
Lapor Chen
Börge Kiss
Dan Rose
sun0day
Enzo Innocenzi
wwj
Matvey Melishev
meteorlxy
Aurélio A. Heckert
xuxuhahaha
Hogne Vevle
Daiki Ojima

Changelog

v13.1.0 on
c1d6e - feat(shared): ensure return types exists (#4659)
v12.8.0 on
7432f - feat(types): deprecate MaybeRef and MaybeRefOrGetter in favor of Vue's native (#4636)
v12.3.0 on
59f75 - feat(toValue): deprecate toValue from @vueuse/shared in favor of Vue's native
v12.0.0-beta.1 on
0a9ed - feat!: drop Vue 2 support, optimize bundles and clean up (#4349)
v11.2.0 on
59f8c - fix: prevent timer being set after pause is called in cb (#4258)

Released under the MIT License.

40% Off  yearly access to Vue School, Full course library + Vue.js Master Class.
Claim Offer