Search code examples
angularngxs

Angular 11 Ngxs-Storage-Plugin restore Dates


I'm trying to transition from NgRx to NGXS in my Angular project and i was wondering if there is any way to restore dates with the Ngxs-Storage-Plugin like the library ngrx-store-localstorage for NgRx does or do i have to do it manually in the afterDeserialize function?


Solution

  • There is no built in way for the storage plugin to know what is a date and what's a string/number. You're best bet would be to just use the Serialization Interceptors or create a Custom Storage Engine. Under the hood the default storage engine just uses JSON.parse and JSON.stringify