fix: flag worker set as stopped as soon the stopped event is emitted
[e-mobility-charging-stations-simulator.git] / src / charging-station / ChargingStationWorker.ts
index 4eb6e6a0aa8d8a13ed7091e8255f35029ed62fce..2623f1272d2f19142715f12bfaadaff469294ddb 100644 (file)
@@ -19,8 +19,8 @@ export let chargingStationWorker: object
 if (Configuration.workerPoolInUse()) {
   chargingStationWorker = new ThreadWorker<ChargingStationWorkerData>(
     (data?: ChargingStationWorkerData): void => {
-      // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
-      new ChargingStation(data!.index, data!.templateFile).add()
+      // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, no-new
+      new ChargingStation(data!.index, data!.templateFile, data!.options)
     }
   )
 } else {
@@ -33,9 +33,9 @@ if (Configuration.workerPoolInUse()) {
             try {
               const chargingStation = new ChargingStation(
                 message.data.index,
-                message.data.templateFile
+                message.data.templateFile,
+                message.data.options
               )
-              chargingStation.add()
               parentPort?.postMessage({
                 event: WorkerMessageEvents.addedWorkerElement,
                 data: buildChargingStationDataPayload(chargingStation)