Tinker
This commit is contained in:
parent
d62f6077ce
commit
0dfaa15923
1 changed files with 4 additions and 11 deletions
|
@ -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}`);
|
||||
|
|
Loading…
Add table
Reference in a new issue