A basic debounce implementation. Debounce will basically wait X amount of seconds to execute AFTER it's last call.
const debouncer = func.debounce((windowEvent)=> { console.log(wiindowEvent);}, 500);// Now when you resize, it will wait 500 ms until the last resize call.window.addEventListener('resize', debounce);Orwindow.addEventListener('resize', func.debounce(()=> { console.log('throttled');}, 500)) Copy
const debouncer = func.debounce((windowEvent)=> { console.log(wiindowEvent);}, 500);// Now when you resize, it will wait 500 ms until the last resize call.window.addEventListener('resize', debounce);Orwindow.addEventListener('resize', func.debounce(()=> { console.log('throttled');}, 500))
The function to call.
The ms to delay.
Optional
Optional, whether to immediately run (changes this to throttle)
A debounced function
A basic debounce implementation. Debounce will basically wait X amount of seconds to execute AFTER it's last call.