useInterval
Reactive counter increases on every interval
Usage
<script>
import { useInterval } from '@svelte-use/core'
// count will increase every 200ms
const counter = useInterval(200)
// with controls
const { counter, pause, resume } = useInterval(200, { controls: true })
</script>
Type Declarations
export interface IntervalOptions<Controls extends boolean> {
/**
* Expose the controls
*
* @default false
*/
controls?: Controls
/**
* Execute the update immediately on calling
*
* @default true
*/
immediate?: boolean
}
export declare function useInterval(
interval?: number,
options?: IntervalOptions<false>
): Writable<number>
export declare function useInterval(
interval: number,
options: IntervalOptions<true>
): {
counter: Writable<number>
} & Pausable