@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 +1 -1
- package/src/utils/unicast-listener.js +40 -30
package/package.json
CHANGED
|
@@ -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.
|
|
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
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (value
|
|
67
|
-
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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])
|