🍔 Worker biting back

This commit is contained in:
2021-04-27 13:59:44 -07:00
parent 71693da709
commit d38309001f
6 changed files with 52 additions and 30 deletions

View File

@@ -1,19 +1,3 @@
// const worker: DedicatedWorkerGlobalScope = self as any;
// worker.onmessage = ({ data }) => {
// if (data instanceof Array) {
// worker.postMessage(data.join(" ") + "!");
// }
// };
import { expose } from "comlink";
class ExpensiveProcessor {
_foo: string;
/* ... async methods here ... */
constructor() {
this._foo = "rishi";
}
}
expose(ExpensiveProcessor, self);
export async function greet(subject: string): string {
return `Hello, ${subject}!`;
}