@tanstack/query-core 4.0.11-beta.0 → 4.0.11-beta.1
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 +1 -1
- 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.mjs
CHANGED
|
@@ -341,6 +341,8 @@ function replaceData(prevData, data, options) {
|
|
|
341
341
|
// Use prev data if an isDataEqual function is defined and returns `true`
|
|
342
342
|
if (options.isDataEqual != null && options.isDataEqual(prevData, data)) {
|
|
343
343
|
return prevData;
|
|
344
|
+
} else if (typeof options.structuralSharing === 'function') {
|
|
345
|
+
return options.structuralSharing(prevData, data);
|
|
344
346
|
} else if (options.structuralSharing !== false) {
|
|
345
347
|
// Structurally share data between prev and new data if needed
|
|
346
348
|
return replaceEqualDeep(prevData, data);
|
|
@@ -2197,6 +2199,14 @@ class QueryObserver extends Subscribable {
|
|
|
2197
2199
|
const prevQuery = this.currentQuery;
|
|
2198
2200
|
this.options = this.client.defaultQueryOptions(options);
|
|
2199
2201
|
|
|
2202
|
+
if (!shallowEqualObjects(prevOptions, this.options)) {
|
|
2203
|
+
this.client.getQueryCache().notify({
|
|
2204
|
+
type: 'observerOptionsUpdated',
|
|
2205
|
+
query: this.currentQuery,
|
|
2206
|
+
observer: this
|
|
2207
|
+
});
|
|
2208
|
+
}
|
|
2209
|
+
|
|
2200
2210
|
if (typeof this.options.enabled !== 'undefined' && typeof this.options.enabled !== 'boolean') {
|
|
2201
2211
|
throw new Error('Expected enabled to be a boolean');
|
|
2202
2212
|
} // Keep previous query key if the user does not supply one
|
|
@@ -2880,7 +2890,16 @@ class MutationObserver extends Subscribable {
|
|
|
2880
2890
|
}
|
|
2881
2891
|
|
|
2882
2892
|
setOptions(options) {
|
|
2893
|
+
const prevOptions = this.options;
|
|
2883
2894
|
this.options = this.client.defaultMutationOptions(options);
|
|
2895
|
+
|
|
2896
|
+
if (!shallowEqualObjects(prevOptions, this.options)) {
|
|
2897
|
+
this.client.getMutationCache().notify({
|
|
2898
|
+
type: 'observerOptionsUpdated',
|
|
2899
|
+
mutation: this.currentMutation,
|
|
2900
|
+
observer: this
|
|
2901
|
+
});
|
|
2902
|
+
}
|
|
2884
2903
|
}
|
|
2885
2904
|
|
|
2886
2905
|
onUnsubscribe() {
|