8000 ES2015 Map on a Store and LocalStorage · Issue #663 · goatslacker/alt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
ES2015 Map on a Store and LocalStorage #663
Open
@afilp

Description

@afilp

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0