@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/deepstream.io-client-js",
3
- "version": "31.2.5",
3
+ "version": "31.2.6",
4
4
  "description": "the javascript client for deepstream.io",
5
5
  "homepage": "http://deepstream.io",
6
6
  "type": "module",
@@ -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.timeoutHandle) {
49
- subscription.timeoutHandle = timers.setTimeout(
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.timeoutHandle.refresh()
51
+ subscription.timeout.refresh()
56
52
  }
57
53
  }
58
54
  return
59
55
  }
60
56
 
61
- if (subscription.timeoutHandle) {
62
- timers.clearTimeout(subscription.timeoutHandle)
63
- subscription.timeoutHandle = null
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
- timeoutHandle: null,
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
- if (subscription.record) {
680
- subscription.record.subscribe(onUpdate, subscription)
656
+ subscriber.add(() => {
657
+ if (subscription.timeout) {
658
+ timers.clearTimeout(subscription.timeout)
659
+ subscription.timeout = null
660
+ }
681
661
 
682
- if (sync && subscription.record.state >= C.RECORD_STATE.SERVER) {
683
- this._sync(onSync, sync === true ? 'WEAK' : sync, subscription)
684
- } else {
685
- subscription.synced = true
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
- onUpdate(subscription.record, subscription)
680
+ subscription.record = this.getRecord(name).subscribe(onUpdate, subscription)
695
681
 
696
- return subscription
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