This commit is contained in:
Ilya Kantor 2019-07-01 23:51:14 +03:00
parent 36bf2af5fd
commit 5c56e0d54b
7 changed files with 11 additions and 1 deletions

View file

@ -337,3 +337,13 @@ To schedule a new microtask:
There's no UI or network event handling between microtasks: they run immediately one after another.
So one may want to `queueMicrotask` to execute a function asynchronously, but also with the same application state.
```smart header="Web Workers"
For long heavy calculations that shouldn't block the event loop, we can use [Web Workers](https://html.spec.whatwg.org/multipage/workers.html).
That's a way to run code in another, parallel thread.
Web Workers can exchange messages with the main process, but they have their own variables, and their own event loop.
Web Workers do not have access to DOM, so they are useful, mainly, for calculations, to use multiplle CPU cores simultaneously.
```