MCPcopy Index your code
hub / github.com/TanStack/query / isStaleByTime

Method isStaleByTime

packages/query-core/src/query.ts:309–324  ·  view source on GitHub ↗
(staleTime: StaleTime = 0)

Source from the content-addressed store, hash-verified

307 }
308
309 isStaleByTime(staleTime: StaleTime = 0): boolean {
310 // no data is always stale
311 if (this.state.data === undefined) {
312 return true
313 }
314 // static is never stale
315 if (staleTime === 'static') {
316 return false
317 }
318 // if the query is invalidated, it is stale
319 if (this.state.isInvalidated) {
320 return true
321 }
322
323 return !timeUntilStale(this.state.dataUpdatedAt, staleTime)
324 }
325
326 onFocus(): void {
327 const observer = this.observers.find((x) => x.shouldFetchOnWindowFocus())

Callers 3

ensureQueryDataMethod · 0.80
fetchQueryMethod · 0.80
isStaleFunction · 0.80

Calls 1

timeUntilStaleFunction · 0.90

Tested by

no test coverage detected