From: Jérôme Benoit Date: Sat, 9 Sep 2023 10:38:33 +0000 (+0200) Subject: refactor: use classic setter in configuration class X-Git-Tag: v1.2.21~4 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=9f139e99d5c59592faad743f3285b26acc03b7c9;p=e-mobility-charging-stations-simulator.git refactor: use classic setter in configuration class Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/Bootstrap.ts b/src/charging-station/Bootstrap.ts index 00ca6e3c..66b2d5f8 100644 --- a/src/charging-station/Bootstrap.ts +++ b/src/charging-station/Bootstrap.ts @@ -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 { diff --git a/src/utils/Configuration.ts b/src/utils/Configuration.ts index 8dc1f70a..b9ba72a5 100644 --- a/src/utils/Configuration.ts +++ b/src/utils/Configuration.ts @@ -60,13 +60,11 @@ export class Configuration { [ConfigurationSection.uiServer, Configuration.buildUIServerSection()], ]); - private static configurationChangeCallback?: () => Promise; - private constructor() { // This is intentional } - public static setConfigurationChangeCallback(cb: () => Promise): void { + public static set configurationChangeCallback(cb: () => Promise) { 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; }); }