@nxtedition/deepstream.io-client-js 23.4.6 → 23.4.8

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": "23.4.6",
3
+ "version": "23.4.8",
4
4
  "description": "the javascript client for deepstream.io",
5
5
  "homepage": "http://deepstream.io",
6
6
  "bugs": {
@@ -11,7 +11,8 @@ class Listener {
11
11
  this._connection = this._handler._connection
12
12
  this._subscriptions = new Map()
13
13
  this._stringify = stringify || JSON.stringify
14
- this._value = null
14
+ this._data = ''
15
+ this._version = ''
15
16
 
16
17
  this._$onConnectionStateChange()
17
18
 
@@ -59,36 +60,45 @@ class Listener {
59
60
  }
60
61
 
61
62
  if (value$) {
62
- const subscription = value$.subscribe({
63
- next: (value) => {
64
- let data
65
- if (value && typeof value === 'string') {
66
- if (value.charAt(0) !== '{' && value.charAt(0) !== '[') {
67
- throw new Error(`invalid value: ${value}`)
63
+ const subscription = value$
64
+ .pipe(
65
+ rxjs.map((value) => {
66
+ let data
67
+ if (value && typeof value === 'string') {
68
+ if (value.charAt(0) !== '{' && value.charAt(0) !== '[') {
69
+ throw new Error(`invalid value: ${value}`)
70
+ }
71
+ data = value
72
+ } else if (value && typeof value === 'object') {
73
+ data = this._stringify(value)
68
74
  }
69
- data = value
70
- } else if (value && typeof value === 'object') {
71
- data = this._stringify(value)
72
- } else {
73
- throw new Error(`invalid value: ${value}`)
74
- }
75
-
76
- if (value === this._value) {
77
- return
78
- }
79
-
80
- this._value = value
81
- this._connection.sendMsg(this._topic, C.ACTIONS.UPDATE, [
82
- name,
83
- `INF-${this._connection.hasher.h64ToString(data)}`,
84
- data,
85
- ])
86
- },
87
- error: (err) => {
88
- this._error(name, err)
89
- this._connection.sendMsg(this._topic, C.ACTIONS.LISTEN_REJECT, [this._pattern, name])
90
- },
91
- })
75
+
76
+ return data
77
+ }),
78
+ rxjs.takeWhile(Boolean)
79
+ )
80
+ .subscribe({
81
+ next: (data) => {
82
+ if (data === this._data) {
83
+ return
84
+ }
85
+
86
+ this._data = data
87
+ this._version = `INF-${this._connection.hasher.h64ToString(data)}`
88
+ this._connection.sendMsg(this._topic, C.ACTIONS.UPDATE, [
89
+ name,
90
+ this._version,
91
+ this._data,
92
+ ])
93
+ },
94
+ error: (err) => {
95
+ this._error(name, err)
96
+ this._connection.sendMsg(this._topic, C.ACTIONS.LISTEN_REJECT, [this._pattern, name])
97
+ },
98
+ complete: () => {
99
+ this._connection.sendMsg(this._topic, C.ACTIONS.LISTEN_REJECT, [this._pattern, name])
100
+ },
101
+ })
92
102
  this._subscriptions.set(name, subscription)
93
103
  } else {
94
104
  this._connection.sendMsg(this._topic, C.ACTIONS.LISTEN_REJECT, [this._pattern, name])