decord/source/hooks/useThrottle.tsx

80 lines
2 KiB
TypeScript
Raw Normal View History

2026-08-25 06:04:03 +00:00
// Module ID: 11041
// Function ID: 11042
2026-07-20 16:05:17 +00:00
// Name: throttleStateFn
2026-07-29 08:29:29 +00:00
// Dependencies: [19, 12, 2]
2026-07-20 16:05:17 +00:00
// Exports: useThrottledState
2026-08-25 06:04:03 +00:00
// Module 11041 (throttleStateFn)
2026-08-24 06:08:38 +00:00
import closure_2 from "noop" /* 19 */;
2026-07-23 10:11:24 +00:00
const require = arg1;
2026-07-20 16:05:17 +00:00
function throttleStateFn(arg0) {
return arg0;
}
2026-07-29 08:29:29 +00:00
function useThrottledFunction(callback4, arg1, items4, sharedValue) {
2026-07-23 10:11:24 +00:00
const _require = callback4;
2026-08-24 06:08:38 +00:00
dependencyMap = arg1;
2026-07-29 08:29:29 +00:00
let items = items4;
if (items4 === undefined) {
2026-07-20 16:05:17 +00:00
items = [];
}
2026-07-23 10:11:24 +00:00
const React = sharedValue;
let ref;
2026-07-29 08:29:29 +00:00
ref = React.useRef(_require(12).throttle(callback4, arg1, sharedValue));
2026-07-23 10:11:24 +00:00
const items1 = [callback4, arg1, sharedValue, ...items];
2026-07-20 16:05:17 +00:00
const effect = React.useEffect(() => {
2026-08-24 06:08:38 +00:00
ref.current = callback(current2[1]).throttle(callback, current2, ref1);
2026-07-20 16:05:17 +00:00
return () => {
2026-07-29 08:29:29 +00:00
const current = ref.current;
if (current != null) {
2026-07-20 16:05:17 +00:00
current.cancel();
}
};
}, items1);
return ref.current;
}
2026-07-23 10:11:24 +00:00
const result = require("set").fileFinishedImporting("hooks/useThrottle.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export const useThrottledState = (stateFromStores) => {
let current = stateFromStores;
let _require = stateFromStores;
let items = arg2;
if (arg2 === undefined) {
items = [];
}
let current2;
let ref1;
2026-08-04 21:03:28 +00:00
if (typeof useThrottledFunction !== "function") {
2026-07-29 08:29:29 +00:00
HermesBuiltin.throwTypeError();
}
_require = tmp;
current2 = arg1;
2026-07-20 16:05:17 +00:00
if (items === undefined) {
items = [];
}
2026-07-29 08:29:29 +00:00
ref1 = arg3;
2026-07-23 10:11:24 +00:00
let ref;
2026-07-29 08:29:29 +00:00
ref = ref1.useRef(_require(current2[1]).throttle(tmp, arg1, arg3));
const items1 = [tmp, arg1, arg3, ...items];
const effect = ref1.useEffect(() => {
2026-08-24 06:08:38 +00:00
ref.current = callback(current2[1]).throttle(callback, current2, ref1);
2026-07-29 08:29:29 +00:00
return () => {
const current = ref.current;
if (current != null) {
current.cancel();
}
};
2026-07-20 16:05:17 +00:00
}, items1);
2026-07-29 08:29:29 +00:00
current2 = ref.current;
ref1 = ref1.useRef(current);
const items2 = [current, current2];
const effect1 = ref1.useEffect(() => {
ref1.current = current2(closure_0);
}, items2);
2026-07-20 16:05:17 +00:00
if (0 !== arg1) {
2026-07-29 08:29:29 +00:00
current = ref1.current;
2026-07-20 16:05:17 +00:00
}
return current;
};
export { useThrottledFunction };