Skip to content
On this page

Demo

Category
Last Changed
a month ago

Please wait for 3 seconds

useTimeoutFn

Wrapper for setTimeout with controls.

import { useTimeoutFn } from '@vueuse/core'

const { isPending, start, stop } = useTimeoutFn(() => {
  /* ... */
}, 3000)
import { useTimeoutFn } from '@vueuse/core'

const { isPending, start, stop } = useTimeoutFn(() => {
  /* ... */
}, 3000)

Type Declarations

export interface TimeoutFnOptions {
  /**
   * Start the timer immediate after calling this function
   *
   * @default true
   */
  immediate?: boolean
}
/**
 * Wrapper for `setTimeout` with controls.
 *
 * @param cb
 * @param interval
 * @param immediate
 */
export declare function useTimeoutFn(
  cb: (...args: unknown[]) => any,
  interval: MaybeRef<number>,
  options?: TimeoutFnOptions
): Stoppable
export interface TimeoutFnOptions {
  /**
   * Start the timer immediate after calling this function
   *
   * @default true
   */
  immediate?: boolean
}
/**
 * Wrapper for `setTimeout` with controls.
 *
 * @param cb
 * @param interval
 * @param immediate
 */
export declare function useTimeoutFn(
  cb: (...args: unknown[]) => any,
  interval: MaybeRef<number>,
  options?: TimeoutFnOptions
): Stoppable

Source

SourceDemoDocs

Contributors

Anthony Fu
Scott Bedard
Shinigami
Peter Shih
liaoliao666
Sergey Shumov

Changelog

v6.9.2 on 11/19/2021
80409 - fix: interface typos (#938)
v6.0.0-beta.2 on 8/9/2021
ff21b - feat: use tryOnScopeDispose instead of tryOnUnmounted
v4.9.3 on 5/11/2021
b5d5d - feat(useTransition): support for delayed transitions (#386)
Demo has loaded