playing with workers

This commit is contained in:
Jade (Rose) Rowland 2024-01-09 19:39:21 -05:00
parent 6eec4277c1
commit 0006f6483d
4 changed files with 38 additions and 41 deletions

View file

@ -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;