From 7ed58ad9ee8f366a752305098c7e1206e824caf0 Mon Sep 17 00:00:00 2001 From: Massimo Candela Date: Wed, 12 Jan 2022 14:13:10 +0100 Subject: [PATCH] minor change to improve performance onMessage --- src/connectors/connectorRIS.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/connectors/connectorRIS.js b/src/connectors/connectorRIS.js index 79ba0624..106a40a0 100644 --- a/src/connectors/connectorRIS.js +++ b/src/connectors/connectorRIS.js @@ -74,16 +74,21 @@ export default class ConnectorRIS extends Connector { } }; + _messageToJsonCanary = (message) => { + this._checkCanary(); + this._message(JSON.parse(message)); + }; + _messageToJson = (message) => { - const messageObj = JSON.parse(message); - if (this._shouldCanaryMonitoringStart()) { - this._checkCanary(); - } - this._message(messageObj); + this._message(JSON.parse(message)); }; _appendListeners = (resolve, reject) => { - this.ws.on('message', this._messageToJson); + if (this._shouldCanaryMonitoringStart()) { + this.ws.on('message', this._messageToJsonCanary); + } else { + this.ws.on('message', this._messageToJson); + } this.ws.on('close', (error) => { if (this.connected) {