joshnuss / svelte-persisted-store

A Svelte store that persists to localStorage

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Release a new version on npm

mrexodia opened this issue · comments

Today I was trying to use this package with the serializer, but it wasn't working. Then I realized the last release is from 2021 so it would be cool if you could release an update!

In the end this worked for me:

npm install https://github.com/joshnuss/svelte-local-storage-store.git#7d1af4885c5e2572011fcbcc2b56ffa45e8f0eaa

If you're interested here is an example for the README of only storing specific keys in the local storage (I use bind:this on every entry and some cached calculations that I don't want to store in local storage):

const entries = writable("entries", [{ text: "", calories: 0 }], {
    serializer: {
      parse: JSON.parse,
      stringify: (entries) =>
        JSON.stringify(
          entries.map(({ text, calories }) => ({ text, calories }))
        ),
    },
  });

Hi @mrexodia,

Thanks for letting me know. It seems the release wasn't triggered because the issue wasn't using sematic commit messages, so it didn't trigger the automatic push.

Going forward, I'll make sure we use feat:, fix: etc in commit messages.

For now, I forced a deploy. You should find 0.3.0 on npm:
https://www.npmjs.com/package/svelte-local-storage-store

Feel free to open a PR to add an example to the docs. I think a simple example would be to serialize {firstName: 'John', lastName: 'Smith'} as ${firstName} ${lastName} and parsing it const [firstName, lastName] = data.split(' ')

Thanks again,