public constructor (
type: string,
protected readonly isMain: boolean,
- protected readonly mainWorker: MainWorker,
+ private readonly mainWorker: MainWorker,
taskFunctions:
| WorkerFunction<Data, Response>
| TaskFunctions<Data, Response>,
/** @inheritDoc */
protected handleReadyMessage (message: MessageValue<Data>): void {
- if (message.workerId === this.id && message.ready != null) {
- !this.isMain && this.sendToMainWorker({ ready: true, workerId: this.id })
+ if (!this.isMain && message.workerId === this.id && message.ready != null) {
+ this.sendToMainWorker({ ready: true, workerId: this.id })
}
}
/** @inheritDoc */
protected handleReadyMessage (message: MessageValue<Data>): void {
if (
+ !this.isMain &&
message.workerId === this.id &&
message.ready != null &&
message.port != null
) {
- if (!this.isMain) {
- this.port = message.port
- this.port.on('message', this.messageListener.bind(this))
- this.sendToMainWorker({ ready: true, workerId: this.id })
- }
+ this.port = message.port
+ this.port.on('message', this.messageListener.bind(this))
+ this.sendToMainWorker({ ready: true, workerId: this.id })
}
}