Add explicit collection readiness detection with isReady() and markReady()#270
Merged
KyleAMathews merged 3 commits intomainfrom Jul 16, 2025
Merged
Add explicit collection readiness detection with isReady() and markReady()#270KyleAMathews merged 3 commits intomainfrom
KyleAMathews merged 3 commits intomainfrom
Conversation
…ady() - Add isReady() method to check if a collection is ready for use - Add onFirstReady() method to register callbacks for when collection becomes ready - Add markReady() to SyncConfig interface for sync implementations to explicitly signal readiness - Replace onFirstCommit() with onFirstReady() for better semantics - Update status state machine to allow loading → ready transition for cases with no data to commit - Update all sync implementations (Electric, Query, Local-only, Local-storage) to use markReady() - Improve error handling by allowing collections to be marked ready even when sync errors occur This provides a more intuitive and ergonomic API for determining collection readiness, replacing the previous approach of using commits as a readiness signal. Fixes #266 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 56c0a2e The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 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 |
|
@tanstack/db-example-react-todo @tanstack/db
@tanstack/electric-db-collection
@tanstack/query-db-collection
@tanstack/react-db
@tanstack/vue-db
commit: |
Contributor
|
Size Change: +295 B (+0.78%) Total Size: 38.2 kB
ℹ️ View Unchanged
|
Contributor
|
Size Change: 0 B Total Size: 1.05 kB ℹ️ View Unchanged
|
…markReady() methods - Add isReady() method to collections returning boolean readiness state - Add markReady() method to sync configurations for explicit readiness signaling - Update all sync implementations (Electric, Query, Local-only, Local-storage, Live query) to call markReady() - Fix test utilities to properly call markReady() after initial sync - Enable direct loading → ready state transitions without requiring commits - Replace commit-based readiness detection with explicit markReady() calls Fixes #266 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
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
This PR implements explicit collection readiness detection as requested in #266, replacing the previous approach of using commits as readiness signals.
Changes Made
isReady()method to check if a collection is ready for useonFirstReady()method to register callbacks for when collection becomes ready (replacesonFirstCommit())markReady()to SyncConfig interface for sync implementations to explicitly signal readinessloading→readytransition for cases with no data to commitmarkReady()Benefits
Test Coverage
All tests pass (716 tests), including new lifecycle tests that verify the readiness detection works correctly in various scenarios.
Fixes #266
🤖 Generated with Claude Code