joshnuss / svelte-persisted-store

A Svelte store that persists to localStorage

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature: Validator function to support replacement of invalid value

webJose opened this issue · comments

I would like to be able to pass a validator function that runs whenever the persisted store reads storage for the first time. This is helpful in software upgrade scenarios where the shape of the stored data may change to support new features, or to fix bugs.

Let's also remember that storage can be altered by users using developer tools, so this is another source of uncertainty for local storage values.

If you support the idea, I'll make the PR.

This is the first time anyone has requested this.

I think for the time being, I'd like to keep the API as simple as possible.

I will close for now, but if anyone else needs this, comment below and we can reconsider if there are many others that need it.