um-react/src/decrypt-worker/client.ts

13 lines
571 B
TypeScript
Raw Normal View History

2023-05-09 00:22:00 +00:00
import { WorkerClientBus } from '~/util/WorkerEventBus';
import { DECRYPTION_WORKER_ACTION_NAME } from './constants';
2023-05-16 21:47:47 +00:00
import { DecryptionQueue } from '~/util/DecryptionQueue';
// TODO: Worker pool?
2023-05-08 15:23:46 +00:00
export const workerClient = new Worker(new URL('./worker', import.meta.url), { type: 'module' });
// FIXME: report the error so is obvious to the user.
workerClient.onerror = (err) => console.error(err);
export const workerClientBus = new WorkerClientBus<DECRYPTION_WORKER_ACTION_NAME>(workerClient);
export const decryptionQueue = new DecryptionQueue(workerClientBus);