eagerly run live queries while collections are loading#658
Merged
Conversation
🦋 Changeset detectedLatest commit: 2816a73 The changes in this PR will be included in the next version bump. This PR includes changesets to release 12 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/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: +222 B (+0.29%) Total Size: 76.3 kB
ℹ️ View Unchanged
|
Contributor
|
Size Change: 0 B Total Size: 1.47 kB ℹ️ View Unchanged
|
d2d3004 to
2816a73
Compare
KyleAMathews
approved these changes
Oct 8, 2025
Collaborator
KyleAMathews
left a comment
There was a problem hiding this comment.
Great stuff! I don't think this would show up as improvement in our current benchmarks but for anything that does chunked loading like electric, this should be quite a bit faster.
Contributor
|
❤️ works like a charm - closing #641 |
1 task
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.
Summary
Refactors the live query execution model to support eager materialization. Live queries now process and display data as it arrives from source collections during sync, rather than waiting for all source collections to reach a "ready" state before executing.
Key Changes
.preload()or.startSync(), processing data as it arrives from source collectionson('status:change')event listeners, whilesubscribeChangesis used solely for data updatesinitialCommitstatus from collection lifecycle across entire codebaseloadingstate to support eager query execution_lifecycleproperty public on Collection interface for internal library useinitialCommitreferences and validate eager execution behaviorTesting
Core Package (
@tanstack/db):query-while-syncing.test.ts(24 tests covering basic queries, joins, multiple sources, error handling, and both.startSync()and.preload()patterns)markReady()in collection testsdescribe.eachpattern for parameterized testing with bothautoIndex: 'off'andautoIndex: 'eager'Framework Packages:
isLoading == true:@tanstack/react-db): 4 new tests (33 total)@tanstack/vue-db): 4 new tests (23 total)@tanstack/solid-db): 4 new tests (20 total)@tanstack/svelte-db): 4 new tests (22 total)@tanstack/angular-db): 3 new tests (18 total)isLoading == trueinitialCommitreferences in framework adapter implementationsTest Coverage:
User-Facing Impact
Users will see live query results update in real-time as data loads, providing immediate feedback during sync operations. This includes both synced data and local optimistic updates, creating a more responsive user experience even before the underlying data is fully loaded. They can use the collection status to show loading state while the data streams in. This behavior is consistent across all framework adapters (React, Vue, Solid, Svelte, Angular).