import {
type SetInfo,
type WorkerData,
+ type WorkerMessage,
WorkerMessageEvents,
type WorkerOptions,
type WorkerSetElement,
'message',
this.workerOptions.poolOptions?.messageHandler ?? WorkerConstants.EMPTY_FUNCTION,
);
+ worker.on('message', (message: WorkerMessage<WorkerData>) => {
+ if (message.event === WorkerMessageEvents.startedWorkerElement) {
+ this.emitter?.emit(WorkerSetEvents.elementStarted, message.data);
+ } else if (message.event === WorkerMessageEvents.startWorkerElementError) {
+ this.emitter?.emit(WorkerSetEvents.elementError, message.data);
+ }
+ });
worker.on(
'error',
this.workerOptions.poolOptions?.errorHandler ?? WorkerConstants.EMPTY_FUNCTION,
export enum WorkerSetEvents {
error = 'error',
+ elementStarted = 'elementStarted',
+ elementError = 'elementError',
}
export const WorkerEvents = {