playing with workers
This commit is contained in:
parent
6eec4277c1
commit
0006f6483d
4 changed files with 38 additions and 41 deletions
|
|
@ -30,6 +30,13 @@ export function repl({
|
|||
started: false,
|
||||
};
|
||||
|
||||
const worker = new Worker(new URL('./deep-thought.js', import.meta.url));
|
||||
worker.postMessage({
|
||||
question: 'The Answer to the Ultimate Question of Life, The Universe, and Everything.',
|
||||
});
|
||||
worker.onmessage = ({ data: { answer } }) => {
|
||||
console.log(answer);
|
||||
};
|
||||
const updateState = (update) => {
|
||||
Object.assign(state, update);
|
||||
state.isDirty = state.code !== state.activeCode;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue