Skip to content

Conversation

@Nr9
Copy link
Member

@Nr9 Nr9 commented Dec 3, 2025

Greptile Overview

Greptile Summary

Refactored the staleTime logic in observableQueryOptions to directly check for active RxJS subscriptions instead of inferring state from query metadata. The new implementation checks if a subscription exists in the queriesSubscriptions Map using hashKey(queryKey), which is more explicit and aligns better with the actual lifecycle of observable subscriptions.

Key Changes:

  • Replaced state.dataUpdateCount and state.status checks with direct queriesSubscriptions.has() lookup
  • Updated test to properly simulate an active subscription by adding it to the Map
  • Improved test description to clarify it's testing active subscription behavior

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The change simplifies the staleTime logic by directly checking the source of truth (the subscriptions Map) rather than indirectly inferring from query state. The implementation is clearer, more maintainable, and the test coverage validates the new behavior correctly
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
packages/react-query-observable/src/observableQueryOptions.ts 5/5 Simplified staleTime logic to check active subscriptions directly instead of relying on query state
packages/react-query-observable/src/tests/observableQueryOptions.test.ts 5/5 Updated test to properly setup subscription in Map before checking staleTime behavior

@Nr9 Nr9 requested a review from a team as a code owner December 3, 2025 17:55
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@Nr9 Nr9 enabled auto-merge (squash) December 3, 2025 17:57
@Nr9 Nr9 disabled auto-merge December 3, 2025 17:58
@Nr9 Nr9 merged commit ecbc256 into main Dec 3, 2025
6 checks passed
@Nr9 Nr9 deleted the feat/simplify-stale-query branch December 3, 2025 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants