You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently changing the serializer (from json to devalue in my case) is messy, because as long as someone can have stale data, you need to do this (I'm also posting in case other people face this problem):
constbrowser=typeofwindow!=="undefined"&&typeofdocument!=="undefined"// for SSRif(browser)try{serializer.parse(localStorage.get(key))}catch{localStorage.setItem(key,"") # removeItemdidntworkforme}store=persisted(key,defaults,{ serializer })
And I found the fact that onError only catches read errors and not parse errors misleading which cost me extra time.
Both these problems would be solved by simply adding another option onParseError defaulting to rethrowing, that you could supply with your default value - then autocomplete would also make it clear that onError doesn't include parsing errors.
Perhaps onParseError could be passed the serialised string to have the option open for falling back to the old parser, but I wouldn't have used it.
Currently changing the serializer (from json to devalue in my case) is messy, because as long as someone can have stale data, you need to do this (I'm also posting in case other people face this problem):
And I found the fact that
onError
only catches read errors and not parse errors misleading which cost me extra time.Both these problems would be solved by simply adding another option
onParseError
defaulting to rethrowing, that you could supply with your default value - then autocomplete would also make it clear thatonError
doesn't include parsing errors.Perhaps
onParseError
could be passed the serialised string to have the option open for falling back to the old parser, but I wouldn't have used it.Edit:
I settled on:
The text was updated successfully, but these errors were encountered: