Update runAsync.md
This commit is contained in:
@ -1,12 +1,10 @@
|
|||||||
### runAsync
|
### runAsync
|
||||||
|
|
||||||
Runs a function in a separate thread by using a Web Worker, allowing
|
Runs a function in a separate thread by using a [Web Worker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers), allowing long running functions to not block the UI.
|
||||||
long running functions to not block the UI.
|
|
||||||
|
|
||||||
Create a new `Worker` using a `Blob` object URL, the contents of which should be the
|
Create a new `Worker` using a `Blob` object URL, the contents of which should be the stringified version of the supplied function.
|
||||||
stringified version of the supplied function. Immediately post the return value of calling
|
Immediately post the return value of calling the function back.
|
||||||
the function back. Return a promise, listening for `onmessage` and `onerror` events
|
Return a promise, listening for `onmessage` and `onerror` events and resolving the data posted back from the worker, or throwing an error.
|
||||||
and resolving the data posted back from the worker, or throwing an error.
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const runAsync = fn => {
|
const runAsync = fn => {
|
||||||
|
|||||||
Reference in New Issue
Block a user