Optimize worker handlers calls by binding them to the current instance
[e-mobility-charging-stations-simulator.git] / src / charging-station / Bootstrap.ts
index 329c5546dcde0a255add2c4a136652d2b337cc61..64b35d536fa6a175875ef5bb1648e94ba4e3ae50 100644 (file)
@@ -19,6 +19,7 @@ import {
 } from '../types/ChargingStationWorker';
 import type { StationTemplateUrl } from '../types/ConfigurationData';
 import type { Statistics } from '../types/Statistics';
+import type { MessageHandler } from '../types/Worker';
 import Configuration from '../utils/Configuration';
 import logger from '../utils/Logger';
 import Utils from '../utils/Utils';
@@ -178,10 +179,7 @@ export class Bootstrap {
           poolOptions: {
             workerChoiceStrategy: Configuration.getWorker().poolStrategy,
           },
-          messageHandler: this.messageHandler.bind(this) as (
-            this: Worker,
-            msg: ChargingStationWorkerMessage<ChargingStationWorkerMessageData>
-          ) => void,
+          messageHandler: this.messageHandler.bind(this) as MessageHandler<Worker>,
         }
       ));
   }