@vlalg-nimbus/magic-debounce
v3.0.2
Published
Printing the console.log in a magical way
Maintainers
Readme
This lib is a debounce utility that simplifies the control of function execution timing, preventing unnecessary calls and improving performance.
Full documentation can be found here, a summary is below.
Config
The lib accepts three parameters:
- wait: The time (in milliseconds) to wait before calling the
callback. - callback: The function to be executed after the debounce delay. Required.
- firstClickOnly: If
true, only the first call is executed during the debounce window. Useful for preventing repeated triggers.
const config = {
wait: 300,
firstClickOnly: false,
callback:() => {}
};
MagicDebounce(config)How to use?
To install
npm i @vlalg-nimbus/magic-debounceor
yarn add @vlalg-nimbus/magic-debounceCDN
https://unpkg.com/@vlalg-nimbus/magic-debounce/dist/bundle.min.umd.jsTo use
import MagicDebounce from '@vlalg-nimbus/magic-debounce'
const { debouncedFunction, cancel } = MagicDebounce({
wait: 300,
callback: () => {
console.log('Debounced!');
}
});
debouncedFunction();
cancel();