reveal / multiplex

The reveal.js Multiplex Plugin
MIT License
116 stars 22 forks source link

Reference Error: Reveal is not defined. Initialization Error #13

Open igauravsehrawat opened 2 years ago

igauravsehrawat commented 2 years ago

Greetings and morning all,

I am facing this unexpected issue I have included the dependencies as shown in README.md Screen Shot 2022-05-03 at 08 22 09

But on my slides, I am getting below error Screen Shot 2022-05-03 at 08 21 34

I tried to include all dependencies in script tag though it's not suggested but then I get below error.

Screen Shot 2022-05-03 at 08 28 07

Any help will be appreciated. What am I doing wrong?

jungleBadger commented 3 months ago

I just went through a similar scenario. To resolve that, you need to expose your Reveal instance to the global Window object, as demonstrated below:

import Reveal from "reveal.js";
import { useRef } from "preact/hooks";

const deckDivRef = useRef(null); 

window.Reveal = new Reveal(deckDivRef.current, {
    transition: "slide",
    multiplex: {
        "secret": null, // fill for master execution
        "id": "35c115997a5e0645", //it must be Id here - the lib will convert to socketId
        "url": 'https://reveal-multiplex.glitch.me/' // Location of socket.io server
    },
    dependencies: [
        { src: 'https://reveal-multiplex.glitch.me/socket.io/socket.io.js', async: true },
        { src: 'https://reveal-multiplex.glitch.me/client.js', async: true } // or server
    ],
    // other config options
});

I hope it helps.

Stay safe!