decord/source/hooks/useLeadingEdgeDebounce.tsx

35 lines
924 B
TypeScript
Raw Normal View History

2026-08-25 06:04:03 +00:00
// Module ID: 10838
// Function ID: 10839
2026-07-20 16:05:17 +00:00
// Name: useLeadingEdgeDebounce
2026-07-29 08:29:29 +00:00
// Dependencies: [32, 19, 2]
2026-07-20 16:05:17 +00:00
// Exports: useLeadingEdgeDebounce
2026-08-25 06:04:03 +00:00
// Module 10838 (useLeadingEdgeDebounce)
2026-08-24 06:08:38 +00:00
import closure_0 from "_slicedToArray" /* 32 */;
import closure_1 from "noop" /* 19 */;
2026-07-23 10:11:24 +00:00
const result = require("set").fileFinishedImporting("hooks/useLeadingEdgeDebounce.tsx");
2026-07-20 16:05:17 +00:00
export const useLeadingEdgeDebounce = (arg0, arg1) => {
const callback = arg0;
const React = arg1;
2026-08-24 06:08:38 +00:00
closure_2 = React.useRef(true);
2026-07-20 16:05:17 +00:00
const tmp = callback(React.useState(arg0), 2);
2026-08-24 06:08:38 +00:00
closure_3 = tmp[1];
2026-07-20 16:05:17 +00:00
const items = [arg0, arg1];
const effect = React.useEffect(() => {
const timeout = setTimeout(() => {
2026-08-24 06:08:38 +00:00
callback(closure_0);
2026-07-29 08:29:29 +00:00
closure_2.current = true;
2026-08-24 06:08:38 +00:00
}, closure_1);
2026-07-20 16:05:17 +00:00
if (ref.current) {
callback(timeout);
}
ref.current = false;
return () => {
2026-08-24 06:08:38 +00:00
clearTimeout(closure_0);
2026-07-20 16:05:17 +00:00
};
}, items);
return tmp[0];
};