Skip to content
Source
Sign inSign up
TanStack/db

fix: allow live queries to access optimistic inserts before sync completes #641

Closedmarbemac(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/641/headopened

Showing 3 changed files with 65 additions and 1 deletion.

x
0 of 3 viewed, 3 left
5 additions and 0 deletions.changeset/slow-lamps-follow.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+"@tanstack/db": patch
+---
+​
+fix: allow live queries to access optimistic inserts before sync completes
4 additions and 1 deletionpackages/db/src/query/live/collection-config-builder.tsModified
View file
@@ -326,7 +326,10 @@
private allCollectionsReadyOrInitialCommit() {
return Object.values(this.collections).every(
(collection) =>
- collection.status === `ready` || collection.status === `initialCommit`
+ collection.status === `ready` ||
+ collection.status === `initialCommit` ||
+ // Allow graph to run if collection has data (optimistic inserts)
+ collection.size > 0
​
56 additions and 0 deletionspackages/db/tests/query/live-query-collection.test.tsModified
View file