useTimeoutFn

Wrapper for setTimeout with controls.

Usage

<script>
  import { useTimeoutFn } from '@svelte-use/core'

  const { isPending, start, stop } = useTimeoutFn(() => {
    // do something
  }, 3000)
</script>

Type Declarations

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

Source

SourceDemoDocs