Replies: 1 comment
-
Thanks @mschwartz! You are right, it can totally be defined once. Though it will require some refactoring, since the event sends the new value serialized, but it will need to be deserialized according to the serializer option of the store (it's not always JSON). |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
https://github.com/joshnuss/svelte-local-storage-store/blob/34b1994bd22180d704d7629938e9b27936aa375e/index.ts#L50
You are creating an event handler and capture for every store, plus adding a listener for it.
I don’t think you need more than one listener. The Event object passed to the handler includes the key, and you have the map of key to store already.
This optimization can save memory and be more performant , IMO.
Beta Was this translation helpful? Give feedback.
All reactions