memoizedDebounce.ts 312 B

12345678910111213
  1. import { debounce, memoize } from 'lodash';
  2. export default (func: (...args: any[]) => void, wait = 7000) => {
  3. const mem = memoize(
  4. (...args) =>
  5. debounce(func, wait, {
  6. leading: true,
  7. }),
  8. (...args) => JSON.stringify(args)
  9. );
  10. return (...args: any[]) => mem(...args)(...args);
  11. };