Skip to content

Conversation

@KrosFire
Copy link
Contributor

https://pikax.me/vue-composable/composable/storage/localStorage.html

In current documentation, remove function is described as an equivalent to storage.value = undefined, but it's false.
When we set starage.value = undefined, this undefined is being stored in localStorage as 'undefined' (string), which lead to issues when reloading the app.

Another issue is when we pass a ref as a defaultValue (which is acceptable), then the ref itself (object) is saved into localStorage, rather that it's value.

There's also a thing that is missing for me personally and that is instant save into storage. Debounce is great but when I tried to use your library to store accessToken in localStorage I had an issue. In some requests the key was missing, so I believe that an option to fully sync storage with ref would be nice.

I also don't see any reason to provide setSync function in sessionStorage, when it's useless.

I've fixed those and few other things in this pull req

KrosFire and others added 4 commits September 18, 2021 22:38
…o that it works according to the documentation. Removed setSync from useSessionStorage as it is unusable. Removed a bug of saving value into storage, just after it was read from it. Added useDebounce parameter so that storage is updated instantly (it's usefull for example when saving accessToken in localStorage and reading from it rather than from ref). Fixed a bug of giving the ref as a defaultValue and saving the ref into a storage, rather than the value of a ref
@pikax
Copy link
Owner

pikax commented Oct 17, 2021

Thank you, sorry for the delay, tests failing on expect(storage1.value).toMatchObject(storage2.value);

@KrosFire
Copy link
Contributor Author

I believe I've fixed tests. It was just typescript screaming about possible undefined.

@KrosFire
Copy link
Contributor Author

@pikax Could you run pipeline once again?

@KrosFire
Copy link
Contributor Author

@pikax I think test failed regardless of my changes and just needs a rerun

@pikax pikax merged commit 879528a into pikax:master Jul 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants