Skip to content

Commit

Permalink
return useInputState hook back to its simpler form
Browse files Browse the repository at this point in the history
  • Loading branch information
noahm committed Apr 7, 2024
1 parent 1b8afe0 commit 1b8a70b
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions ui/stage/stage-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,9 @@ const UI_UPDATE_RATE = 50;

function useInputState(stage: SMXStage | undefined) {
const [panelStates, setPanelStates] = useState<Array<boolean> | 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;
}

Expand Down

0 comments on commit 1b8a70b

Please sign in to comment.