@nxtedition/deepstream.io-client-js 23.4.9 → 23.4.10
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/record/record-handler.js +28 -5
package/package.json
CHANGED
|
@@ -35,6 +35,7 @@ class RecordHandler {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
this._syncEmitter = new EventEmitter()
|
|
38
|
+
this._syncQueue = null
|
|
38
39
|
|
|
39
40
|
this.set = this.set.bind(this)
|
|
40
41
|
this.get = this.get.bind(this)
|
|
@@ -83,6 +84,8 @@ class RecordHandler {
|
|
|
83
84
|
|
|
84
85
|
this._pruneInterval = setInterval(_prune, 1e3)
|
|
85
86
|
this._pruneInterval.unref?.()
|
|
87
|
+
|
|
88
|
+
this._syncAll = this._syncAll.bind(this)
|
|
86
89
|
}
|
|
87
90
|
|
|
88
91
|
_onRef(rec) {
|
|
@@ -241,18 +244,38 @@ class RecordHandler {
|
|
|
241
244
|
return
|
|
242
245
|
}
|
|
243
246
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
if (this._connected) {
|
|
248
|
-
this._connection.sendMsg(C.TOPIC.RECORD, C.ACTIONS.SYNC, [token])
|
|
247
|
+
if (!this._syncQueue) {
|
|
248
|
+
this._syncQueue = []
|
|
249
|
+
queueMicrotask(this._syncAll)
|
|
249
250
|
}
|
|
251
|
+
|
|
252
|
+
this._syncQueue.push(onToken)
|
|
250
253
|
},
|
|
251
254
|
(err) => onDone(Promise.reject(err))
|
|
252
255
|
)
|
|
253
256
|
})
|
|
254
257
|
}
|
|
255
258
|
|
|
259
|
+
_syncAll() {
|
|
260
|
+
if (!this._syncQueue) {
|
|
261
|
+
return
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const syncQueue = this._syncQueue
|
|
265
|
+
const token = xuid()
|
|
266
|
+
|
|
267
|
+
this._syncQueue = null
|
|
268
|
+
this._syncEmitter.once(token, () => {
|
|
269
|
+
for (const callback of syncQueue) {
|
|
270
|
+
callback()
|
|
271
|
+
}
|
|
272
|
+
})
|
|
273
|
+
|
|
274
|
+
if (this._connected) {
|
|
275
|
+
this._connection.sendMsg(C.TOPIC.RECORD, C.ACTIONS.SYNC, [token])
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
256
279
|
set(name, ...args) {
|
|
257
280
|
const record = this.getRecord(name)
|
|
258
281
|
try {
|