Open Not-Jayden opened 4 weeks ago
Latest commit: 41f949510d9628e9c1f7ee7a8bdcc362b8bf6229
The changes in this PR will be included in the next version bump.
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
Name | Status | Preview | Last Commit |
---|---|---|---|
runed | ✅ Ready (View Log) | Visit Preview | 41f949510d9628e9c1f7ee7a8bdcc362b8bf6229 |
I haven't had a chance to give this a thorough review, but I love what I see.
Regarding the name, I think Persisted
is cleaner, though I'll defer to the others if dropping the State
makes what it does less obvious.
For something like this, I wonder if we can take it a step further and accept a custom Storage
type rather than just the custom serializer/deserializer. We can include adapters for session and local storage out of the box while allowing users to BYOS any storage system they wish as long as it follows our Storage
interface.
I'm currently imagining a situation where we could leverage this along with something like Supabase or any real-time DB to bind specific values. If something changes in the DB, it updates, and if something changes that value in the app, it updates the DB. Having a flexible StorageAdapter
would be sick for something like this!
I haven't had a chance to give this a thorough review, but I love what I see.
Regarding the name, I think
Persisted
is cleaner, though I'll defer to the others if dropping theState
makes what it does less obvious.For something like this, I wonder if we can take it a step further and accept a custom
Storage
type rather than just the custom serializer/deserializer. We can include adapters for session and local storage out of the box while allowing users to BYOS any storage system they wish as long as it follows ourStorage
interface.I'm currently imagining a situation where we could leverage this along with something like Supabase or any real-time DB to bind specific values. If something changes in the DB, it updates, and if something changes that value in the app, it updates the DB. Having a flexible
StorageAdapter
would be sick for something like this!
@huntabyte thanks! Agree the adapter might be good for future extensibility, I've had a crack at it in this branch: https://github.com/svecosystem/runed/pull/118
Seems to be working fine but will sanity check it over the weekend to be sure and update docs if all looks good. If you have any feedback in the meantime it would be appreciated to make sure I don't sink too much time into going the wrong direction :)
Going to give this a review this week, I promise @Not-Jayden!
Thanks for your patience!
Discussing the storage adapter PR with the other maintainers as we speak! Hopefully we can polish it and get this shipped sooner rather than later 😃
Creates reactive state that is persisted and synced across sessions and browser tabs. Inspired by https://github.com/joshnuss/svelte-persisted-store
See docs: https://not-jayden-persisted-state.runed.pages.dev/docs/utilities/persisted-state