@nxtedition/deepstream.io-client-js 28.1.18 → 28.1.21
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 +41 -4
- package/src/record/record.js +4 -0
package/package.json
CHANGED
|
@@ -102,7 +102,7 @@ class RecordHandler {
|
|
|
102
102
|
this._pruning = new Set()
|
|
103
103
|
this._patching = new Map()
|
|
104
104
|
this._updating = new Map()
|
|
105
|
-
this._putting = new
|
|
105
|
+
this._putting = new Map()
|
|
106
106
|
|
|
107
107
|
this._connected = 0
|
|
108
108
|
this._stats = {
|
|
@@ -257,12 +257,15 @@ class RecordHandler {
|
|
|
257
257
|
this._stats.listeners += 1
|
|
258
258
|
this._listeners.set(pattern, listener)
|
|
259
259
|
|
|
260
|
-
|
|
260
|
+
const disposer = () => {
|
|
261
261
|
listener._$destroy()
|
|
262
262
|
|
|
263
263
|
this._stats.listeners -= 1
|
|
264
264
|
this._listeners.delete(pattern)
|
|
265
265
|
}
|
|
266
|
+
disposer[Symbol.dispose] = disposer
|
|
267
|
+
|
|
268
|
+
return disposer
|
|
266
269
|
}
|
|
267
270
|
|
|
268
271
|
async sync(opts) {
|
|
@@ -284,6 +287,40 @@ class RecordHandler {
|
|
|
284
287
|
|
|
285
288
|
signalPromise?.catch(noop)
|
|
286
289
|
|
|
290
|
+
if (this._putting.size) {
|
|
291
|
+
const promises = []
|
|
292
|
+
|
|
293
|
+
{
|
|
294
|
+
const puttingPromises = []
|
|
295
|
+
for (const callbacks of this._putting.values()) {
|
|
296
|
+
puttingPromises.push(new Promise((resolve) => callbacks.push(resolve)))
|
|
297
|
+
}
|
|
298
|
+
promises.push(puttingPromises)
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
if (timeout) {
|
|
302
|
+
promises.push(
|
|
303
|
+
new Promise((resolve) => {
|
|
304
|
+
const patchingTimeout = timers.setTimeout(() => {
|
|
305
|
+
this._client._$onError(
|
|
306
|
+
C.TOPIC.RECORD,
|
|
307
|
+
C.EVENT.TIMEOUT,
|
|
308
|
+
new Error('sync putting timeout'),
|
|
309
|
+
)
|
|
310
|
+
resolve(null)
|
|
311
|
+
}, timeout)
|
|
312
|
+
disposers.push(() => timers.clearTimeout(patchingTimeout))
|
|
313
|
+
}),
|
|
314
|
+
)
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
if (signalPromise) {
|
|
318
|
+
promises.push(signalPromise)
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
await Promise.race(promises)
|
|
322
|
+
}
|
|
323
|
+
|
|
287
324
|
if (this._patching.size) {
|
|
288
325
|
const promises = []
|
|
289
326
|
|
|
@@ -429,7 +466,7 @@ class RecordHandler {
|
|
|
429
466
|
const update = [name, version, jsonPath.stringify(data)]
|
|
430
467
|
this._connection.sendMsg(C.TOPIC.RECORD, C.ACTIONS.PUT, update)
|
|
431
468
|
|
|
432
|
-
this._putting.
|
|
469
|
+
this._putting.set(update, [])
|
|
433
470
|
this._sync((update) => {
|
|
434
471
|
this._putting.delete(update)
|
|
435
472
|
}, update)
|
|
@@ -694,7 +731,7 @@ class RecordHandler {
|
|
|
694
731
|
this._connection.sendMsg(C.TOPIC.RECORD, C.ACTIONS.SYNC, [token])
|
|
695
732
|
}
|
|
696
733
|
|
|
697
|
-
for (const update of this._putting) {
|
|
734
|
+
for (const update of this._putting.keys()) {
|
|
698
735
|
this._connection.sendMsg(C.TOPIC.RECORD, C.ACTIONS.PUT, update)
|
|
699
736
|
}
|
|
700
737
|
} else {
|