-
Notifications
You must be signed in to change notification settings - Fork 108
Add getOptimisticInfo() method to track optimistic state per record #660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Implements a new collection.getOptimisticInfo(id) method that returns rich metadata about optimistic state for a given record. Returns: - isOptimistic: boolean flag indicating if record has active mutations - original: pre-mutation state (for updates) - modified: current state including optimistic changes - changes: delta of modifications (for updates) - mutations: array of all active mutations affecting the record This provides everything needed for UI states like loading badges, diff views, and rollback UI. Closes #20 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 96e987e 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: |
|
Size Change: +464 B (+0.61%) Total Size: 76.9 kB
ℹ️ View Unchanged
|
|
Size Change: 0 B Total Size: 1.47 kB ℹ️ View Unchanged
|
|
Closing this for now — @samwillis pointed out that using this in a component is problematic as the component doesn't necessarily re-render when a record goes from optimistic to synced so there needs to be a way to query a This isn't a priority atm so we'll pick this up later. |
Summary
Implements
collection.getOptimisticInfo(id)to provide rich metadata about optimistic state for a given record.Returns:
isOptimistic: boolean flag indicating if record has active mutationsoriginal: pre-mutation state (for updates)modified: current state including optimistic changeschanges: delta of modifications (for updates)mutations: array of all active mutations affecting the recordUsage:
This provides everything needed for UI states like loading badges, diff views, and rollback UI while keeping records pure (no
__optimisticfield polluting user data).Closes #20
Test plan