platform-bible-utils
    Preparing search index...

    Function debounce

    • Get a function that reduces calls to the function passed in

      Type Parameters

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

        A function type that takes any arguments and returns void. This is the type of the function being debounced.

      Parameters

      • fn: TFunc

        The function to debounce

      • delay: number = 300

        How much delay in milliseconds after the most recent call to the debounced function to call the function

      Returns DebouncedFunction<TFunc>

      Function that, when called, only calls the function passed in at maximum every delay ms. The returned function also has a cancel method to abandon any pending invocation (canceling makes the pending invocation's promise reject with an error whose message is DEBOUNCE_CANCELED_ERROR_MESSAGE) and a flush method to run the pending invocation immediately instead of waiting out the delay.