Update parameterUtils to use debounce instead of throttle
This commit is contained in:
parent
4ac1b4f1b0
commit
239fb230c6
2 changed files with 5 additions and 5 deletions
|
|
@ -34,8 +34,8 @@ import {
|
||||||
} from "../../../../types/api";
|
} from "../../../../types/api";
|
||||||
import { ParameterComponentType } from "../../../../types/components";
|
import { ParameterComponentType } from "../../../../types/components";
|
||||||
import {
|
import {
|
||||||
|
debouncedHandleUpdateValues,
|
||||||
handleUpdateValues,
|
handleUpdateValues,
|
||||||
throttledHandleUpdateValues,
|
|
||||||
} from "../../../../utils/parameterUtils";
|
} from "../../../../utils/parameterUtils";
|
||||||
import {
|
import {
|
||||||
convertObjToArray,
|
convertObjToArray,
|
||||||
|
|
@ -170,7 +170,7 @@ export default function ParameterComponent({
|
||||||
if (shouldUpdate) {
|
if (shouldUpdate) {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
try {
|
try {
|
||||||
newTemplate = await throttledHandleUpdateValues(name, data);
|
newTemplate = await debouncedHandleUpdateValues(name, data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
let responseError = error as ResponseErrorTypeAPI;
|
let responseError = error as ResponseErrorTypeAPI;
|
||||||
setErrorData({
|
setErrorData({
|
||||||
|
|
@ -662,7 +662,7 @@ export default function ParameterComponent({
|
||||||
) : left === true && type === "int" ? (
|
) : left === true && type === "int" ? (
|
||||||
<div className="mt-2 w-full">
|
<div className="mt-2 w-full">
|
||||||
<IntComponent
|
<IntComponent
|
||||||
rangeSpec={data.node?.template[name].rangeSpec}
|
rangeSpec={data.node?.template[name].rangeSpec}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
value={data.node?.template[name].value ?? ""}
|
value={data.node?.template[name].value ?? ""}
|
||||||
onChange={handleOnNewValue}
|
onChange={handleOnNewValue}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { throttle } from "lodash";
|
import { debounce } from "lodash";
|
||||||
import { postCustomComponentUpdate } from "../controllers/API";
|
import { postCustomComponentUpdate } from "../controllers/API";
|
||||||
import { ResponseErrorTypeAPI } from "../types/api";
|
import { ResponseErrorTypeAPI } from "../types/api";
|
||||||
import { NodeDataType } from "../types/flow";
|
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);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue