Table of Contents
Description
The Debounce utility provides a function to delay the execution of a function until after a specified wait time has elapsed since the last time it was invoked.
Basic Usage
import debounce from '../src/utils/debounce.js';
const saveInput = debounce(() => {
console.log('Saving data');
}, 2000);
document.getElementById('input').addEventListener('input', saveInput);
JavaScript Reference
debounce
debounce(func function, timeout number)
Parameters
func: function
The function to debounce.
timeout: number
The number of milliseconds to delay. Default is 300ms.
Returns
A debounced version of the provided function.