Files
super-app/App/common/utilities/ThrottleUtil.ts
2024-09-24 17:39:17 +00:00

15 lines
389 B
TypeScript

import throttle from "lodash/throttle";
import { GenericActionPayload } from "../actions/GenericAction";
export const createThrottledHandler = (
handleActions: (action?: GenericActionPayload) => void,
delay: number,
options = { leading: true, trailing: false },
) => {
return throttle(
(action?: GenericActionPayload) => handleActions(action),
delay,
options,
);
};