🔧 Web workers

This commit is contained in:
2021-04-27 09:50:51 -07:00
parent 15dcdcfe43
commit 3a5bf12ba6
9 changed files with 48 additions and 62 deletions

View File

@@ -1,7 +0,0 @@
import { exposeWorker } from "react-hooks-worker";
const fib = (i) => {
return i * 9;
};
exposeWorker(fib);

View File

@@ -0,0 +1,10 @@
import strategy from "clooney";
class Actor {
timeoutThing() {
return new Promise(resolve => setTimeout(_ => resolve('ohai'), 1000));
}
}
const instance = await strategy.spawn(Actor);
alert(await instance.timeoutThing()); // Will alert() after 1 second