ports/webassembly: Add documentation on webworker support.

Signed-off-by: Emir Halıcı <emir.halici1@gmail.com>
pull/12118/head
Emir Halıcı 2023-07-29 21:19:06 +03:00
rodzic 5309938a1b
commit 01826acc96
1 zmienionych plików z 14 dodań i 0 usunięć

Wyświetl plik

@ -88,6 +88,20 @@ MicroPython code execution will suspend the browser so be sure to atomize usage
within this environment. Unfortunately interrupts have not been implemented for the
browser.
Running with WebWorkers on browsers
-----------------
To enable WebWorker support and receive messages outside of DOM, set `Module.webWorkerEventCallback` to a function that'll receive the events.
```
importScripts('micropython.js');
// ...
Module.webWorkerEventCallback = (event) => {
console.log(`Received an event from MicroPython!`);
};
```
WebWorkers on the web gives more flexibility to developers when consuming the WASM module. Example cases where this is useful are: not blocking main thread, creating and disposing multiple instances on a single session, using multiple instances for different purposes separate from each other...
Testing
-------