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