Hiyve Components - v1.0.0
    Preparing search index...
    • Hook for Q&A synchronization via the semantic relay.

      Parameters

      Returns UseQASyncResult

      Object containing sync functions and connection state

      This hook handles real-time synchronization of Q&A state across all participants in a room.

      Message Flow:

      • When a user posts a question, it's broadcast to all participants
      • When the owner answers, the answer is broadcast to all
      • When votes change, the new vote array is broadcast
      • Late joiners request state from any participant

      Owner Responsibilities:

      • Responding to state requests from late joiners
      • Answering questions
      • Deleting questions
      • Pinning/unpinning questions
      function QAComponent() {
      const questionsRef = useRef(new Map());
      const [questions, setQuestions] = useState([]);

      const {
      postQuestion,
      answerQuestion,
      deleteQuestion,
      toggleVote,
      pinQuestion,
      connected,
      } = useQASync({
      isOwner,
      localUserId: userId,
      localUserName: userName,
      questionsRef,
      onStateUpdate: setQuestions,
      });
      }