Skip to content

Web Workers

Arturo Vasquez edited this page Apr 18, 2021 · 4 revisions

To work with Web Worker

get the Web Workers API interface

   let wwapi=genrl.ww;

Set the Web Worker

   wwapi.set('worker1',"./src/mods/worker1.js");

Activate the Web Worker

   wwapi.send('worker1',"Hola");

How to code the Web Worker:

this.onmessage = function(e) {
  var mensaje;
  mensaje = e.data;
  console.log('Message received: ' + mensaje);
  if(mensaje=="Hola"){
    console.log('Cómo estás?');
    console.log('Adiós!');
  }
}

Search into the pages for more info

Clone this wiki locally