MCPcopy Create free account
hub / github.com/TanStack/query / isStaleByTime

Method isStaleByTime

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

Source from the content-addressed store, hash-verified

314 }
315
316 isStaleByTime(staleTime: StaleTime = 0): boolean {
317 // no data is always stale
318 if (this.state.data === undefined) {
319 return true
320 }
321 // static is never stale
322 if (staleTime === 'static') {
323 return false
324 }
325 // if the query is invalidated, it is stale
326 if (this.state.isInvalidated) {
327 return true
328 }
329
330 return !timeUntilStale(this.state.dataUpdatedAt, staleTime)
331 }
332
333 onFocus(): void {
334 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