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

Function isStale

packages/query-core/src/queryObserver.ts:965–973  ·  view source on GitHub ↗

* Checks whether a query is stale for the given observer options. * @param query - The query to check. * @param options - The observer options, whose `enabled` and `staleTime` are used. * @returns `true` if the query is enabled and its data is stale for `staleTime`.

(
  query: Query<any, any, any, any>,
  options: QueryObserverOptions<any, any, any, any, any>,
)

Source from the content-addressed store, hash-verified

963 * @returns `true` if the query is enabled and its data is stale for `staleTime`.
964 */
965function isStale(
966 query: Query<any, any, any, any>,
967 options: QueryObserverOptions<any, any, any, any, any>,
968): boolean {
969 return (
970 resolveQueryValue(options.enabled, query) !== false &&
971 query.isStaleByTime(resolveQueryValue(options.staleTime, query))
972 )
973}

Callers 4

QueryRowFunction · 0.85
createResultMethod · 0.85
shouldFetchOnFunction · 0.85
shouldFetchOptionallyFunction · 0.85

Calls 2

resolveQueryValueFunction · 0.90
isStaleByTimeMethod · 0.80

Tested by

no test coverage detected