From b53b03b81c3e63d1a27fa0bf90575cc129acb049 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 10 May 2024 22:11:24 +0200 Subject: [PATCH] rename methods --- lib/salix.js | 8 ++++---- mylogger.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/salix.js b/lib/salix.js index 25b0624..d3f296f 100644 --- a/lib/salix.js +++ b/lib/salix.js @@ -19,9 +19,9 @@ module.exports = class Salix { this._salixVersion = null; this._salixConfig = null; } - fooListener(val) {} - registerNewListener(externalListenerFunction) { - this.fooListener = externalListenerFunction; + emit() {} + subscribe(externalListenerFunction) { + this.emit = externalListenerFunction; } async init(logger) { this.conf = logger.conf; @@ -180,7 +180,7 @@ module.exports = class Salix { return this._salixVersion; } set salixVersion(newVersion) { - if(this._salixVersion) this.fooListener(newVersion); + if(this._salixVersion && (this._salixVersion!== newVersion)) this.emit(newVersion); this._salixVersion = newVersion; } diff --git a/mylogger.js b/mylogger.js index 4f0381b..f5599e2 100644 --- a/mylogger.js +++ b/mylogger.js @@ -22,7 +22,7 @@ module.exports = class MyLogger { async start() { const conf = (this.conf = loadConfig(__dirname, 'config')); const salix = new Salix(); - salix.registerNewListener(() => { + salix.subscribe(( ) => { this.stop(); this.start(); });