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?
I realized that persistence of an
altjs store
onlocalStorage
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 anArray
and not as aMap
. This makes theMap
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 useMap
at all?Thanks.