ES2015 Map on a Store and LocalStorage
- Dominant language
- JavaScript
- Stars
- 3.4k
- Forks
- 312
- PR merge metrics
- No merged PRs in 30d
Description
I realized that persistence of an `altjs store` on `localStorage` has problems when the store uses an ES2015 (ES6) `Map`.
The problem is that when the store is retrieved from the localStorage, the `Map` is retrieved as an `Array` and not as a `Map`. This makes the `Map` functions on this entity to fail.
This is how the store data is set on localStorage:
`localStorage.setItem(storeName, JSON.stringify(alt.takeSnapshot(storeName)));`
...and this is how the store data is retrieved from localStorage:
`JSON.parse(localStorage.getItem(storeName))`
Do you have your own utils to solve this problem of persistence on localStorage and respect the `Map` entities? If not, is there any solution to this problem without having to not use `Map` at all?
Thanks.
Contributor guide
Assessment
This issue has not been assessed yet.