@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.
@@ -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() {