Coder Social home page Coder Social logo

Comments (4)

s00500 avatar s00500 commented on June 12, 2024

I unfortunatly also just realized that I cant use
this.ws = new WebSocket(this.url, this.protocols);
at all....

neither window.WebSocket(this.url, this.protocols);

from plenti.

jimafisk avatar jimafisk commented on June 12, 2024

@s00500 - I assume you're getting a build error like ReferenceError: ReconnectingWebSocket is not defined, is that correct?

The build process creates both the interactive clientside JS (which has access to browser objects like window) and HTML fallbacks (which don't have access to the browser / runtime JS). If I have something that needs to be run clientside only, I typically wrap it in onMount so it's ignored by the SSR part of the build that creates the HTML.

Can you try putting the clientside logic inside onMount and let me know if that help? For example:

<script>
  import { ReconnectingWebSocket } from "../scripts/reconnecting-ws.js";
  import { onMount } from 'svelte';

  let ws;
  onMount(() => {                             
    ws = new ReconnectingWebSocket("ws://localhost:3", []);
  });
</script>

from plenti.

s00500 avatar s00500 commented on June 12, 2024

Hey @jimafisk, that nailed it! Thanks a lot !!!
(would ofc be awesome to have a error that can be traced easier ;-) )

from plenti.

jimafisk avatar jimafisk commented on June 12, 2024

Awesome, I'm glad it worked @s00500, thanks for following up!

from plenti.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.