@tanstack/vue-query 5.0.0-alpha.12 → 5.0.0-alpha.19
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.
|
@@ -1116,10 +1116,11 @@
|
|
|
1116
1116
|
return [...this.#queries.values()];
|
|
1117
1117
|
}
|
|
1118
1118
|
find(filters) {
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1119
|
+
const defaultedFilters = {
|
|
1120
|
+
exact: true,
|
|
1121
|
+
...filters
|
|
1122
|
+
};
|
|
1123
|
+
return this.getAll().find(query => matchQuery(defaultedFilters, query));
|
|
1123
1124
|
}
|
|
1124
1125
|
findAll(filters = {}) {
|
|
1125
1126
|
const queries = this.getAll();
|
|
@@ -1425,10 +1426,11 @@
|
|
|
1425
1426
|
return this.#mutations;
|
|
1426
1427
|
}
|
|
1427
1428
|
find(filters) {
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1429
|
+
const defaultedFilters = {
|
|
1430
|
+
exact: true,
|
|
1431
|
+
...filters
|
|
1432
|
+
};
|
|
1433
|
+
return this.#mutations.find(mutation => matchMutation(defaultedFilters, mutation));
|
|
1432
1434
|
}
|
|
1433
1435
|
findAll(filters = {}) {
|
|
1434
1436
|
return this.#mutations.filter(mutation => matchMutation(filters, mutation));
|
|
@@ -1695,10 +1697,11 @@
|
|
|
1695
1697
|
});
|
|
1696
1698
|
}
|
|
1697
1699
|
cancelQueries(filters = {}, cancelOptions = {}) {
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1700
|
+
const defaultedCancelOptions = {
|
|
1701
|
+
revert: true,
|
|
1702
|
+
...cancelOptions
|
|
1703
|
+
};
|
|
1704
|
+
const promises = notifyManager.batch(() => this.#queryCache.findAll(filters).map(query => query.cancel(defaultedCancelOptions)));
|
|
1702
1705
|
return Promise.all(promises).then(noop).catch(noop);
|
|
1703
1706
|
}
|
|
1704
1707
|
invalidateQueries(filters = {}, options = {}) {
|
|
@@ -1847,10 +1850,12 @@
|
|
|
1847
1850
|
#currentResult = undefined;
|
|
1848
1851
|
#currentResultState;
|
|
1849
1852
|
#currentResultOptions;
|
|
1850
|
-
#previousQueryResult;
|
|
1851
1853
|
#selectError;
|
|
1852
1854
|
#selectFn;
|
|
1853
1855
|
#selectResult;
|
|
1856
|
+
// This property keeps track of the last defined query data.
|
|
1857
|
+
// It will be used to pass the previous data to the placeholder function between renders.
|
|
1858
|
+
#lastDefinedQueryData;
|
|
1854
1859
|
#staleTimeoutId;
|
|
1855
1860
|
#refetchIntervalId;
|
|
1856
1861
|
#currentRefetchInterval;
|
|
@@ -2045,7 +2050,6 @@
|
|
|
2045
2050
|
const prevResultOptions = this.#currentResultOptions;
|
|
2046
2051
|
const queryChange = query !== prevQuery;
|
|
2047
2052
|
const queryInitialState = queryChange ? query.state : this.#currentQueryInitialState;
|
|
2048
|
-
const prevQueryResult = queryChange ? this.#currentResult : this.#previousQueryResult;
|
|
2049
2053
|
const {
|
|
2050
2054
|
state
|
|
2051
2055
|
} = query;
|
|
@@ -2104,7 +2108,7 @@
|
|
|
2104
2108
|
if (prevResult?.isPlaceholderData && options.placeholderData === prevResultOptions?.placeholderData) {
|
|
2105
2109
|
placeholderData = prevResult.data;
|
|
2106
2110
|
} else {
|
|
2107
|
-
placeholderData = typeof options.placeholderData === 'function' ? options.placeholderData(
|
|
2111
|
+
placeholderData = typeof options.placeholderData === 'function' ? options.placeholderData(this.#lastDefinedQueryData) : options.placeholderData;
|
|
2108
2112
|
if (options.select && typeof placeholderData !== 'undefined') {
|
|
2109
2113
|
try {
|
|
2110
2114
|
placeholderData = options.select(placeholderData);
|
|
@@ -2168,6 +2172,9 @@
|
|
|
2168
2172
|
if (shallowEqualObjects(nextResult, prevResult)) {
|
|
2169
2173
|
return;
|
|
2170
2174
|
}
|
|
2175
|
+
if (this.#currentResultState.data !== undefined) {
|
|
2176
|
+
this.#lastDefinedQueryData = this.#currentResultState.data;
|
|
2177
|
+
}
|
|
2171
2178
|
this.#currentResult = nextResult;
|
|
2172
2179
|
|
|
2173
2180
|
// Determine which callbacks to trigger
|
|
@@ -2208,7 +2215,6 @@
|
|
|
2208
2215
|
const prevQuery = this.#currentQuery;
|
|
2209
2216
|
this.#currentQuery = query;
|
|
2210
2217
|
this.#currentQueryInitialState = query.state;
|
|
2211
|
-
this.#previousQueryResult = this.#currentResult;
|
|
2212
2218
|
if (this.hasListeners()) {
|
|
2213
2219
|
prevQuery?.removeObserver(this);
|
|
2214
2220
|
query.addObserver(this);
|