decord/source/hooks/useLeadingEdgeDebounce.tsx

35 lines
919 B
TypeScript
Raw Normal View History

2026-08-13 17:34:28 +00:00
// Module ID: 10725
// Function ID: 10726
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-13 17:34:28 +00:00
// Module 10725 (useLeadingEdgeDebounce)
2026-07-23 10:11:24 +00:00
import _slicedToArray from "_slicedToArray";
2026-07-29 08:29:29 +00:00
import noop from "noop";
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;
let closure_2 = React.useRef(true);
const tmp = callback(React.useState(arg0), 2);
let closure_3 = tmp[1];
const items = [arg0, arg1];
const effect = React.useEffect(() => {
const timeout = setTimeout(() => {
2026-07-29 08:29:29 +00:00
callback(_slicedToArray);
closure_2.current = true;
}, noop);
2026-07-20 16:05:17 +00:00
if (ref.current) {
callback(timeout);
}
ref.current = false;
return () => {
2026-07-23 10:11:24 +00:00
clearTimeout(_slicedToArray);
2026-07-20 16:05:17 +00:00
};
}, items);
return tmp[0];
};