Skip to content

Commit

Permalink
chore: better setinterval
Browse files Browse the repository at this point in the history
Signed-off-by: Sacha Froment <[email protected]>
  • Loading branch information
sfroment committed Feb 24, 2025
1 parent 3ae6a99 commit 4b25c8f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions examples/grid/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,14 @@ async function run(metrics?: IMetrics) {
});

const button_connect = <HTMLButtonElement>document.getElementById("joinGrid");
const grid_input = <HTMLInputElement>document.getElementById("gridInput");
grid_input.addEventListener("keydown", (event) => {
if (event.key === "Enter") {
button_connect.click();
}
});
button_connect.addEventListener("click", async () => {
const drpId = (<HTMLInputElement>document.getElementById("gridInput")).value;
const drpId = grid_input.value;
try {
gridState.drpObject = await gridState.node.connectObject({
id: drpId,
Expand Down Expand Up @@ -150,7 +156,7 @@ async function main() {
await run(metrics);
});

setInterval(renderInfo, import.meta.env.VITE_RENDER_INFO_INTERVAL);
if (!hasRun) setInterval(renderInfo, import.meta.env.VITE_RENDER_INFO_INTERVAL);
}

void main();

0 comments on commit 4b25c8f

Please sign in to comment.