@tanstack/query-core 5.0.0-alpha.3 → 5.0.0-alpha.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/build/lib/_virtual/_rollupPluginBabelHelpers.esm.js +13 -0
- package/build/lib/_virtual/_rollupPluginBabelHelpers.esm.js.map +1 -0
- package/build/lib/_virtual/_rollupPluginBabelHelpers.js +16 -0
- package/build/lib/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
- package/build/lib/focusManager.esm.js +31 -15
- package/build/lib/focusManager.esm.js.map +1 -1
- package/build/lib/focusManager.js +31 -15
- package/build/lib/focusManager.js.map +1 -1
- package/build/lib/hydration.esm.js +4 -2
- package/build/lib/hydration.esm.js.map +1 -1
- package/build/lib/hydration.js +4 -2
- package/build/lib/hydration.js.map +1 -1
- package/build/lib/infiniteQueryBehavior.d.ts +2 -2
- package/build/lib/infiniteQueryBehavior.esm.js +52 -48
- package/build/lib/infiniteQueryBehavior.esm.js.map +1 -1
- package/build/lib/infiniteQueryBehavior.js +52 -48
- package/build/lib/infiniteQueryBehavior.js.map +1 -1
- package/build/lib/infiniteQueryBehavior.mjs +48 -45
- package/build/lib/infiniteQueryBehavior.mjs.map +1 -1
- package/build/lib/infiniteQueryObserver.d.ts +6 -6
- package/build/lib/infiniteQueryObserver.esm.js +7 -8
- package/build/lib/infiniteQueryObserver.esm.js.map +1 -1
- package/build/lib/infiniteQueryObserver.js +7 -8
- package/build/lib/infiniteQueryObserver.js.map +1 -1
- package/build/lib/infiniteQueryObserver.mjs +4 -6
- package/build/lib/infiniteQueryObserver.mjs.map +1 -1
- package/build/lib/mutation.esm.js +127 -102
- package/build/lib/mutation.esm.js.map +1 -1
- package/build/lib/mutation.js +127 -102
- package/build/lib/mutation.js.map +1 -1
- package/build/lib/mutationCache.esm.js +30 -17
- package/build/lib/mutationCache.esm.js.map +1 -1
- package/build/lib/mutationCache.js +30 -17
- package/build/lib/mutationCache.js.map +1 -1
- package/build/lib/mutationObserver.esm.js +81 -51
- package/build/lib/mutationObserver.esm.js.map +1 -1
- package/build/lib/mutationObserver.js +81 -51
- package/build/lib/mutationObserver.js.map +1 -1
- package/build/lib/onlineManager.esm.js +29 -14
- package/build/lib/onlineManager.esm.js.map +1 -1
- package/build/lib/onlineManager.js +29 -14
- package/build/lib/onlineManager.js.map +1 -1
- package/build/lib/queriesObserver.esm.js +94 -65
- package/build/lib/queriesObserver.esm.js.map +1 -1
- package/build/lib/queriesObserver.js +94 -65
- package/build/lib/queriesObserver.js.map +1 -1
- package/build/lib/query.d.ts +4 -3
- package/build/lib/query.esm.js +210 -161
- package/build/lib/query.esm.js.map +1 -1
- package/build/lib/query.js +210 -161
- package/build/lib/query.js.map +1 -1
- package/build/lib/query.mjs.map +1 -1
- package/build/lib/queryCache.esm.js +16 -9
- package/build/lib/queryCache.esm.js.map +1 -1
- package/build/lib/queryCache.js +16 -9
- package/build/lib/queryCache.js.map +1 -1
- package/build/lib/queryClient.esm.js +103 -63
- package/build/lib/queryClient.esm.js.map +1 -1
- package/build/lib/queryClient.js +103 -63
- package/build/lib/queryClient.js.map +1 -1
- package/build/lib/queryObserver.esm.js +308 -207
- package/build/lib/queryObserver.esm.js.map +1 -1
- package/build/lib/queryObserver.js +307 -206
- package/build/lib/queryObserver.js.map +1 -1
- package/build/lib/removable.esm.js +13 -6
- package/build/lib/removable.esm.js.map +1 -1
- package/build/lib/removable.js +13 -6
- package/build/lib/removable.js.map +1 -1
- package/build/lib/retryer.esm.js +15 -14
- package/build/lib/retryer.esm.js.map +1 -1
- package/build/lib/retryer.js +15 -14
- package/build/lib/retryer.js.map +1 -1
- package/build/lib/tests/utils.d.ts +4 -5
- package/build/lib/types.d.ts +5 -3
- package/build/lib/utils.esm.js +1 -1
- package/build/lib/utils.esm.js.map +1 -1
- package/build/lib/utils.js +1 -1
- package/build/lib/utils.js.map +1 -1
- package/build/umd/index.development.js +52 -51
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/infiniteQueryBehavior.ts +52 -60
- package/src/infiniteQueryObserver.ts +15 -10
- package/src/query.ts +6 -4
- package/src/tests/focusManager.test.tsx +12 -14
- package/src/tests/hydration.test.tsx +15 -14
- package/src/tests/infiniteQueryBehavior.test.tsx +16 -9
- package/src/tests/infiniteQueryObserver.test.tsx +62 -1
- package/src/tests/mutationCache.test.tsx +11 -10
- package/src/tests/mutationObserver.test.tsx +3 -2
- package/src/tests/mutations.test.tsx +11 -10
- package/src/tests/notifyManager.test.tsx +7 -6
- package/src/tests/onlineManager.test.tsx +12 -17
- package/src/tests/queriesObserver.test.tsx +18 -17
- package/src/tests/query.test.tsx +18 -17
- package/src/tests/queryCache.test.tsx +14 -13
- package/src/tests/queryClient.test.tsx +49 -48
- package/src/tests/queryObserver.test.tsx +10 -9
- package/src/tests/utils.test.tsx +2 -1
- package/src/tests/utils.ts +5 -4
- package/src/types.ts +9 -1
|
@@ -1,31 +1,128 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var _rollupPluginBabelHelpers = require('./_virtual/_rollupPluginBabelHelpers.js');
|
|
3
4
|
var utils = require('./utils.js');
|
|
4
5
|
var notifyManager = require('./notifyManager.js');
|
|
5
6
|
var focusManager = require('./focusManager.js');
|
|
6
7
|
var subscribable = require('./subscribable.js');
|
|
7
8
|
var retryer = require('./retryer.js');
|
|
8
9
|
|
|
10
|
+
var _client = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("client");
|
|
11
|
+
var _currentQuery = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("currentQuery");
|
|
12
|
+
var _currentQueryInitialState = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("currentQueryInitialState");
|
|
13
|
+
var _currentResult = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("currentResult");
|
|
14
|
+
var _currentResultState = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("currentResultState");
|
|
15
|
+
var _currentResultOptions = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("currentResultOptions");
|
|
16
|
+
var _previousQueryResult = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("previousQueryResult");
|
|
17
|
+
var _selectError = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("selectError");
|
|
18
|
+
var _selectFn = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("selectFn");
|
|
19
|
+
var _selectResult = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("selectResult");
|
|
20
|
+
var _staleTimeoutId = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("staleTimeoutId");
|
|
21
|
+
var _refetchIntervalId = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("refetchIntervalId");
|
|
22
|
+
var _currentRefetchInterval = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("currentRefetchInterval");
|
|
23
|
+
var _trackedProps = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("trackedProps");
|
|
24
|
+
var _executeFetch = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("executeFetch");
|
|
25
|
+
var _updateStaleTimeout = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("updateStaleTimeout");
|
|
26
|
+
var _computeRefetchInterval = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("computeRefetchInterval");
|
|
27
|
+
var _updateRefetchInterval = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("updateRefetchInterval");
|
|
28
|
+
var _updateTimers = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("updateTimers");
|
|
29
|
+
var _clearStaleTimeout = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("clearStaleTimeout");
|
|
30
|
+
var _clearRefetchInterval = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("clearRefetchInterval");
|
|
31
|
+
var _updateResult = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("updateResult");
|
|
32
|
+
var _updateQuery = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("updateQuery");
|
|
33
|
+
var _notify = /*#__PURE__*/_rollupPluginBabelHelpers.classPrivateFieldLooseKey("notify");
|
|
9
34
|
class QueryObserver extends subscribable.Subscribable {
|
|
10
|
-
#client;
|
|
11
|
-
#currentQuery = undefined;
|
|
12
|
-
#currentQueryInitialState = undefined;
|
|
13
|
-
#currentResult = undefined;
|
|
14
|
-
#currentResultState;
|
|
15
|
-
#currentResultOptions;
|
|
16
|
-
#previousQueryResult;
|
|
17
|
-
#selectError;
|
|
18
|
-
#selectFn;
|
|
19
|
-
#selectResult;
|
|
20
|
-
#staleTimeoutId;
|
|
21
|
-
#refetchIntervalId;
|
|
22
|
-
#currentRefetchInterval;
|
|
23
|
-
#trackedProps = new Set();
|
|
24
35
|
constructor(client, options) {
|
|
25
36
|
super();
|
|
26
|
-
this
|
|
37
|
+
Object.defineProperty(this, _notify, {
|
|
38
|
+
value: _notify2
|
|
39
|
+
});
|
|
40
|
+
Object.defineProperty(this, _updateQuery, {
|
|
41
|
+
value: _updateQuery2
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(this, _updateResult, {
|
|
44
|
+
value: _updateResult2
|
|
45
|
+
});
|
|
46
|
+
Object.defineProperty(this, _clearRefetchInterval, {
|
|
47
|
+
value: _clearRefetchInterval2
|
|
48
|
+
});
|
|
49
|
+
Object.defineProperty(this, _clearStaleTimeout, {
|
|
50
|
+
value: _clearStaleTimeout2
|
|
51
|
+
});
|
|
52
|
+
Object.defineProperty(this, _updateTimers, {
|
|
53
|
+
value: _updateTimers2
|
|
54
|
+
});
|
|
55
|
+
Object.defineProperty(this, _updateRefetchInterval, {
|
|
56
|
+
value: _updateRefetchInterval2
|
|
57
|
+
});
|
|
58
|
+
Object.defineProperty(this, _computeRefetchInterval, {
|
|
59
|
+
value: _computeRefetchInterval2
|
|
60
|
+
});
|
|
61
|
+
Object.defineProperty(this, _updateStaleTimeout, {
|
|
62
|
+
value: _updateStaleTimeout2
|
|
63
|
+
});
|
|
64
|
+
Object.defineProperty(this, _executeFetch, {
|
|
65
|
+
value: _executeFetch2
|
|
66
|
+
});
|
|
67
|
+
Object.defineProperty(this, _client, {
|
|
68
|
+
writable: true,
|
|
69
|
+
value: void 0
|
|
70
|
+
});
|
|
71
|
+
Object.defineProperty(this, _currentQuery, {
|
|
72
|
+
writable: true,
|
|
73
|
+
value: undefined
|
|
74
|
+
});
|
|
75
|
+
Object.defineProperty(this, _currentQueryInitialState, {
|
|
76
|
+
writable: true,
|
|
77
|
+
value: undefined
|
|
78
|
+
});
|
|
79
|
+
Object.defineProperty(this, _currentResult, {
|
|
80
|
+
writable: true,
|
|
81
|
+
value: undefined
|
|
82
|
+
});
|
|
83
|
+
Object.defineProperty(this, _currentResultState, {
|
|
84
|
+
writable: true,
|
|
85
|
+
value: void 0
|
|
86
|
+
});
|
|
87
|
+
Object.defineProperty(this, _currentResultOptions, {
|
|
88
|
+
writable: true,
|
|
89
|
+
value: void 0
|
|
90
|
+
});
|
|
91
|
+
Object.defineProperty(this, _previousQueryResult, {
|
|
92
|
+
writable: true,
|
|
93
|
+
value: void 0
|
|
94
|
+
});
|
|
95
|
+
Object.defineProperty(this, _selectError, {
|
|
96
|
+
writable: true,
|
|
97
|
+
value: void 0
|
|
98
|
+
});
|
|
99
|
+
Object.defineProperty(this, _selectFn, {
|
|
100
|
+
writable: true,
|
|
101
|
+
value: void 0
|
|
102
|
+
});
|
|
103
|
+
Object.defineProperty(this, _selectResult, {
|
|
104
|
+
writable: true,
|
|
105
|
+
value: void 0
|
|
106
|
+
});
|
|
107
|
+
Object.defineProperty(this, _staleTimeoutId, {
|
|
108
|
+
writable: true,
|
|
109
|
+
value: void 0
|
|
110
|
+
});
|
|
111
|
+
Object.defineProperty(this, _refetchIntervalId, {
|
|
112
|
+
writable: true,
|
|
113
|
+
value: void 0
|
|
114
|
+
});
|
|
115
|
+
Object.defineProperty(this, _currentRefetchInterval, {
|
|
116
|
+
writable: true,
|
|
117
|
+
value: void 0
|
|
118
|
+
});
|
|
119
|
+
Object.defineProperty(this, _trackedProps, {
|
|
120
|
+
writable: true,
|
|
121
|
+
value: new Set()
|
|
122
|
+
});
|
|
123
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _client)[_client] = client;
|
|
27
124
|
this.options = options;
|
|
28
|
-
this
|
|
125
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _selectError)[_selectError] = null;
|
|
29
126
|
this.bindMethods();
|
|
30
127
|
this.setOptions(options);
|
|
31
128
|
}
|
|
@@ -34,11 +131,11 @@ class QueryObserver extends subscribable.Subscribable {
|
|
|
34
131
|
}
|
|
35
132
|
onSubscribe() {
|
|
36
133
|
if (this.listeners.length === 1) {
|
|
37
|
-
this
|
|
38
|
-
if (shouldFetchOnMount(this
|
|
39
|
-
this
|
|
134
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery].addObserver(this);
|
|
135
|
+
if (shouldFetchOnMount(_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery], this.options)) {
|
|
136
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _executeFetch)[_executeFetch]();
|
|
40
137
|
}
|
|
41
|
-
this
|
|
138
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _updateTimers)[_updateTimers]();
|
|
42
139
|
}
|
|
43
140
|
}
|
|
44
141
|
onUnsubscribe() {
|
|
@@ -47,25 +144,25 @@ class QueryObserver extends subscribable.Subscribable {
|
|
|
47
144
|
}
|
|
48
145
|
}
|
|
49
146
|
shouldFetchOnReconnect() {
|
|
50
|
-
return shouldFetchOn(this
|
|
147
|
+
return shouldFetchOn(_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery], this.options, this.options.refetchOnReconnect);
|
|
51
148
|
}
|
|
52
149
|
shouldFetchOnWindowFocus() {
|
|
53
|
-
return shouldFetchOn(this
|
|
150
|
+
return shouldFetchOn(_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery], this.options, this.options.refetchOnWindowFocus);
|
|
54
151
|
}
|
|
55
152
|
destroy() {
|
|
56
153
|
this.listeners = [];
|
|
57
|
-
this
|
|
58
|
-
this
|
|
59
|
-
this
|
|
154
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _clearStaleTimeout)[_clearStaleTimeout]();
|
|
155
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _clearRefetchInterval)[_clearRefetchInterval]();
|
|
156
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery].removeObserver(this);
|
|
60
157
|
}
|
|
61
158
|
setOptions(options, notifyOptions) {
|
|
62
159
|
const prevOptions = this.options;
|
|
63
|
-
const prevQuery = this
|
|
64
|
-
this.options = this
|
|
160
|
+
const prevQuery = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery];
|
|
161
|
+
this.options = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _client)[_client].defaultQueryOptions(options);
|
|
65
162
|
if (!utils.shallowEqualObjects(prevOptions, this.options)) {
|
|
66
|
-
this
|
|
163
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _client)[_client].getQueryCache().notify({
|
|
67
164
|
type: 'observerOptionsUpdated',
|
|
68
|
-
query: this
|
|
165
|
+
query: _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery],
|
|
69
166
|
observer: this
|
|
70
167
|
});
|
|
71
168
|
}
|
|
@@ -77,34 +174,34 @@ class QueryObserver extends subscribable.Subscribable {
|
|
|
77
174
|
if (!this.options.queryKey) {
|
|
78
175
|
this.options.queryKey = prevOptions.queryKey;
|
|
79
176
|
}
|
|
80
|
-
this
|
|
177
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _updateQuery)[_updateQuery]();
|
|
81
178
|
const mounted = this.hasListeners();
|
|
82
179
|
|
|
83
180
|
// Fetch if there are subscribers
|
|
84
|
-
if (mounted && shouldFetchOptionally(this
|
|
85
|
-
this
|
|
181
|
+
if (mounted && shouldFetchOptionally(_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery], prevQuery, this.options, prevOptions)) {
|
|
182
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _executeFetch)[_executeFetch]();
|
|
86
183
|
}
|
|
87
184
|
|
|
88
185
|
// Update result
|
|
89
|
-
this
|
|
186
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _updateResult)[_updateResult](notifyOptions);
|
|
90
187
|
|
|
91
188
|
// Update stale interval if needed
|
|
92
|
-
if (mounted && (this
|
|
93
|
-
this
|
|
189
|
+
if (mounted && (_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery] !== prevQuery || this.options.enabled !== prevOptions.enabled || this.options.staleTime !== prevOptions.staleTime)) {
|
|
190
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _updateStaleTimeout)[_updateStaleTimeout]();
|
|
94
191
|
}
|
|
95
|
-
const nextRefetchInterval = this
|
|
192
|
+
const nextRefetchInterval = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _computeRefetchInterval)[_computeRefetchInterval]();
|
|
96
193
|
|
|
97
194
|
// Update refetch interval if needed
|
|
98
|
-
if (mounted && (this
|
|
99
|
-
this
|
|
195
|
+
if (mounted && (_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery] !== prevQuery || this.options.enabled !== prevOptions.enabled || nextRefetchInterval !== _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentRefetchInterval)[_currentRefetchInterval])) {
|
|
196
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _updateRefetchInterval)[_updateRefetchInterval](nextRefetchInterval);
|
|
100
197
|
}
|
|
101
198
|
}
|
|
102
199
|
getOptimisticResult(options) {
|
|
103
|
-
const query = this
|
|
200
|
+
const query = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _client)[_client].getQueryCache().build(_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _client)[_client], options);
|
|
104
201
|
return this.createResult(query, options);
|
|
105
202
|
}
|
|
106
203
|
getCurrentResult() {
|
|
107
|
-
return this
|
|
204
|
+
return _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResult)[_currentResult];
|
|
108
205
|
}
|
|
109
206
|
trackResult(result) {
|
|
110
207
|
const trackedResult = {};
|
|
@@ -113,7 +210,7 @@ class QueryObserver extends subscribable.Subscribable {
|
|
|
113
210
|
configurable: false,
|
|
114
211
|
enumerable: true,
|
|
115
212
|
get: () => {
|
|
116
|
-
this
|
|
213
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _trackedProps)[_trackedProps].add(key);
|
|
117
214
|
return result[key];
|
|
118
215
|
}
|
|
119
216
|
});
|
|
@@ -121,7 +218,7 @@ class QueryObserver extends subscribable.Subscribable {
|
|
|
121
218
|
return trackedResult;
|
|
122
219
|
}
|
|
123
220
|
getCurrentQuery() {
|
|
124
|
-
return this
|
|
221
|
+
return _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery];
|
|
125
222
|
}
|
|
126
223
|
refetch({
|
|
127
224
|
...options
|
|
@@ -131,87 +228,30 @@ class QueryObserver extends subscribable.Subscribable {
|
|
|
131
228
|
});
|
|
132
229
|
}
|
|
133
230
|
fetchOptimistic(options) {
|
|
134
|
-
const defaultedOptions = this
|
|
135
|
-
const query = this
|
|
231
|
+
const defaultedOptions = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _client)[_client].defaultQueryOptions(options);
|
|
232
|
+
const query = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _client)[_client].getQueryCache().build(_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _client)[_client], defaultedOptions);
|
|
136
233
|
query.isFetchingOptimistic = true;
|
|
137
234
|
return query.fetch().then(() => this.createResult(query, defaultedOptions));
|
|
138
235
|
}
|
|
139
236
|
fetch(fetchOptions) {
|
|
140
|
-
|
|
237
|
+
var _fetchOptions$cancelR;
|
|
238
|
+
return _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _executeFetch)[_executeFetch]({
|
|
141
239
|
...fetchOptions,
|
|
142
|
-
cancelRefetch: fetchOptions.cancelRefetch
|
|
240
|
+
cancelRefetch: (_fetchOptions$cancelR = fetchOptions.cancelRefetch) != null ? _fetchOptions$cancelR : true
|
|
143
241
|
}).then(() => {
|
|
144
|
-
this
|
|
145
|
-
return this
|
|
242
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _updateResult)[_updateResult]();
|
|
243
|
+
return _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResult)[_currentResult];
|
|
146
244
|
});
|
|
147
245
|
}
|
|
148
|
-
#executeFetch(fetchOptions) {
|
|
149
|
-
// Make sure we reference the latest query as the current one might have been removed
|
|
150
|
-
this.#updateQuery();
|
|
151
|
-
|
|
152
|
-
// Fetch
|
|
153
|
-
let promise = this.#currentQuery.fetch(this.options, fetchOptions);
|
|
154
|
-
if (!fetchOptions?.throwOnError) {
|
|
155
|
-
promise = promise.catch(utils.noop);
|
|
156
|
-
}
|
|
157
|
-
return promise;
|
|
158
|
-
}
|
|
159
|
-
#updateStaleTimeout() {
|
|
160
|
-
this.#clearStaleTimeout();
|
|
161
|
-
if (utils.isServer || this.#currentResult.isStale || !utils.isValidTimeout(this.options.staleTime)) {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
const time = utils.timeUntilStale(this.#currentResult.dataUpdatedAt, this.options.staleTime);
|
|
165
|
-
|
|
166
|
-
// The timeout is sometimes triggered 1 ms before the stale time expiration.
|
|
167
|
-
// To mitigate this issue we always add 1 ms to the timeout.
|
|
168
|
-
const timeout = time + 1;
|
|
169
|
-
this.#staleTimeoutId = setTimeout(() => {
|
|
170
|
-
if (!this.#currentResult.isStale) {
|
|
171
|
-
this.#updateResult();
|
|
172
|
-
}
|
|
173
|
-
}, timeout);
|
|
174
|
-
}
|
|
175
|
-
#computeRefetchInterval() {
|
|
176
|
-
return typeof this.options.refetchInterval === 'function' ? this.options.refetchInterval(this.#currentResult.data, this.#currentQuery) : this.options.refetchInterval ?? false;
|
|
177
|
-
}
|
|
178
|
-
#updateRefetchInterval(nextInterval) {
|
|
179
|
-
this.#clearRefetchInterval();
|
|
180
|
-
this.#currentRefetchInterval = nextInterval;
|
|
181
|
-
if (utils.isServer || this.options.enabled === false || !utils.isValidTimeout(this.#currentRefetchInterval) || this.#currentRefetchInterval === 0) {
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
this.#refetchIntervalId = setInterval(() => {
|
|
185
|
-
if (this.options.refetchIntervalInBackground || focusManager.focusManager.isFocused()) {
|
|
186
|
-
this.#executeFetch();
|
|
187
|
-
}
|
|
188
|
-
}, this.#currentRefetchInterval);
|
|
189
|
-
}
|
|
190
|
-
#updateTimers() {
|
|
191
|
-
this.#updateStaleTimeout();
|
|
192
|
-
this.#updateRefetchInterval(this.#computeRefetchInterval());
|
|
193
|
-
}
|
|
194
|
-
#clearStaleTimeout() {
|
|
195
|
-
if (this.#staleTimeoutId) {
|
|
196
|
-
clearTimeout(this.#staleTimeoutId);
|
|
197
|
-
this.#staleTimeoutId = undefined;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
#clearRefetchInterval() {
|
|
201
|
-
if (this.#refetchIntervalId) {
|
|
202
|
-
clearInterval(this.#refetchIntervalId);
|
|
203
|
-
this.#refetchIntervalId = undefined;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
246
|
createResult(query, options) {
|
|
207
|
-
const prevQuery = this
|
|
247
|
+
const prevQuery = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery];
|
|
208
248
|
const prevOptions = this.options;
|
|
209
|
-
const prevResult = this
|
|
210
|
-
const prevResultState = this
|
|
211
|
-
const prevResultOptions = this
|
|
249
|
+
const prevResult = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResult)[_currentResult];
|
|
250
|
+
const prevResultState = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResultState)[_currentResultState];
|
|
251
|
+
const prevResultOptions = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResultOptions)[_currentResultOptions];
|
|
212
252
|
const queryChange = query !== prevQuery;
|
|
213
|
-
const queryInitialState = queryChange ? query.state : this
|
|
214
|
-
const prevQueryResult = queryChange ? this
|
|
253
|
+
const queryInitialState = queryChange ? query.state : _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQueryInitialState)[_currentQueryInitialState];
|
|
254
|
+
const prevQueryResult = queryChange ? _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResult)[_currentResult] : _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _previousQueryResult)[_previousQueryResult];
|
|
215
255
|
const {
|
|
216
256
|
state
|
|
217
257
|
} = query;
|
|
@@ -243,17 +283,17 @@ class QueryObserver extends subscribable.Subscribable {
|
|
|
243
283
|
// Select data if needed
|
|
244
284
|
if (options.select && typeof state.data !== 'undefined') {
|
|
245
285
|
// Memoize select result
|
|
246
|
-
if (prevResult && state.data === prevResultState
|
|
247
|
-
data = this
|
|
286
|
+
if (prevResult && state.data === (prevResultState == null ? void 0 : prevResultState.data) && options.select === _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _selectFn)[_selectFn]) {
|
|
287
|
+
data = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _selectResult)[_selectResult];
|
|
248
288
|
} else {
|
|
249
289
|
try {
|
|
250
|
-
this
|
|
290
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _selectFn)[_selectFn] = options.select;
|
|
251
291
|
data = options.select(state.data);
|
|
252
|
-
data = utils.replaceData(prevResult
|
|
253
|
-
this
|
|
254
|
-
this
|
|
292
|
+
data = utils.replaceData(prevResult == null ? void 0 : prevResult.data, data, options);
|
|
293
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _selectResult)[_selectResult] = data;
|
|
294
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _selectError)[_selectError] = null;
|
|
255
295
|
} catch (selectError) {
|
|
256
|
-
this
|
|
296
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _selectError)[_selectError] = selectError;
|
|
257
297
|
}
|
|
258
298
|
}
|
|
259
299
|
}
|
|
@@ -267,28 +307,28 @@ class QueryObserver extends subscribable.Subscribable {
|
|
|
267
307
|
let placeholderData;
|
|
268
308
|
|
|
269
309
|
// Memoize placeholder data
|
|
270
|
-
if (prevResult
|
|
310
|
+
if (prevResult != null && prevResult.isPlaceholderData && options.placeholderData === (prevResultOptions == null ? void 0 : prevResultOptions.placeholderData)) {
|
|
271
311
|
placeholderData = prevResult.data;
|
|
272
312
|
} else {
|
|
273
|
-
placeholderData = typeof options.placeholderData === 'function' ? options.placeholderData(prevQueryResult
|
|
313
|
+
placeholderData = typeof options.placeholderData === 'function' ? options.placeholderData(prevQueryResult == null ? void 0 : prevQueryResult.data) : options.placeholderData;
|
|
274
314
|
if (options.select && typeof placeholderData !== 'undefined') {
|
|
275
315
|
try {
|
|
276
316
|
placeholderData = options.select(placeholderData);
|
|
277
|
-
this
|
|
317
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _selectError)[_selectError] = null;
|
|
278
318
|
} catch (selectError) {
|
|
279
|
-
this
|
|
319
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _selectError)[_selectError] = selectError;
|
|
280
320
|
}
|
|
281
321
|
}
|
|
282
322
|
}
|
|
283
323
|
if (typeof placeholderData !== 'undefined') {
|
|
284
324
|
status = 'success';
|
|
285
|
-
data = utils.replaceData(prevResult
|
|
325
|
+
data = utils.replaceData(prevResult == null ? void 0 : prevResult.data, placeholderData, options);
|
|
286
326
|
isPlaceholderData = true;
|
|
287
327
|
}
|
|
288
328
|
}
|
|
289
|
-
if (this
|
|
290
|
-
error = this
|
|
291
|
-
data = this
|
|
329
|
+
if (_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _selectError)[_selectError]) {
|
|
330
|
+
error = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _selectError)[_selectError];
|
|
331
|
+
data = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _selectResult)[_selectResult];
|
|
292
332
|
errorUpdatedAt = Date.now();
|
|
293
333
|
status = 'error';
|
|
294
334
|
}
|
|
@@ -324,62 +364,6 @@ class QueryObserver extends subscribable.Subscribable {
|
|
|
324
364
|
};
|
|
325
365
|
return result;
|
|
326
366
|
}
|
|
327
|
-
#updateResult(notifyOptions) {
|
|
328
|
-
const prevResult = this.#currentResult;
|
|
329
|
-
const nextResult = this.createResult(this.#currentQuery, this.options);
|
|
330
|
-
this.#currentResultState = this.#currentQuery.state;
|
|
331
|
-
this.#currentResultOptions = this.options;
|
|
332
|
-
|
|
333
|
-
// Only notify and update result if something has changed
|
|
334
|
-
if (utils.shallowEqualObjects(nextResult, prevResult)) {
|
|
335
|
-
return;
|
|
336
|
-
}
|
|
337
|
-
this.#currentResult = nextResult;
|
|
338
|
-
|
|
339
|
-
// Determine which callbacks to trigger
|
|
340
|
-
const defaultNotifyOptions = {};
|
|
341
|
-
const shouldNotifyListeners = () => {
|
|
342
|
-
if (!prevResult) {
|
|
343
|
-
return true;
|
|
344
|
-
}
|
|
345
|
-
const {
|
|
346
|
-
notifyOnChangeProps
|
|
347
|
-
} = this.options;
|
|
348
|
-
if (notifyOnChangeProps === 'all' || !notifyOnChangeProps && !this.#trackedProps.size) {
|
|
349
|
-
return true;
|
|
350
|
-
}
|
|
351
|
-
const includedProps = new Set(notifyOnChangeProps ?? this.#trackedProps);
|
|
352
|
-
if (this.options.throwErrors) {
|
|
353
|
-
includedProps.add('error');
|
|
354
|
-
}
|
|
355
|
-
return Object.keys(this.#currentResult).some(key => {
|
|
356
|
-
const typedKey = key;
|
|
357
|
-
const changed = this.#currentResult[typedKey] !== prevResult[typedKey];
|
|
358
|
-
return changed && includedProps.has(typedKey);
|
|
359
|
-
});
|
|
360
|
-
};
|
|
361
|
-
if (notifyOptions?.listeners !== false && shouldNotifyListeners()) {
|
|
362
|
-
defaultNotifyOptions.listeners = true;
|
|
363
|
-
}
|
|
364
|
-
this.#notify({
|
|
365
|
-
...defaultNotifyOptions,
|
|
366
|
-
...notifyOptions
|
|
367
|
-
});
|
|
368
|
-
}
|
|
369
|
-
#updateQuery() {
|
|
370
|
-
const query = this.#client.getQueryCache().build(this.#client, this.options);
|
|
371
|
-
if (query === this.#currentQuery) {
|
|
372
|
-
return;
|
|
373
|
-
}
|
|
374
|
-
const prevQuery = this.#currentQuery;
|
|
375
|
-
this.#currentQuery = query;
|
|
376
|
-
this.#currentQueryInitialState = query.state;
|
|
377
|
-
this.#previousQueryResult = this.#currentResult;
|
|
378
|
-
if (this.hasListeners()) {
|
|
379
|
-
prevQuery?.removeObserver(this);
|
|
380
|
-
query.addObserver(this);
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
367
|
onQueryUpdate(action) {
|
|
384
368
|
const notifyOptions = {};
|
|
385
369
|
if (action.type === 'success') {
|
|
@@ -387,36 +371,153 @@ class QueryObserver extends subscribable.Subscribable {
|
|
|
387
371
|
} else if (action.type === 'error' && !retryer.isCancelledError(action.error)) {
|
|
388
372
|
notifyOptions.onError = true;
|
|
389
373
|
}
|
|
390
|
-
this
|
|
374
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _updateResult)[_updateResult](notifyOptions);
|
|
391
375
|
if (this.hasListeners()) {
|
|
392
|
-
this
|
|
376
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _updateTimers)[_updateTimers]();
|
|
393
377
|
}
|
|
394
378
|
}
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
this.options.onSuccess?.(this.#currentResult.data);
|
|
400
|
-
this.options.onSettled?.(this.#currentResult.data, null);
|
|
401
|
-
} else if (notifyOptions.onError) {
|
|
402
|
-
this.options.onError?.(this.#currentResult.error);
|
|
403
|
-
this.options.onSettled?.(undefined, this.#currentResult.error);
|
|
404
|
-
}
|
|
379
|
+
}
|
|
380
|
+
function _executeFetch2(fetchOptions) {
|
|
381
|
+
// Make sure we reference the latest query as the current one might have been removed
|
|
382
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _updateQuery)[_updateQuery]();
|
|
405
383
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
384
|
+
// Fetch
|
|
385
|
+
let promise = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery].fetch(this.options, fetchOptions);
|
|
386
|
+
if (!(fetchOptions != null && fetchOptions.throwOnError)) {
|
|
387
|
+
promise = promise.catch(utils.noop);
|
|
388
|
+
}
|
|
389
|
+
return promise;
|
|
390
|
+
}
|
|
391
|
+
function _updateStaleTimeout2() {
|
|
392
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _clearStaleTimeout)[_clearStaleTimeout]();
|
|
393
|
+
if (utils.isServer || _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResult)[_currentResult].isStale || !utils.isValidTimeout(this.options.staleTime)) {
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
const time = utils.timeUntilStale(_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResult)[_currentResult].dataUpdatedAt, this.options.staleTime);
|
|
412
397
|
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
398
|
+
// The timeout is sometimes triggered 1 ms before the stale time expiration.
|
|
399
|
+
// To mitigate this issue we always add 1 ms to the timeout.
|
|
400
|
+
const timeout = time + 1;
|
|
401
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _staleTimeoutId)[_staleTimeoutId] = setTimeout(() => {
|
|
402
|
+
if (!_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResult)[_currentResult].isStale) {
|
|
403
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _updateResult)[_updateResult]();
|
|
404
|
+
}
|
|
405
|
+
}, timeout);
|
|
406
|
+
}
|
|
407
|
+
function _computeRefetchInterval2() {
|
|
408
|
+
var _this$options$refetch;
|
|
409
|
+
return typeof this.options.refetchInterval === 'function' ? this.options.refetchInterval(_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResult)[_currentResult].data, _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery]) : (_this$options$refetch = this.options.refetchInterval) != null ? _this$options$refetch : false;
|
|
410
|
+
}
|
|
411
|
+
function _updateRefetchInterval2(nextInterval) {
|
|
412
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _clearRefetchInterval)[_clearRefetchInterval]();
|
|
413
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentRefetchInterval)[_currentRefetchInterval] = nextInterval;
|
|
414
|
+
if (utils.isServer || this.options.enabled === false || !utils.isValidTimeout(_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentRefetchInterval)[_currentRefetchInterval]) || _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentRefetchInterval)[_currentRefetchInterval] === 0) {
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _refetchIntervalId)[_refetchIntervalId] = setInterval(() => {
|
|
418
|
+
if (this.options.refetchIntervalInBackground || focusManager.focusManager.isFocused()) {
|
|
419
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _executeFetch)[_executeFetch]();
|
|
420
|
+
}
|
|
421
|
+
}, _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentRefetchInterval)[_currentRefetchInterval]);
|
|
422
|
+
}
|
|
423
|
+
function _updateTimers2() {
|
|
424
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _updateStaleTimeout)[_updateStaleTimeout]();
|
|
425
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _updateRefetchInterval)[_updateRefetchInterval](_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _computeRefetchInterval)[_computeRefetchInterval]());
|
|
426
|
+
}
|
|
427
|
+
function _clearStaleTimeout2() {
|
|
428
|
+
if (_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _staleTimeoutId)[_staleTimeoutId]) {
|
|
429
|
+
clearTimeout(_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _staleTimeoutId)[_staleTimeoutId]);
|
|
430
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _staleTimeoutId)[_staleTimeoutId] = undefined;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
function _clearRefetchInterval2() {
|
|
434
|
+
if (_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _refetchIntervalId)[_refetchIntervalId]) {
|
|
435
|
+
clearInterval(_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _refetchIntervalId)[_refetchIntervalId]);
|
|
436
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _refetchIntervalId)[_refetchIntervalId] = undefined;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
function _updateResult2(notifyOptions) {
|
|
440
|
+
const prevResult = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResult)[_currentResult];
|
|
441
|
+
const nextResult = this.createResult(_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery], this.options);
|
|
442
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResultState)[_currentResultState] = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery].state;
|
|
443
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResultOptions)[_currentResultOptions] = this.options;
|
|
444
|
+
|
|
445
|
+
// Only notify and update result if something has changed
|
|
446
|
+
if (utils.shallowEqualObjects(nextResult, prevResult)) {
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResult)[_currentResult] = nextResult;
|
|
450
|
+
|
|
451
|
+
// Determine which callbacks to trigger
|
|
452
|
+
const defaultNotifyOptions = {};
|
|
453
|
+
const shouldNotifyListeners = () => {
|
|
454
|
+
if (!prevResult) {
|
|
455
|
+
return true;
|
|
456
|
+
}
|
|
457
|
+
const {
|
|
458
|
+
notifyOnChangeProps
|
|
459
|
+
} = this.options;
|
|
460
|
+
if (notifyOnChangeProps === 'all' || !notifyOnChangeProps && !_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _trackedProps)[_trackedProps].size) {
|
|
461
|
+
return true;
|
|
462
|
+
}
|
|
463
|
+
const includedProps = new Set(notifyOnChangeProps != null ? notifyOnChangeProps : _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _trackedProps)[_trackedProps]);
|
|
464
|
+
if (this.options.throwErrors) {
|
|
465
|
+
includedProps.add('error');
|
|
466
|
+
}
|
|
467
|
+
return Object.keys(_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResult)[_currentResult]).some(key => {
|
|
468
|
+
const typedKey = key;
|
|
469
|
+
const changed = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResult)[_currentResult][typedKey] !== prevResult[typedKey];
|
|
470
|
+
return changed && includedProps.has(typedKey);
|
|
418
471
|
});
|
|
472
|
+
};
|
|
473
|
+
if ((notifyOptions == null ? void 0 : notifyOptions.listeners) !== false && shouldNotifyListeners()) {
|
|
474
|
+
defaultNotifyOptions.listeners = true;
|
|
475
|
+
}
|
|
476
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _notify)[_notify]({
|
|
477
|
+
...defaultNotifyOptions,
|
|
478
|
+
...notifyOptions
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
function _updateQuery2() {
|
|
482
|
+
const query = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _client)[_client].getQueryCache().build(_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _client)[_client], this.options);
|
|
483
|
+
if (query === _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery]) {
|
|
484
|
+
return;
|
|
419
485
|
}
|
|
486
|
+
const prevQuery = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery];
|
|
487
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery] = query;
|
|
488
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQueryInitialState)[_currentQueryInitialState] = query.state;
|
|
489
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _previousQueryResult)[_previousQueryResult] = _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResult)[_currentResult];
|
|
490
|
+
if (this.hasListeners()) {
|
|
491
|
+
prevQuery == null ? void 0 : prevQuery.removeObserver(this);
|
|
492
|
+
query.addObserver(this);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
function _notify2(notifyOptions) {
|
|
496
|
+
notifyManager.notifyManager.batch(() => {
|
|
497
|
+
// First trigger the configuration callbacks
|
|
498
|
+
if (notifyOptions.onSuccess) {
|
|
499
|
+
var _this$options$onSucce, _this$options, _this$options$onSettl, _this$options2;
|
|
500
|
+
(_this$options$onSucce = (_this$options = this.options).onSuccess) == null ? void 0 : _this$options$onSucce.call(_this$options, _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResult)[_currentResult].data);
|
|
501
|
+
(_this$options$onSettl = (_this$options2 = this.options).onSettled) == null ? void 0 : _this$options$onSettl.call(_this$options2, _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResult)[_currentResult].data, null);
|
|
502
|
+
} else if (notifyOptions.onError) {
|
|
503
|
+
var _this$options$onError, _this$options3, _this$options$onSettl2, _this$options4;
|
|
504
|
+
(_this$options$onError = (_this$options3 = this.options).onError) == null ? void 0 : _this$options$onError.call(_this$options3, _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResult)[_currentResult].error);
|
|
505
|
+
(_this$options$onSettl2 = (_this$options4 = this.options).onSettled) == null ? void 0 : _this$options$onSettl2.call(_this$options4, undefined, _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResult)[_currentResult].error);
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
// Then trigger the listeners
|
|
509
|
+
if (notifyOptions.listeners) {
|
|
510
|
+
this.listeners.forEach(listener => {
|
|
511
|
+
listener(_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentResult)[_currentResult]);
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
// Then the cache listeners
|
|
516
|
+
_rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _client)[_client].getQueryCache().notify({
|
|
517
|
+
query: _rollupPluginBabelHelpers.classPrivateFieldLooseBase(this, _currentQuery)[_currentQuery],
|
|
518
|
+
type: 'observerResultsUpdated'
|
|
519
|
+
});
|
|
520
|
+
});
|
|
420
521
|
}
|
|
421
522
|
function shouldLoadOnMount(query, options) {
|
|
422
523
|
return options.enabled !== false && !query.state.dataUpdatedAt && !(query.state.status === 'error' && options.retryOnMount === false);
|