workerizing

This commit is contained in:
Jade (Rose) Rowland 2024-01-09 22:49:39 -05:00
parent 0006f6483d
commit 19f2434694
2 changed files with 124 additions and 13 deletions

View file

@ -37,6 +37,14 @@ export function repl({
worker.onmessage = ({ data: { answer } }) => {
console.log(answer);
};
const sharedworker = new SharedWorker(new URL('./cyclistworker.js', import.meta.url));
sharedworker.port.start();
sharedworker.port.addEventListener('message', (message) => {
console.log(message);
});
const updateState = (update) => {
Object.assign(state, update);
state.isDirty = state.code !== state.activeCode;