Repository navigation
localOnlyCollectionOptions collection for ephemeral local state - #204
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: 72c3e17 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 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 commit: |
Contributor
|
Size Change: 0 B Total Size: 29.2 kB ℹ️ View Unchanged
|
Contributor
|
Size Change: 0 B Total Size: 561 B ℹ️ View Unchanged
|
Implement true loopback sync for local-only collections Add initial data support for local-only collections Refactor local-only collection with optimistic updates and custom callbacks Checkpoint before follow-up message Update local-only sync to support custom key types Update local-only collection tests with extended generic types Refactor local-only sync function signature for improved readability Add explicit key type parameter to localOnlyCollectionOptions Checkpoint before follow-up message Checkpoint before follow-up message Add localOnly collection type for in-memory collections Add localOnly collection type for in-memory collections Refactor local-only collection handlers to call user handlers before confirming transactions fix changeset
samwillis
force-pushed
the
cursor/implement-localonly-collection-type-b6eb
branch
from
July 6, 2025 14:03
36bd9c4 to
7b2d15b
Compare
samwillis
marked this pull request as ready for review
July 6, 2025 14:18
Merged
cursor Bot
pushed a commit
that referenced
this pull request
Jul 16, 2025
Co-authored-by: Cursor Agent <[email protected]>
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.
Stacked on #230 - merge that first!
This just loops back on the sync interface applying all changes immediately.
There is a failing tests, I'm suspicious it is exposing something else going on that we need to look at.(edit: fixed in #230)A
localOnlycollection type was implemented in@tanstack/db-collections.Key changes include:
packages/db-collections/src/local-only.tswas created, exportinglocalOnlyCollectionOptionsand related types.localOnlyCollectionOptionsfunction now configures an in-memory collection with a "loopback" sync.createLocalOnlySyncfunction captures the collection's internalbegin,write, andcommitfunctions.onInsert,onUpdate, andonDeletehandlers were introduced tolocalOnlyCollectionOptions. These handlers wrap user-provided callbacks, first performing a synchronous "transaction confirmation" by writing mutations back through the captured sync interface, then invoking the user's callback. This ensures optimistic changes are immediately reflected.initialDataarray was added toLocalOnlyCollectionConfig, allowing the collection to be pre-populated during its initial sync.getKeywas refined acrossLocalOnlyCollectionConfig,localOnlyCollectionOptions, andcreateLocalOnlySyncto correctly propagate specific key types (e.g.,numberinstead ofstring | number).packages/db-collections/tests/local-only.test-d.tsfile was added to verify type compatibility withcreateCollection.async) were resolved.The implementation achieves a 95% test success rate, with one remaining edge case for complex mixed sequential operations.