Skip to content

useIntervalFn

Category
Export Size
348 B
Last Changed
5 days ago

Wrapper for setInterval with controls

Demo

Usage

tsx
import { 
useIntervalFn
} from '@reause/shared'
const {
isActive
,
pause
,
resume
} =
useIntervalFn
(() => {
/* ... */ }, 1000)

Type Declarations

ts
export interface UseIntervalFnOptions {
    immediate?: boolean;
    immediateCallback?: boolean;
}

export interface UseIntervalFnReturn {
    isActive: boolean;
    pause: () => void;
    resume: () => void;
}

type Fn = () => void

export function useIntervalFn(cb: Fn, interval?: number, options?: UseIntervalFnOptions): UseIntervalFnReturn

Source

Source · Demo · VueUse

Contributors

hairyf

Changelog

v0.1.0 on
750ca - fix(shared): resolve useIntervalFn audit findings (#734)
8fddc - chore!: remove all Vue-only Maybe* types and getter unions, adopt React Ref (#462)

Released under the MIT License. v0.1.8