@nxtedition/deepstream.io-client-js 31.2.5 → 31.2.6
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 +33 -41
package/package.json
CHANGED
|
@@ -45,22 +45,18 @@ function onUpdate(record, subscription) {
|
|
|
45
45
|
|
|
46
46
|
if (!subscription.synced || subscription.record.state < subscription.state) {
|
|
47
47
|
if (subscription.timeoutValue > 0) {
|
|
48
|
-
if (!subscription.
|
|
49
|
-
subscription.
|
|
50
|
-
onTimeout,
|
|
51
|
-
subscription.timeoutValue,
|
|
52
|
-
subscription,
|
|
53
|
-
)
|
|
48
|
+
if (!subscription.timeout) {
|
|
49
|
+
subscription.timeout = timers.setTimeout(onTimeout, subscription.timeoutValue, subscription)
|
|
54
50
|
} else {
|
|
55
|
-
subscription.
|
|
51
|
+
subscription.timeout.refresh()
|
|
56
52
|
}
|
|
57
53
|
}
|
|
58
54
|
return
|
|
59
55
|
}
|
|
60
56
|
|
|
61
|
-
if (subscription.
|
|
62
|
-
timers.clearTimeout(subscription.
|
|
63
|
-
subscription.
|
|
57
|
+
if (subscription.timeout) {
|
|
58
|
+
timers.clearTimeout(subscription.timeout)
|
|
59
|
+
subscription.timeout = null
|
|
64
60
|
}
|
|
65
61
|
|
|
66
62
|
const data = subscription.path
|
|
@@ -634,8 +630,6 @@ class RecordHandler {
|
|
|
634
630
|
const subscription = {
|
|
635
631
|
/** @readonly @type {unknown} */
|
|
636
632
|
subscriber,
|
|
637
|
-
/** @type {Record|null} */
|
|
638
|
-
record: this.getRecord(name),
|
|
639
633
|
/** @readonly @type {unknown} */
|
|
640
634
|
path,
|
|
641
635
|
/** @readonly @type {number} */
|
|
@@ -647,53 +641,51 @@ class RecordHandler {
|
|
|
647
641
|
/** @readonly @type {number} */
|
|
648
642
|
timeoutValue: timeout,
|
|
649
643
|
|
|
644
|
+
/** @type {Record|null} */
|
|
645
|
+
record: null,
|
|
650
646
|
/** @type {Timeout|null} */
|
|
651
|
-
|
|
647
|
+
timeout: null,
|
|
652
648
|
/** @type {Function?} */
|
|
653
649
|
abort: null,
|
|
654
650
|
/** @type {object|Array} */
|
|
655
651
|
data: kEmpty,
|
|
656
652
|
/** @type {boolean} */
|
|
657
653
|
synced: false,
|
|
658
|
-
|
|
659
|
-
unsubscribe() {
|
|
660
|
-
if (this.timeoutHandle) {
|
|
661
|
-
timers.clearTimeout(this.timeoutHandle)
|
|
662
|
-
this.timeoutHandle = null
|
|
663
|
-
}
|
|
664
|
-
|
|
665
|
-
if (this.signal) {
|
|
666
|
-
utils.removeAbortListener(this.signal, this.abort)
|
|
667
|
-
this.abort = null
|
|
668
|
-
this.signal = null
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
if (this.record) {
|
|
672
|
-
this.record.unsubscribe(onUpdate, this)
|
|
673
|
-
this.record.unref()
|
|
674
|
-
this.record = null
|
|
675
|
-
}
|
|
676
|
-
},
|
|
677
654
|
}
|
|
678
655
|
|
|
679
|
-
|
|
680
|
-
subscription.
|
|
656
|
+
subscriber.add(() => {
|
|
657
|
+
if (subscription.timeout) {
|
|
658
|
+
timers.clearTimeout(subscription.timeout)
|
|
659
|
+
subscription.timeout = null
|
|
660
|
+
}
|
|
681
661
|
|
|
682
|
-
if (
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
subscription.
|
|
662
|
+
if (subscription.signal) {
|
|
663
|
+
utils.removeAbortListener(subscription.signal, subscription.abort)
|
|
664
|
+
subscription.abort = null
|
|
665
|
+
subscription.signal = null
|
|
686
666
|
}
|
|
687
|
-
|
|
667
|
+
|
|
668
|
+
if (subscription.record) {
|
|
669
|
+
subscription.record.unsubscribe(onUpdate, subscription)
|
|
670
|
+
subscription.record.unref()
|
|
671
|
+
subscription.record = null
|
|
672
|
+
}
|
|
673
|
+
})
|
|
688
674
|
|
|
689
675
|
if (subscription.signal) {
|
|
690
676
|
subscription.abort = () => subscriber.error(new utils.AbortError())
|
|
691
677
|
utils.addAbortListener(subscription.signal, subscription.abort)
|
|
692
678
|
}
|
|
693
679
|
|
|
694
|
-
|
|
680
|
+
subscription.record = this.getRecord(name).subscribe(onUpdate, subscription)
|
|
695
681
|
|
|
696
|
-
|
|
682
|
+
if (sync) {
|
|
683
|
+
this._sync(onSync, sync === true ? 'WEAK' : sync, subscription)
|
|
684
|
+
} else {
|
|
685
|
+
subscription.synced = true
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
onUpdate(subscription.record, subscription)
|
|
697
689
|
})
|
|
698
690
|
}
|
|
699
691
|
|