@dfinity/gix-components
Version:
A UI kit developed by the GIX team
14 lines (13 loc) • 454 B
JavaScript
// TODO: copied from NNS-dapp and needs to be moved to utils
/* eslint-disable-next-line @typescript-eslint/ban-types */
import { nonNullish } from "@dfinity/utils";
export const debounce = (func, timeout) => {
let timer;
return (...args) => {
const next = () => func(...args);
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(next, nonNullish(timeout) && timeout > 0 ? timeout : 300);
};
};