@supuwoerc/toolkit
    Preparing search index...

    Variable debounceConst

    debounce: <T extends (...args: any[]) => any>(
        delay: number,
        callback: T,
        options?: DebounceOptions,
    ) => __type<T> = _debounce

    Type Declaration

      • <T extends (...args: any[]) => any>(
            delay: number,
            callback: T,
            options?: DebounceOptions,
        ): __type<T>
      • Debounce execution of a function. Debouncing, unlike throttling, guarantees that a function is only executed a single time, either at the very beginning of a series of calls, or at the very end.

        Type Parameters

        • T extends (...args: any[]) => any

        Parameters

        • delay: number

          A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.

        • callback: T

          A function to be executed after delay milliseconds. The this context and all arguments are passed through, as-is, to callback when the debounced-function is executed.

        • Optionaloptions: DebounceOptions

          An object to configure options.

          • atBegin

            If atBegin is false or unspecified, callback will only be executed delay milliseconds after the last debounced-function call. If atBegin is true, callback will be executed only at the first debounced-function call. (After the throttled-function has not been called for delay milliseconds, the internal counter is reset).

        Returns __type<T>

        A new, debounced function.

    Function to debounce

    Wait time in milliseconds

    Configuration options

    Call before the delay

    Call after the delay

    Maximum wait time

    Debounced function

    const debouncedFn = debounce(() => {
    console.log('Resized!')
    }, 250)
    window.addEventListener('resize', debouncedFn)