@tanstack/query-core 4.0.11-beta.0 → 4.0.11-beta.5
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/index.js +19 -0
- package/build/lib/index.js.map +1 -1
- package/build/lib/index.mjs +19 -0
- package/build/lib/index.mjs.map +1 -1
- package/build/lib/mutationCache.d.ts +6 -1
- package/build/lib/queryCache.d.ts +6 -1
- package/build/lib/types.d.ts +10 -8
- package/build/umd/index.development.js +19 -0
- 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 -3
- package/src/mutationCache.ts +7 -0
- package/src/mutationObserver.ts +9 -0
- package/src/queryCache.ts +7 -0
- package/src/queryObserver.ts +8 -0
- package/src/tests/queryClient.test.tsx +33 -0
- package/src/tests/queryObserver.test.tsx +19 -0
- package/src/types.ts +15 -9
- package/src/utils.ts +2 -0
package/build/lib/index.js
CHANGED
|
@@ -345,6 +345,8 @@ function replaceData(prevData, data, options) {
|
|
|
345
345
|
// Use prev data if an isDataEqual function is defined and returns `true`
|
|
346
346
|
if (options.isDataEqual != null && options.isDataEqual(prevData, data)) {
|
|
347
347
|
return prevData;
|
|
348
|
+
} else if (typeof options.structuralSharing === 'function') {
|
|
349
|
+
return options.structuralSharing(prevData, data);
|
|
348
350
|
} else if (options.structuralSharing !== false) {
|
|
349
351
|
// Structurally share data between prev and new data if needed
|
|
350
352
|
return replaceEqualDeep(prevData, data);
|
|
@@ -2201,6 +2203,14 @@ class QueryObserver extends Subscribable {
|
|
|
2201
2203
|
const prevQuery = this.currentQuery;
|
|
2202
2204
|
this.options = this.client.defaultQueryOptions(options);
|
|
2203
2205
|
|
|
2206
|
+
if (!shallowEqualObjects(prevOptions, this.options)) {
|
|
2207
|
+
this.client.getQueryCache().notify({
|
|
2208
|
+
type: 'observerOptionsUpdated',
|
|
2209
|
+
query: this.currentQuery,
|
|
2210
|
+
observer: this
|
|
2211
|
+
});
|
|
2212
|
+
}
|
|
2213
|
+
|
|
2204
2214
|
if (typeof this.options.enabled !== 'undefined' && typeof this.options.enabled !== 'boolean') {
|
|
2205
2215
|
throw new Error('Expected enabled to be a boolean');
|
|
2206
2216
|
} // Keep previous query key if the user does not supply one
|
|
@@ -2884,7 +2894,16 @@ class MutationObserver extends Subscribable {
|
|
|
2884
2894
|
}
|
|
2885
2895
|
|
|
2886
2896
|
setOptions(options) {
|
|
2897
|
+
const prevOptions = this.options;
|
|
2887
2898
|
this.options = this.client.defaultMutationOptions(options);
|
|
2899
|
+
|
|
2900
|
+
if (!shallowEqualObjects(prevOptions, this.options)) {
|
|
2901
|
+
this.client.getMutationCache().notify({
|
|
2902
|
+
type: 'observerOptionsUpdated',
|
|
2903
|
+
mutation: this.currentMutation,
|
|
2904
|
+
observer: this
|
|
2905
|
+
});
|
|
2906
|
+
}
|
|
2888
2907
|
}
|
|
2889
2908
|
|
|
2890
2909
|
onUnsubscribe() {
|