From 9f139e99d5c59592faad743f3285b26acc03b7c9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 9 Sep 2023 12:38:33 +0200 Subject: [PATCH] refactor: use classic setter in configuration class MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/Bootstrap.ts | 2 +- src/utils/Configuration.ts | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) 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; }); } -- 2.34.1