Fix isReady return value for early useLiveQuery exits#886
Merged
KyleAMathews merged 11 commits intomainfrom Dec 3, 2025
Merged
Fix isReady return value for early useLiveQuery exits#886KyleAMathews merged 11 commits intomainfrom
KyleAMathews merged 11 commits intomainfrom
Conversation
When useLiveQuery's query function returns null or undefined, the query is effectively "disabled" - there's no async operation to wait for. The hook should be considered "ready" immediately since there's nothing loading. This change updates isReady to return true (instead of false) when status is 'disabled', matching user expectations when conditionally enabling queries. Fixes #883
🦋 Changeset detectedLatest commit: 2d3e7ec The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 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: |
Contributor
|
Size Change: 0 B Total Size: 87.1 kB ℹ️ View Unchanged
|
Contributor
|
Size Change: 0 B Total Size: 3.34 kB ℹ️ View Unchanged
|
Extended the fix for disabled queries to solid-db, vue-db, and svelte-db. All frameworks now properly handle when query functions return null/undefined by: - Returning null for the collection - Setting status to 'disabled' - Returning isReady: true (since there's nothing to wait for) This provides a consistent API across all framework packages and fixes the common conditional query pattern. Related to #883
Added explicit TypeScript overloads to support returning null/undefined from query functions across all framework packages: - solid-db: useLiveQuery - vue-db: useLiveQuery - svelte-db: useLiveQuery - angular-db: injectLiveQuery This makes the disabled query pattern type-safe, allowing developers to conditionally enable queries with proper type inference. Related to #883
samwillis
requested changes
Nov 25, 2025
Collaborator
samwillis
left a comment
There was a problem hiding this comment.
Looks good, but we should add tests for the vue, svelte, solid and angular implementation of the disabled queries.
Added tests to verify that disabled queries (returning null/undefined) properly return isReady: true. Solid tests pass. Vue tests added but need additional debugging of the reactive deps implementation. Related to #883 - addressing Sam's review feedback
- Updated InjectLiveQueryResult interface to support nullable collection and disabled status - Fixed isReady computed to return true when status is 'disabled' - Added TypeScript overloads for query functions that can return null/undefined - Added tests for disabled query functionality with reactive params
- Added check for query functions that return null/undefined - Sets status to 'disabled' when collection is null - Fixed isReady to return true for disabled status - Added tests but marked as skipped due to Vue reactivity limitations - TODO: Need different test pattern that works with Vue's reactivity system
- Fixed toValue() being called on query functions, which was treating them as getters - Wrapped query functions to handle null/undefined returns without double-invocation - All 25 tests now passing including disabled query tests - Performance improvement: query function only called once by createLiveQueryCollection
samwillis
approved these changes
Dec 3, 2025
Merged
Contributor
|
🎉 This PR has been released!
Thank you for your contribution! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When useLiveQuery's query function returns null or undefined, the query is effectively "disabled" - there's no async operation to wait for. The hook should be considered "ready" immediately since there's nothing loading.
This change updates isReady to return true (instead of false) when status is 'disabled', matching user expectations when conditionally enabling queries.
Fixes #883
🎯 Changes
✅ Checklist
pnpm test:pr.🚀 Release Impact