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)
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 AnyFn>(
cb: CallbackFn,
interval: MaybeRefOrGetter<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
Changelog ​
v10.0.0-beta.4
on 4/13/20234d757
- feat(types)!: rename MaybeComputedRef
to MaybeRefOrGetter
0a72b
- feat(toValue): rename resolveUnref
to toValue
v9.12.0
on 1/29/2023v9.1.1
on 8/23/20220fdbb
- fix(shared): resolve internal circular referencev9.0.0-beta.1
on 7/20/2022