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(); });