Event driven, add clue clock

This commit is contained in:
2023-02-19 11:29:28 -06:00
parent c1779907d7
commit de65fddba2
6 changed files with 69 additions and 26 deletions

View File

@@ -1,19 +1,20 @@
import { useEffect } from "react";
import { useEffect, useState } from "react";
import { useParams } from "react-router-dom";
import { debounce } from "./utils";
import { socket } from "./socket";
import { useAppSelector } from "./hooks";
import { selectCanBuzz, selectSignature } from "./store/contestantSlice";
import { selectSignature } from "./store/contestantSlice";
const Contestant = () => {
const { room } = useParams();
const signature = useAppSelector(selectSignature);
const canBuzz = useAppSelector(selectCanBuzz);
const [canBuzz, setCanBuzz] = useState<boolean>(false);
useEffect(() => {
socket.emit("contestant-join", { room, signature });
socket.on("clue-clock-on", () => setCanBuzz(true));
}, []);
const handleBuzz = debounce(() => {