@nxtedition/deepstream.io-client-js 23.1.23 → 23.2.0

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.1.23",
3
+ "version": "23.2.0",
4
4
  "description": "the javascript client for deepstream.io",
5
5
  "homepage": "http://deepstream.io",
6
6
  "bugs": {
@@ -19,6 +19,7 @@ class Record {
19
19
  this._subscribed = false
20
20
  this._subscriptions = []
21
21
  this._updating = null
22
+ this._patches = null
22
23
 
23
24
  this._subscribe()
24
25
  }
@@ -98,14 +99,14 @@ class Record {
98
99
  throw new Error('invalid argument: path')
99
100
  }
100
101
 
101
- if (!this._update(path, data, false)) {
102
- return
102
+ if (!this._version) {
103
+ this._patches = path && this._patches ? this._patches : []
104
+ this._patches.push(path, jsonPath.jsonClone(data))
105
+ this._handler._patch.add(this)
103
106
  }
104
107
 
105
- this._emitUpdate()
106
-
107
- if (this._state < Record.STATE.SERVER) {
108
- this._handler._patch.add(this)
108
+ if (this._update(path, data, false)) {
109
+ this._emitUpdate()
109
110
  }
110
111
  }
111
112
 
@@ -266,10 +267,14 @@ class Record {
266
267
  this._version = nextVersion
267
268
 
268
269
  const update = [this._name, nextVersion, jsonPath.stringify(data), prevVersion]
269
- this._handler._connection.sendMsg(C.TOPIC.RECORD, C.ACTIONS.UPDATE, update)
270
270
  this._updating ??= new Map()
271
271
  this._updating.set(nextVersion, update)
272
272
  this._handler._stats.updating += 1
273
+
274
+ const connection = this._handler._connection
275
+ if (connection.connected) {
276
+ connection.sendMsg(C.TOPIC.RECORD, C.ACTIONS.UPDATE, update)
277
+ }
273
278
  }
274
279
 
275
280
  return true
@@ -284,20 +289,24 @@ class Record {
284
289
  this._handler._stats.updating -= 1
285
290
  }
286
291
 
287
- if (!this._version) {
292
+ if (this._patches) {
288
293
  this._version = version
289
294
  this._data = jsonPath.parse(data)
290
295
 
291
296
  if (this._version.charAt(0) !== 'I') {
292
- this._update(null, prevData, true)
297
+ for (let n = 0; n < this._patches.length; n += 2) {
298
+ this._update(this._patches[n + 0], this._patches[n + 1], true)
299
+ }
293
300
  }
301
+
302
+ this._patches = null
303
+ this._handler._patch.delete(this)
294
304
  } else if (version.charAt(0) === 'I' || utils.compareRev(version, this._version) > 0) {
295
305
  this._version = version
296
306
  this._data = jsonPath.set(this._data, null, jsonPath.parse(data), true)
297
307
  }
298
308
 
299
309
  if (this._state < Record.STATE.SERVER) {
300
- this._handler._patch.delete(this)
301
310
  this._state = this._version.charAt(0) === 'I' ? Record.STATE.STALE : Record.STATE.SERVER
302
311
  }
303
312