Skip to content

Latest commit

 

History

History
38 lines (27 loc) · 660 Bytes

worker.md

File metadata and controls

38 lines (27 loc) · 660 Bytes

Worker

Limitations (Currently):

  • Can not use script classes (GodotJSScript) in workers
  • transferable objects are not supported
  • onerror event is not implemented

A Simple Example

// tests/master.ts
// ...

let worker = new Worker("tests/worker");
worker.onmessage = function (m: any) {
    console.log("master: get message", m);
    worker.terminate();
}
worker.postMessage("hello");
// tests/worker.ts

onmessage = function (m: any) {
    console.log("worker: get message", m);
    postMessage("worker result");

    // worker can terminate itself by calling `close()`
    // close();
}

Go Back