useTimeoutFn
Wrapper for setTimeout
with controls.
Demo
Please wait for 3 seconds
Usage
js
import { useTimeoutFn } from '@vueuse/core'
const { isPending, start, stop } = useTimeoutFn(() => {
/* ... */
}, 3000)
import { useTimeoutFn } from '@vueuse/core'
const { isPending, start, stop } = useTimeoutFn(() => {
/* ... */
}, 3000)
Type Declarations
typescript
export interface UseTimeoutFnOptions {
/**
* Start the timer immediate after calling this function
*
* @default true
*/
immediate?: boolean
}
/**
* Wrapper for `setTimeout` with controls.
*
* @param cb
* @param interval
* @param options
*/
export declare function useTimeoutFn<
CallbackFn extends (...args: any[]) => any
>(
cb: CallbackFn,
interval: MaybeComputedRef<number>,
options?: UseTimeoutFnOptions
): Stoppable<Parameters<CallbackFn> | []>
export interface UseTimeoutFnOptions {
/**
* Start the timer immediate after calling this function
*
* @default true
*/
immediate?: boolean
}
/**
* Wrapper for `setTimeout` with controls.
*
* @param cb
* @param interval
* @param options
*/
export declare function useTimeoutFn<
CallbackFn extends (...args: any[]) => any
>(
cb: CallbackFn,
interval: MaybeComputedRef<number>,
options?: UseTimeoutFnOptions
): Stoppable<Parameters<CallbackFn> | []>
Source
Contributors
Anthony Fu
Scott Bedard
Dan Rose
Kasper Seweryn
jack zhang
vaakian X
Jelf
Shinigami
Peter Shih
liaoliao666
Sergey Shumov