This commit is contained in:
Manav Rathi 2024-04-20 21:09:35 +05:30
parent d62f6077ce
commit 0dfaa15923
No known key found for this signature in database

View file

@ -12,24 +12,17 @@ export class ComlinkWorker<T extends new () => InstanceType<T>> {
this.name = name;
this.worker = worker;
this.worker.onerror = (ev) => {
worker.onerror = (event) => {
log.error(
`Got error event from worker: ${JSON.stringify({
errorEvent: JSON.stringify(ev),
name: this.name,
})}`,
`Got error event from worker: ${JSON.stringify({ event, name })}`,
);
};
log.debug(() => `Initiated ${this.name}`);
const comlink = wrap<T>(this.worker);
log.debug(() => `Initiated web worker ${name}`);
const comlink = wrap<T>(worker);
this.remote = new comlink() as Promise<Remote<InstanceType<T>>>;
expose(workerBridge, worker);
}
public getName() {
return this.name;
}
public terminate() {
this.worker.terminate();
log.debug(() => `Terminated ${this.name}`);