* Returns `true` if the query is stale. * - If the query has observers, defers to whether any observer's current * result reports `isStale` (which accounts for each observer's own * `staleTime` and `enabled` state). * - If the query has no observers, it is considered stale when it ha
()
| 445 | * ``` |
| 446 | */ |
| 447 | isStale(): boolean { |
| 448 | // check observers first, their `isStale` has the source of truth |
| 449 | // calculated with `isStaleByTime` and it takes `enabled` into account |
| 450 | if (this.getObserversCount() > 0) { |
| 451 | return this.observers.some( |
| 452 | (observer) => observer.getCurrentResult().isStale, |
| 453 | ) |
| 454 | } |
| 455 | |
| 456 | return this.state.data === undefined || this.state.isInvalidated |
| 457 | } |
| 458 | |
| 459 | /** |
| 460 | * Returns `true` if the query's data is stale relative to the given |
no test coverage detected