🪛 Workers!

This commit is contained in:
2021-04-27 13:04:53 -07:00
parent 2d8423c516
commit 71693da709
5 changed files with 31 additions and 22 deletions

View File

@@ -1,17 +1,19 @@
// const worker: DedicatedWorkerGlobalScope = self as any;
// worker.onmessage = ({ data }) => {
// if (data instanceof Array) {
// worker.postMessage(data.join(" ") + "!");
// }
// };
import { expose } from "comlink";
const foo = (value: string) => {
return "rishi" + " " + value;
};
class ExpensiveProcessor {
_foo: string;
/* ... async methods here ... */
constructor() {
this._foo = "rishi";
}
}
const bar = (value: number) => {
return value + 10;
};
const exported = {
foo,
bar,
};
export type Worker = typeof exported;
expose(exported);
expose(ExpensiveProcessor, self);