• Wait before calling the same function. Useful for expensive calls. Adapted from https://amitd.co/code/typescript/debounce.

    Type Parameters

    • T extends ((...args) => ReturnType<T>)

    Parameters

    • fn: T

      The function to be debounced.

    • Optional delayMs: number

      Defaults to 5 seconds.

      Optional

    Returns ((...args) => void)

    The debounced function.

      • (...args): void
      • Parameters

        • Rest ...args: Parameters<T>
          Rest

        Returns void

    Example

    const debouncedFunction = debounce(e => {
    console.log(e);
    }, 5000);

    // Console logs 'Hello world again ' after 5 seconds
    debouncedFunction('Hello world');
    debouncedFunction('Hello world again');

Generated using TypeDoc