* 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
()
| 537 | * ``` |
| 538 | */ |
| 539 | isStale(): boolean { |
| 540 | // check observers first, their `isStale` has the source of truth |
| 541 | // calculated with `isStaleByTime` and it takes `enabled` into account |
| 542 | if (this.getObserversCount() > 0) { |
| 543 | return this.observers.some( |
| 544 | (observer) => observer.getCurrentResult().isStale, |
| 545 | ) |
| 546 | } |
| 547 | |
| 548 | return this.state.data === undefined || this.state.isInvalidated |
| 549 | } |
| 550 | |
| 551 | /** |
| 552 | * Returns `true` if the query's data is stale relative to the given |
no test coverage detected