refactor: use classic setter in configuration class
authorJérôme Benoit <jerome.benoit@sap.com>
Sat, 9 Sep 2023 10:38:33 +0000 (12:38 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Sat, 9 Sep 2023 10:38:33 +0000 (12:38 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/Bootstrap.ts
src/utils/Configuration.ts

index 00ca6e3ca24a2dc31f9bf6a654ea469167b320c4..66b2d5f835146782bdb9a703b5002c9ab540146c 100644 (file)
@@ -99,7 +99,7 @@ export class Bootstrap extends EventEmitter {
         performanceStorageConfiguration.uri!,
         this.logPrefix(),
       ));
-    Configuration.setConfigurationChangeCallback(async () => Bootstrap.getInstance().restart());
+    Configuration.configurationChangeCallback = async () => Bootstrap.getInstance().restart();
   }
 
   public static getInstance(): Bootstrap {
index 8dc1f70a610dcb3f20de922c71fe2f8e5c1eae01..b9ba72a5b44b955e308e26b9b77982834efee775 100644 (file)
@@ -60,13 +60,11 @@ export class Configuration {
     [ConfigurationSection.uiServer, Configuration.buildUIServerSection()],
   ]);
 
-  private static configurationChangeCallback?: () => Promise<void>;
-
   private constructor() {
     // This is intentional
   }
 
-  public static setConfigurationChangeCallback(cb: () => Promise<void>): void {
+  public static set configurationChangeCallback(cb: () => Promise<void>) {
     Configuration.configurationChangeCallback = cb;
   }
 
@@ -542,7 +540,7 @@ export class Configuration {
           delete Configuration.configurationData;
           Configuration.configurationSectionCache.clear();
           if (!isUndefined(Configuration.configurationChangeCallback)) {
-            Configuration.configurationChangeCallback!().catch((error) => {
+            Configuration.configurationChangeCallback().catch((error) => {
               throw typeof error === 'string' ? new Error(error) : error;
             });
           }