Skip to content
On this page

useIntervalFn

带控件的 setInterval 包装器

Wrapper for setInterval with controls

例子

Hello

interval:

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

Category
Export Size
394 B
Last Changed
2 months ago

SourceDemoDocs

贡献者(Contributors)

日志(Changelog)

v9.12.0 on 2023/1/29
39183 - feat(useRafFn, useIntervalFn, useTimeoutFn): make status readonly (#2685)

Released under the MIT License.