From 1b8a70bbf0bdcb1b0dab1a91720f230e22cc8890 Mon Sep 17 00:00:00 2001 From: Noah Manneschmidt Date: Sun, 7 Apr 2024 15:38:48 -0700 Subject: [PATCH] return `useInputState` hook back to its simpler form --- ui/stage/stage-test.tsx | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/ui/stage/stage-test.tsx b/ui/stage/stage-test.tsx index 89445cf..209473a 100644 --- a/ui/stage/stage-test.tsx +++ b/ui/stage/stage-test.tsx @@ -10,19 +10,9 @@ const UI_UPDATE_RATE = 50; function useInputState(stage: SMXStage | undefined) { const [panelStates, setPanelStates] = useState | null>(); - useEffect(() => { - if (!stage) return; - - const d = stage; - async function update() { - setPanelStates(d.inputs); - } - - const handle = setInterval(update, UI_UPDATE_RATE); - return () => clearInterval(handle); + return stage?.inputState$.throttle(UI_UPDATE_RATE).onValue(setPanelStates); }, [stage]); - return panelStates; }