decord/alpha/source/hooks/useLeadingEdgeDebounce.tsx

36 lines
913 B
TypeScript
Raw Normal View History

// Module ID: 9825
// Function ID: 9826
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
// Module 9825 (useLeadingEdgeDebounce)
import _slicedToArray from "module_32" /* 32 */;
import noop from "module_19" /* 19 */;
2026-07-23 10:11:24 +00:00
const size = fn(2);
const result = size.fileFinishedImporting("hooks/useLeadingEdgeDebounce.tsx");
2026-07-20 16:05:17 +00:00
export const useLeadingEdgeDebounce = (arg0, arg1) => {
closure_0 = arg0;
closure_1 = arg1;
noop.useRef(true);
const tmp = _slicedToArray(noop.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 = noop.useEffect(() => {
2026-07-20 16:05:17 +00:00
const timeout = setTimeout(() => {
closure_1_3(closure_0);
ref.current = true;
2026-08-24 06:08:38 +00:00
}, closure_1);
2026-07-20 16:05:17 +00:00
if (ref.current) {
closure_3(timeout);
2026-07-20 16:05:17 +00:00
}
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];
};