@tanstack/vue-query 4.29.5 → 4.29.7
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.
|
@@ -6,21 +6,24 @@
|
|
|
6
6
|
|
|
7
7
|
class Subscribable {
|
|
8
8
|
constructor() {
|
|
9
|
-
this.listeners =
|
|
9
|
+
this.listeners = new Set();
|
|
10
10
|
this.subscribe = this.subscribe.bind(this);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
subscribe(listener) {
|
|
14
|
-
|
|
14
|
+
const identity = {
|
|
15
|
+
listener
|
|
16
|
+
};
|
|
17
|
+
this.listeners.add(identity);
|
|
15
18
|
this.onSubscribe();
|
|
16
19
|
return () => {
|
|
17
|
-
this.listeners
|
|
20
|
+
this.listeners.delete(identity);
|
|
18
21
|
this.onUnsubscribe();
|
|
19
22
|
};
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
hasListeners() {
|
|
23
|
-
return this.listeners.
|
|
26
|
+
return this.listeners.size > 0;
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
onSubscribe() {// Do nothing
|
|
@@ -411,7 +414,9 @@
|
|
|
411
414
|
}
|
|
412
415
|
|
|
413
416
|
onFocus() {
|
|
414
|
-
this.listeners.forEach(
|
|
417
|
+
this.listeners.forEach(({
|
|
418
|
+
listener
|
|
419
|
+
}) => {
|
|
415
420
|
listener();
|
|
416
421
|
});
|
|
417
422
|
}
|
|
@@ -494,7 +499,9 @@
|
|
|
494
499
|
}
|
|
495
500
|
|
|
496
501
|
onOnline() {
|
|
497
|
-
this.listeners.forEach(
|
|
502
|
+
this.listeners.forEach(({
|
|
503
|
+
listener
|
|
504
|
+
}) => {
|
|
498
505
|
listener();
|
|
499
506
|
});
|
|
500
507
|
}
|
|
@@ -1361,7 +1368,9 @@
|
|
|
1361
1368
|
|
|
1362
1369
|
notify(event) {
|
|
1363
1370
|
notifyManager.batch(() => {
|
|
1364
|
-
this.listeners.forEach(
|
|
1371
|
+
this.listeners.forEach(({
|
|
1372
|
+
listener
|
|
1373
|
+
}) => {
|
|
1365
1374
|
listener(event);
|
|
1366
1375
|
});
|
|
1367
1376
|
});
|
|
@@ -1703,7 +1712,9 @@
|
|
|
1703
1712
|
|
|
1704
1713
|
notify(event) {
|
|
1705
1714
|
notifyManager.batch(() => {
|
|
1706
|
-
this.listeners.forEach(
|
|
1715
|
+
this.listeners.forEach(({
|
|
1716
|
+
listener
|
|
1717
|
+
}) => {
|
|
1707
1718
|
listener(event);
|
|
1708
1719
|
});
|
|
1709
1720
|
});
|
|
@@ -2229,7 +2240,7 @@
|
|
|
2229
2240
|
}
|
|
2230
2241
|
|
|
2231
2242
|
onSubscribe() {
|
|
2232
|
-
if (this.listeners.
|
|
2243
|
+
if (this.listeners.size === 1) {
|
|
2233
2244
|
this.currentQuery.addObserver(this);
|
|
2234
2245
|
|
|
2235
2246
|
if (shouldFetchOnMount(this.currentQuery, this.options)) {
|
|
@@ -2241,7 +2252,7 @@
|
|
|
2241
2252
|
}
|
|
2242
2253
|
|
|
2243
2254
|
onUnsubscribe() {
|
|
2244
|
-
if (!this.
|
|
2255
|
+
if (!this.hasListeners()) {
|
|
2245
2256
|
this.destroy();
|
|
2246
2257
|
}
|
|
2247
2258
|
}
|
|
@@ -2255,7 +2266,7 @@
|
|
|
2255
2266
|
}
|
|
2256
2267
|
|
|
2257
2268
|
destroy() {
|
|
2258
|
-
this.listeners =
|
|
2269
|
+
this.listeners = new Set();
|
|
2259
2270
|
this.clearStaleTimeout();
|
|
2260
2271
|
this.clearRefetchInterval();
|
|
2261
2272
|
this.currentQuery.removeObserver(this);
|
|
@@ -2684,7 +2695,9 @@
|
|
|
2684
2695
|
|
|
2685
2696
|
|
|
2686
2697
|
if (notifyOptions.listeners) {
|
|
2687
|
-
this.listeners.forEach(
|
|
2698
|
+
this.listeners.forEach(({
|
|
2699
|
+
listener
|
|
2700
|
+
}) => {
|
|
2688
2701
|
listener(this.currentResult);
|
|
2689
2702
|
});
|
|
2690
2703
|
} // Then the cache listeners
|
|
@@ -2741,7 +2754,7 @@
|
|
|
2741
2754
|
}
|
|
2742
2755
|
|
|
2743
2756
|
onSubscribe() {
|
|
2744
|
-
if (this.listeners.
|
|
2757
|
+
if (this.listeners.size === 1) {
|
|
2745
2758
|
this.observers.forEach(observer => {
|
|
2746
2759
|
observer.subscribe(result => {
|
|
2747
2760
|
this.onUpdate(observer, result);
|
|
@@ -2751,13 +2764,13 @@
|
|
|
2751
2764
|
}
|
|
2752
2765
|
|
|
2753
2766
|
onUnsubscribe() {
|
|
2754
|
-
if (!this.listeners.
|
|
2767
|
+
if (!this.listeners.size) {
|
|
2755
2768
|
this.destroy();
|
|
2756
2769
|
}
|
|
2757
2770
|
}
|
|
2758
2771
|
|
|
2759
2772
|
destroy() {
|
|
2760
|
-
this.listeners =
|
|
2773
|
+
this.listeners = new Set();
|
|
2761
2774
|
this.observers.forEach(observer => {
|
|
2762
2775
|
observer.destroy();
|
|
2763
2776
|
});
|
|
@@ -2877,7 +2890,9 @@
|
|
|
2877
2890
|
|
|
2878
2891
|
notify() {
|
|
2879
2892
|
notifyManager.batch(() => {
|
|
2880
|
-
this.listeners.forEach(
|
|
2893
|
+
this.listeners.forEach(({
|
|
2894
|
+
listener
|
|
2895
|
+
}) => {
|
|
2881
2896
|
listener(this.result);
|
|
2882
2897
|
});
|
|
2883
2898
|
});
|
|
@@ -2998,7 +3013,7 @@
|
|
|
2998
3013
|
}
|
|
2999
3014
|
|
|
3000
3015
|
onUnsubscribe() {
|
|
3001
|
-
if (!this.
|
|
3016
|
+
if (!this.hasListeners()) {
|
|
3002
3017
|
var _this$currentMutation2;
|
|
3003
3018
|
|
|
3004
3019
|
(_this$currentMutation2 = this.currentMutation) == null ? void 0 : _this$currentMutation2.removeObserver(this);
|
|
@@ -3079,7 +3094,9 @@
|
|
|
3079
3094
|
|
|
3080
3095
|
|
|
3081
3096
|
if (options.listeners) {
|
|
3082
|
-
this.listeners.forEach(
|
|
3097
|
+
this.listeners.forEach(({
|
|
3098
|
+
listener
|
|
3099
|
+
}) => {
|
|
3083
3100
|
listener(this.currentResult);
|
|
3084
3101
|
});
|
|
3085
3102
|
}
|