@tanstack/query-core
Advanced tools
Comparing version 5.27.2 to 5.27.3
@@ -85,3 +85,11 @@ import { | ||
isStale() { | ||
return this.state.isInvalidated || this.state.data === void 0 || __privateGet(this, _observers).some((observer) => observer.getCurrentResult().isStale); | ||
if (this.state.isInvalidated) { | ||
return true; | ||
} | ||
if (this.getObserversCount() > 0) { | ||
return __privateGet(this, _observers).some( | ||
(observer) => observer.getCurrentResult().isStale | ||
); | ||
} | ||
return this.state.data === void 0; | ||
} | ||
@@ -88,0 +96,0 @@ isStaleByTime(staleTime = 0) { |
@@ -104,3 +104,3 @@ import { | ||
__privateGet(this, _currentQuery).setOptions(this.options); | ||
if (!shallowEqualObjects(this.options, prevOptions)) { | ||
if (prevOptions._defaulted && !shallowEqualObjects(this.options, prevOptions)) { | ||
__privateGet(this, _client).getQueryCache().notify({ | ||
@@ -462,6 +462,6 @@ type: "observerOptionsUpdated", | ||
function shouldFetchOptionally(query, prevQuery, options, prevOptions) { | ||
return options.enabled !== false && (query !== prevQuery || prevOptions.enabled === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options); | ||
return (query !== prevQuery || prevOptions.enabled === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options); | ||
} | ||
function isStale(query, options) { | ||
return query.isStaleByTime(options.staleTime); | ||
return options.enabled !== false && query.isStaleByTime(options.staleTime); | ||
} | ||
@@ -468,0 +468,0 @@ function shouldAssignObserverCurrentProperties(observer, optimisticResult) { |
@@ -75,3 +75,11 @@ // src/query.ts | ||
isStale() { | ||
return this.state.isInvalidated || this.state.data === void 0 || this.#observers.some((observer) => observer.getCurrentResult().isStale); | ||
if (this.state.isInvalidated) { | ||
return true; | ||
} | ||
if (this.getObserversCount() > 0) { | ||
return this.#observers.some( | ||
(observer) => observer.getCurrentResult().isStale | ||
); | ||
} | ||
return this.state.data === void 0; | ||
} | ||
@@ -78,0 +86,0 @@ isStaleByTime(staleTime = 0) { |
@@ -87,3 +87,3 @@ // src/queryObserver.ts | ||
this.#currentQuery.setOptions(this.options); | ||
if (!shallowEqualObjects(this.options, prevOptions)) { | ||
if (prevOptions._defaulted && !shallowEqualObjects(this.options, prevOptions)) { | ||
this.#client.getQueryCache().notify({ | ||
@@ -421,6 +421,6 @@ type: "observerOptionsUpdated", | ||
function shouldFetchOptionally(query, prevQuery, options, prevOptions) { | ||
return options.enabled !== false && (query !== prevQuery || prevOptions.enabled === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options); | ||
return (query !== prevQuery || prevOptions.enabled === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options); | ||
} | ||
function isStale(query, options) { | ||
return query.isStaleByTime(options.staleTime); | ||
return options.enabled !== false && query.isStaleByTime(options.staleTime); | ||
} | ||
@@ -427,0 +427,0 @@ function shouldAssignObserverCurrentProperties(observer, optimisticResult) { |
{ | ||
"name": "@tanstack/query-core", | ||
"version": "5.27.2", | ||
"version": "5.27.3", | ||
"description": "The framework agnostic core that powers TanStack Query", | ||
@@ -5,0 +5,0 @@ "author": "tannerlinsley", |
@@ -251,7 +251,13 @@ import { noop, replaceData, skipToken, timeUntilStale } from './utils' | ||
isStale(): boolean { | ||
return ( | ||
this.state.isInvalidated || | ||
this.state.data === undefined || | ||
this.#observers.some((observer) => observer.getCurrentResult().isStale) | ||
) | ||
if (this.state.isInvalidated) { | ||
return true | ||
} | ||
if (this.getObserversCount() > 0) { | ||
return this.#observers.some( | ||
(observer) => observer.getCurrentResult().isStale, | ||
) | ||
} | ||
return this.state.data === undefined | ||
} | ||
@@ -258,0 +264,0 @@ |
@@ -159,3 +159,6 @@ import { | ||
if (!shallowEqualObjects(this.options, prevOptions)) { | ||
if ( | ||
prevOptions._defaulted && | ||
!shallowEqualObjects(this.options, prevOptions) | ||
) { | ||
this.#client.getQueryCache().notify({ | ||
@@ -733,3 +736,2 @@ type: 'observerOptionsUpdated', | ||
return ( | ||
options.enabled !== false && | ||
(query !== prevQuery || prevOptions.enabled === false) && | ||
@@ -745,3 +747,3 @@ (!options.suspense || query.state.status !== 'error') && | ||
): boolean { | ||
return query.isStaleByTime(options.staleTime) | ||
return options.enabled !== false && query.isStaleByTime(options.staleTime) | ||
} | ||
@@ -748,0 +750,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1841270
26159