Update parameterUtils to use debounce instead of throttle

This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-03-31 23:11:53 -03:00
commit 239fb230c6
2 changed files with 5 additions and 5 deletions

View file

@ -34,8 +34,8 @@ import {
} from "../../../../types/api";
import { ParameterComponentType } from "../../../../types/components";
import {
debouncedHandleUpdateValues,
handleUpdateValues,
throttledHandleUpdateValues,
} from "../../../../utils/parameterUtils";
import {
convertObjToArray,
@ -170,7 +170,7 @@ export default function ParameterComponent({
if (shouldUpdate) {
setIsLoading(true);
try {
newTemplate = await throttledHandleUpdateValues(name, data);
newTemplate = await debouncedHandleUpdateValues(name, data);
} catch (error) {
let responseError = error as ResponseErrorTypeAPI;
setErrorData({
@ -662,7 +662,7 @@ export default function ParameterComponent({
) : left === true && type === "int" ? (
<div className="mt-2 w-full">
<IntComponent
rangeSpec={data.node?.template[name].rangeSpec}
rangeSpec={data.node?.template[name].rangeSpec}
disabled={disabled}
value={data.node?.template[name].value ?? ""}
onChange={handleOnNewValue}

View file

@ -1,4 +1,4 @@
import { throttle } from "lodash";
import { debounce } from "lodash";
import { postCustomComponentUpdate } from "../controllers/API";
import { ResponseErrorTypeAPI } from "../types/api";
import { NodeDataType } from "../types/flow";
@ -38,4 +38,4 @@ export const handleUpdateValues = async (name: string, data: NodeDataType) => {
}
};
export const throttledHandleUpdateValues = throttle(handleUpdateValues, 10);
export const debouncedHandleUpdateValues = debounce(handleUpdateValues, 200);