-
Notifications
You must be signed in to change notification settings - Fork 116
Add QueryObserver state utility methods to QueryCollectionUtils #742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add QueryObserver state utility methods to QueryCollectionUtils #742
Conversation
🦋 Changeset detectedLatest commit: 50c5d1a The changes in this PR will be included in the next version bump. This PR includes changesets to release 16 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
More templates
@tanstack/angular-db
@tanstack/db
@tanstack/db-ivm
@tanstack/electric-db-collection
@tanstack/offline-transactions
@tanstack/powersync-db-collection
@tanstack/query-db-collection
@tanstack/react-db
@tanstack/rxdb-db-collection
@tanstack/solid-db
@tanstack/svelte-db
@tanstack/trailbase-db-collection
@tanstack/vue-db
commit: |
|
Size Change: 0 B Total Size: 79.1 kB ℹ️ View Unchanged
|
|
Size Change: 0 B Total Size: 3.34 kB ℹ️ View Unchanged
|
2f89188 to
ca3361d
Compare
…tters
Adds new utilities to expose TanStack Query's QueryObserver state:
- isFetching: Check if query is currently fetching
- isRefetching: Check if query is refetching in background
- isLoading: Check if query is loading for first time
- dataUpdatedAt: Timestamp of last successful data update
- fetchStatus: Current fetch status ('fetching' | 'paused' | 'idle')
BREAKING CHANGE: Error state utilities are now getters instead of methods:
- collection.utils.lastError() → collection.utils.lastError
- collection.utils.isError() → collection.utils.isError
- collection.utils.errorCount() → collection.utils.errorCount
ca3361d to
f8fd37f
Compare
samwillis
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking very good, much prefer this to the previous and the widening of the types for the utils.
Just a comment above on the class being a closure.
Addresses PR feedback from samwillis: refactor QueryCollectionUtilsImpl class to be extracted outside the function scope with required state passed through the constructor instead of relying on closure patterns. This improves code architecture by making dependencies explicit and avoiding nested class definitions within functions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Re-generate documentation after QueryCollectionUtilsImpl refactoring. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Regenerated all documentation files after running full build. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
samwillis
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
Aside: it will create some merge conflicts with the query driven sync PR #763, hopefully not too painful, but to keep in mind.
| } | ||
|
|
||
| /** | ||
| * Implementation class for QueryCollectionUtils that maintains proper closure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that maintains proper closure
its not a colure any more...
Update QueryCollectionUtilsImpl class comment to accurately reflect that it now uses explicit dependency injection instead of closure. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Adds new utility methods to QueryCollectionUtils to expose TanStack Query's QueryObserver state, addressing user request for visibility into sync status:
New utils exposed:
This allows users to:
Converted error state utilities from methods to getters:
Resolves user request from Discord where status is always 'ready' after initial load, making it impossible to know if background refetches are happening.