Skip to content

Commit

Permalink
IIFE workaround for missing top-level await
Browse files Browse the repository at this point in the history
  • Loading branch information
vakila committed Nov 30, 2023
1 parent 8d09c28 commit 0a63fef
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import "./style.css"; // Vite handles inserting CSS
// Common pattern is to put JS source files in src/
import { setupVideo, takePhoto } from "./src/camera.js";

const button = document.querySelector("#take-photo");
const canvas = document.querySelector("canvas");
const video = await setupVideo();
(async function run() {
const button = document.querySelector("#take-photo");
const canvas = document.querySelector("canvas");
const video = await setupVideo();

button.addEventListener("click", () => {
takePhoto(video, canvas);
});
button.addEventListener("click", () => {
takePhoto(video, canvas);
});
})();

0 comments on commit 0a63fef

Please sign in to comment.