Conversation
🦋 Changeset detectedLatest commit: f509b2b 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: |
|
Size Change: 0 B Total Size: 29 kB ℹ️ View Unchanged
|
|
Size Change: 0 B Total Size: 561 B ℹ️ View Unchanged
|
|
This is intended to be used for persisting a small amount of state (auth, UI prefs etc), and so it stores it all under one key in local storage. One thing we should consider is adding some metadata to the JSON blob about the way it was stored. I've currently implanted a |
KyleAMathews
left a comment
There was a problem hiding this comment.
Looks great!
Only missing thing is some docs
…e and syncs between tabs (#203) Co-authored-by: Cursor Agent <cursoragent@cursor.com>
This is a localStorageCollectionOptions to implement a collection that persists to localStorage (or sessionStorate) and syncs between tabs.
A
localStorageCollectionOptionsfunction was created inpackages/db-collections/src/local-storage.tsto provide a collection type backed by browser storage.storageoption now usesPick<Storage, 'getItem' | 'setItem' | 'removeItem'>for direct DOM compatibility, defaulting towindow.localStorage.storageEventApioption was refined to a type alias matchingWindow's event methods for'storage'events, defaulting towindow, ensuring pluggable cross-tab synchronization.versionKey(UUID) for efficient change detection, replacingJSON.stringifycomparisons.onInsert,onUpdate, andonDeletehandlers now directly perform storage operations and manually trigger local syncs, as storage events do not fire for the current tab.iddefaults tolocal-collection:{storageKey}for predictable naming.local-storage.tsandlocal-storage.test.ts.awaitkeywords were removed from synchronous collection methods inlocal-storage.test.ts.local-storage.test-d.tsfile was added to validate type compatibility withcreateCollection.