Closed danawoodman closed 7 months ago
Hi Dana!
Yes, I'd like to fully support Svelte 5.
Ideally it should support Runes too. But in the meantime, updating peerDependencies
is a start.
Since Svelte5 is a major update, I'd like to change a few things too.
writable
is still supported, but i'd like to remove that. ie import { writable } from 'svelte-persisted-store
)devalue
as the default serializer (instead of JSON
). Because a common gotcha is using values like undefined
and serialization doesn't work as expected.
- Consider switching to
devalue
as the default serializer (instead ofJSON
). Because a common gotcha is using values likeundefined
and serialization doesn't work as expected.
The problem with this is that devalue
is very picky and doesn't work with really common things like symbol keys on objects.
@knd775 I feel like devalue's features could be more useful than Symbol
keys.
I'm suggesting this, because "try devalue" is a common solution to many support requests.
And keep in mind, JSON will continue to be supported. It just wouldn't be the default option anymore.
I'd vote a minor release with just the peerDep change so people can start using it, then follow up with these other things :)
@danawoodman agree. Feel free to open a PR
Pardon the interruption. Why people serialize undefined
? In my mind, if the store's value is undefined
, it would mean it needs to be deleted. Serializing and deserializing it seems like a major waste of effort in my ignorant mind. If the store gets set to undefined
, I would expect the store to delete from local storage. Anything I'm missing?
@joshnuss pr up #233 !
@danawoodman I'll take a look
@webJose I agree with you, for nested attributes in an object. The problem is that if you set the root value to undefined
, for some reason localStorage.setItem()
saves it as a string "undefined"
.
> localStorage.setItem('mykey', undefined)
> localStorage.getItem('mykey')
"undefined"
But it's not just undefined-handling that makes devalue
useful. It also supports Date
, Set
, Map
, BigInt
, circular objects, Infinity
, NaN
:tada: This issue has been resolved in version 0.9.0 :tada:
The release is available on:
Your semantic-release bot :package::rocket:
I understand Svelte 5 is still a preview release, but I'd love to be able to use this store with it. I believe since Svelte 5 is backwards compatible it should just work adding v5 to the
peerDependencies
chain.Could throw together a PR if interested