Skip to content

Commit

Permalink
remove unnecessery utill function
Browse files Browse the repository at this point in the history
  • Loading branch information
filip131311 committed Jun 10, 2024
1 parent 0ffca2f commit 9970683
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 27 deletions.
22 changes: 0 additions & 22 deletions packages/vscode-extension/src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,3 @@ export function throttle<T extends (...args: any[]) => any>(
recentArgs = args;
} as T;
}

export function throttleWithTrailing<T extends (...args: any[]) => any>(
func: T,
limitMs: number
): (...args: Parameters<T>) => void {
let timeout: NodeJS.Timeout | null = null;
let recentArgs: any;

return function (...args: Parameters<T>) {
recentArgs = args;

if (!timeout) {
timeout = setTimeout(() => {
timeout = null;
if (recentArgs) {
func(...recentArgs);
recentArgs = null;
}
}, limitMs);
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import "./DeviceLocationView.css";
import Label from "../components/shared/Label";
import * as Switch from "@radix-ui/react-switch";
import CoordinateParser from "coordinate-parser";
import { throttleWithTrailing } from "../../common/utils";
import Tooltip from "../components/shared/Tooltip";
import { throttle } from "../../common/utils";

const CoordinateInfo = () => {
return (
Expand Down Expand Up @@ -43,10 +43,7 @@ export function DeviceLocationView() {
const { project, deviceSettings } = useProject();
const inputRef = useRef<HTMLInputElement>(null);

const updateProjectSettingWithThrottle = throttleWithTrailing(
project.updateDeviceSettings,
THROTTLE_LIMIT
);
const updateProjectSettingWithThrottle = throttle(project.updateDeviceSettings, THROTTLE_LIMIT);

const [isCoordinateValid, setIsCoordinateValid] = useState(true);

Expand Down

0 comments on commit 9970683

Please sign in to comment.