@nxtedition/deepstream.io-client-js 24.1.3 → 24.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/deepstream.io-client-js",
3
- "version": "24.1.3",
3
+ "version": "24.1.5",
4
4
  "description": "the javascript client for deepstream.io",
5
5
  "homepage": "http://deepstream.io",
6
6
  "bugs": {
@@ -13,7 +13,7 @@ class Listener {
13
13
  this._recursive = recursive
14
14
  this._stringify = stringify || JSON.stringify
15
15
 
16
- this._$onConnectionStateChange(this._connection.connected)
16
+ this._$onConnectionStateChange()
17
17
  }
18
18
 
19
19
  get connected() {
@@ -209,8 +209,8 @@ class Listener {
209
209
  return true
210
210
  }
211
211
 
212
- _$onConnectionStateChange(connected) {
213
- if (connected) {
212
+ _$onConnectionStateChange() {
213
+ if (this.connected) {
214
214
  this._connection.sendMsg(this._topic, C.ACTIONS.LISTEN, [this._pattern])
215
215
  } else {
216
216
  this._reset()
@@ -38,7 +38,7 @@ class Listener {
38
38
  this._connection = this._handler._connection
39
39
  this._subscriptions = new Map()
40
40
 
41
- this._$onConnectionStateChange(this._connection.connected)
41
+ this._$onConnectionStateChange()
42
42
  }
43
43
 
44
44
  get connected() {
@@ -90,8 +90,8 @@ class Listener {
90
90
  next: (data) => {
91
91
  if (data == null) {
92
92
  this._connection.sendMsg(this._topic, C.ACTIONS.LISTEN_REJECT, [this._pattern, name])
93
+ this._subscriptions.delete(name)
93
94
  subscription.unsubscribe()
94
- this._subscriptions.set(name, null)
95
95
  } else {
96
96
  const version = `INF-${this._connection.hasher.h64ToString(data)}`
97
97
  this._connection.sendMsg(this._topic, C.ACTIONS.UPDATE, [name, version, data])
@@ -100,32 +100,31 @@ class Listener {
100
100
  error: (err) => {
101
101
  this._error(name, err)
102
102
  this._connection.sendMsg(this._topic, C.ACTIONS.LISTEN_REJECT, [this._pattern, name])
103
+ this._subscriptions.delete(name)
103
104
  },
104
105
  })
105
106
  this._subscriptions.set(name, subscription)
106
107
  } else {
107
108
  this._connection.sendMsg(this._topic, C.ACTIONS.LISTEN_REJECT, [this._pattern, name])
108
- this._subscriptions.set(name, null)
109
+ this._subscriptions.delete(name)
109
110
  }
110
111
  } else if (message.action === C.ACTIONS.LISTEN_REJECT) {
111
- if (!this._subscriptions.has(name)) {
112
- this._error(name, 'invalid remove: listener missing')
113
- return
114
- }
115
-
116
112
  const subscription = this._subscriptions.get(name)
117
113
 
118
- subscription?.unsubscribe()
119
-
120
- this._subscriptions.delete(name)
114
+ if (subscription) {
115
+ this._subscriptions.delete(name)
116
+ subscription.unsubscribe()
117
+ } else {
118
+ this._error(name, 'invalid remove: listener missing')
119
+ }
121
120
  } else {
122
121
  return false
123
122
  }
124
123
  return true
125
124
  }
126
125
 
127
- _$onConnectionStateChange(connected) {
128
- if (connected) {
126
+ _$onConnectionStateChange() {
127
+ if (this.connected) {
129
128
  this._connection.sendMsg(this._topic, C.ACTIONS.LISTEN, [this._pattern, 'U'])
130
129
  } else {
131
130
  this._reset()