Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

123
Views
Updating value from UDP socket using svelte store

I am trying to update a variable whenever I receive data from udp. The connection is working fine and when I send some data I am getting it in the console correctly. But seems the variable is not being updated. I want to use the variable from a svelte component that will update in the browser. i am using sveltekit.

import { writable } from 'svelte/store';
import dgram from 'dgram';

const Socket = () => {
    const server = dgram.createSocket({type:"udp4",reuseAddr:true});
    server.bind(4444);

  const temperature = writable(0);

  const getTemperature = () => {
    return temperature;
  }

  server.on('message', (msg, rinfo) => {
      var data = JSON.parse(msg);
      temperature.set(data.message);
      console.log(temperature);
  });

  return { getTemperature };
};

export default Socket;
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!