@nxtedition/deepstream.io-client-js 24.1.0 → 24.1.1
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
package/src/record/record.js
CHANGED
|
@@ -10,6 +10,8 @@ class Record {
|
|
|
10
10
|
static STATE = C.RECORD_STATE
|
|
11
11
|
|
|
12
12
|
constructor(name, handler) {
|
|
13
|
+
const connection = handler._connection
|
|
14
|
+
|
|
13
15
|
this._handler = handler
|
|
14
16
|
|
|
15
17
|
this._name = name
|
|
@@ -21,7 +23,7 @@ class Record {
|
|
|
21
23
|
this._emitting = false
|
|
22
24
|
/** @type Map? */ this._updating = null
|
|
23
25
|
/** @type Array? */ this._patching = null
|
|
24
|
-
this._subscribed =
|
|
26
|
+
this._subscribed = connection.sendMsg1(C.TOPIC.RECORD, C.ACTIONS.SUBSCRIBE, this._name)
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
/** @type {string} */
|
|
@@ -53,10 +55,13 @@ class Record {
|
|
|
53
55
|
* @returns {Record}
|
|
54
56
|
*/
|
|
55
57
|
ref() {
|
|
58
|
+
const connection = this._handler._connection
|
|
59
|
+
|
|
56
60
|
this._refs += 1
|
|
57
61
|
if (this._refs === 1) {
|
|
58
62
|
this._handler._onPruning(this, false)
|
|
59
|
-
this._subscribed =
|
|
63
|
+
this._subscribed =
|
|
64
|
+
this._subscribed || connection.sendMsg1(C.TOPIC.RECORD, C.ACTIONS.SUBSCRIBE, this._name)
|
|
60
65
|
}
|
|
61
66
|
return this
|
|
62
67
|
}
|
|
@@ -261,12 +266,15 @@ class Record {
|
|
|
261
266
|
}
|
|
262
267
|
|
|
263
268
|
_$onConnectionStateChange(connected) {
|
|
269
|
+
const connection = this._handler._connection
|
|
270
|
+
|
|
264
271
|
if (connected) {
|
|
265
|
-
this._subscribed =
|
|
272
|
+
this._subscribed =
|
|
273
|
+
this._refs > 0 && connection.sendMsg1(C.TOPIC.RECORD, C.ACTIONS.SUBSCRIBE, this._name)
|
|
266
274
|
|
|
267
275
|
if (this._updating) {
|
|
268
276
|
for (const update of this._updating.values()) {
|
|
269
|
-
|
|
277
|
+
connection.sendMsg(C.TOPIC.RECORD, C.ACTIONS.UPDATE, update)
|
|
270
278
|
}
|
|
271
279
|
}
|
|
272
280
|
} else {
|
|
@@ -280,12 +288,14 @@ class Record {
|
|
|
280
288
|
}
|
|
281
289
|
|
|
282
290
|
_$dispose() {
|
|
291
|
+
const connection = this._handler._connection
|
|
292
|
+
|
|
283
293
|
invariant(!this._refs, 'must not have refs')
|
|
284
294
|
invariant(!this._patching, 'must not have patches')
|
|
285
295
|
invariant(!this._updating, 'must not have updates')
|
|
286
296
|
|
|
287
297
|
if (this._subscribed) {
|
|
288
|
-
|
|
298
|
+
connection.sendMsg1(C.TOPIC.RECORD, C.ACTIONS.UNSUBSCRIBE, this._name)
|
|
289
299
|
this._subscribed = false
|
|
290
300
|
}
|
|
291
301
|
|
|
@@ -414,10 +424,6 @@ class Record {
|
|
|
414
424
|
}
|
|
415
425
|
}
|
|
416
426
|
|
|
417
|
-
_sendMsg1(action, data) {
|
|
418
|
-
return this._handler._connection.sendMsg1(C.TOPIC.RECORD, action, data)
|
|
419
|
-
}
|
|
420
|
-
|
|
421
427
|
_error(event, msgOrError, data) {
|
|
422
428
|
this._handler._client._$onError(C.TOPIC.RECORD, event, msgOrError, [
|
|
423
429
|
...(Array.isArray(data) ? data : []),
|
|
@@ -10,6 +10,7 @@ class Listener {
|
|
|
10
10
|
this._handler = handler
|
|
11
11
|
this._client = this._handler._client
|
|
12
12
|
this._connection = this._handler._connection
|
|
13
|
+
this._connected = false
|
|
13
14
|
this._subscriptions = new Map()
|
|
14
15
|
this._stringify = stringify || JSON.stringify
|
|
15
16
|
|
|
@@ -39,10 +40,6 @@ class Listener {
|
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
get connected() {
|
|
43
|
-
return this._client.getConnectionState() === C.CONNECTION_STATE.OPEN
|
|
44
|
-
}
|
|
45
|
-
|
|
46
43
|
get stats() {
|
|
47
44
|
return {
|
|
48
45
|
subscriptions: this._subscriptions.size,
|
|
@@ -52,13 +49,13 @@ class Listener {
|
|
|
52
49
|
_$destroy() {
|
|
53
50
|
this._reset()
|
|
54
51
|
|
|
55
|
-
if (this.
|
|
52
|
+
if (this._connected) {
|
|
56
53
|
this._connection.sendMsg(this._topic, C.ACTIONS.UNLISTEN, [this._pattern])
|
|
57
54
|
}
|
|
58
55
|
}
|
|
59
56
|
|
|
60
57
|
_$onMessage(message) {
|
|
61
|
-
if (!this.
|
|
58
|
+
if (!this._connected) {
|
|
62
59
|
this._client._$onError(
|
|
63
60
|
C.TOPIC.RECORD,
|
|
64
61
|
C.EVENT.NOT_CONNECTED,
|
|
@@ -122,8 +119,10 @@ class Listener {
|
|
|
122
119
|
return true
|
|
123
120
|
}
|
|
124
121
|
|
|
125
|
-
_$onConnectionStateChange() {
|
|
126
|
-
|
|
122
|
+
_$onConnectionStateChange(connected) {
|
|
123
|
+
this._connected = connected
|
|
124
|
+
|
|
125
|
+
if (connected) {
|
|
127
126
|
this._connection.sendMsg(this._topic, C.ACTIONS.LISTEN, [this._pattern, 'U'])
|
|
128
127
|
} else {
|
|
129
128
|
this._reset()
|