15 lines
389 B
TypeScript
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,
|
|
);
|
|
};
|