FrontEnd.ro logo
Deci FrontEnd-ul e doar butoane?
// Create a new Web Worker
let myWorker = new Worker('worker.js');

// Send data to it
myWorker.postMessage("Here's some data");

// Receive data from it
myWorker.addEventListener('message', (e) => {
  // ...
});
// worker.js

// Receive data from main app
self.addEventListener('message', (e) => {
  // ...


  // Send data back to main app
  self.postMessage(/* ... */);
});