The function to debounce.
The delay time in milliseconds.
A debounced version of func
that executes only after the delay time has passed without further calls.
let count = 1
const myfunc = () => {
console.log('Call ' + count)
count++
}
const myfuncDebounce = PUtilsFunction.debounce(myfunc, 1000)
// First context
myfuncDebounce() // Execute myfunc after 1 second: 'Call 1'
// Another context
myfuncDebounce() // Call 1 (canceled)
myfuncDebounce() // Reset time. It cancel the called one and after 1 seconde: 'Call 2'
Creates a debounced version of the given function. The returned function delays the execution of
func
until after a specified delay time has passed since the last time it was called. If the returned function is called again before the delay has expired, the previous call is canceled and the timer resets.