Platform: Add Store Hydration/Serialization API

Created on 25 Feb 2018  路  13Comments  路  Source: ngrx/platform

To better support state serialization and hydration I recommend adding built-in APIs into @ngrx/store. We should try and tackle the two biggest use cases:

  • Serializing state for server side rendering
  • Persisting state in browser and native platform storage

Ideally, we would separate the process of persistence and serialization into two steps:

  1. Transform - Take a state object and perform a transformation on it
  2. Store - Take the transformed result and save it

This would allow authors of persistence strategies to focus on persistence without having to reimplement key filtering or Immutable restructuring.

Store enhancement

Most helpful comment

Just throwing out ideas while we're on the topic ... but it would be awesome if something like https://github.com/btroncone/ngrx-store-localstorage became a first class part of ngrx itself. Serializing out for SSR and indexedDB usage is definitely important too, but I would guess that the majority of people are just saving bits of state to localstorage. Plus, the library above doesn't work with feature modules.

All 13 comments

Remember handling async storage in saving to indexedDB or some native cordova plugin filesystem etc.

Just throwing out ideas while we're on the topic ... but it would be awesome if something like https://github.com/btroncone/ngrx-store-localstorage became a first class part of ngrx itself. Serializing out for SSR and indexedDB usage is definitely important too, but I would guess that the majority of people are just saving bits of state to localstorage. Plus, the library above doesn't work with feature modules.

.... When is this going to be implemented? :-( Wasn't it for 7.0?? (today....)

@brandonroberts When do you think it is going to work?

@brandonroberts may I take this?

@Dutchboy @itayod we're going to put together a design for this first, which we have on our list to look at since version 8 has launched.

@brandonroberts sounds great!
meanwhile, I have posted a blog that might help users to implement it:
https://medium.com/better-programming/sync-your-state-in-local-storage-with-ngrx-9d6ceba93fc0

I'm using ngrx-store-sync that I hacked together. Seems to work for my use case.

Putting it here to maybe give you some ideas how to do it (or not do it :D)

@itayod maybe update your article and repo to 8, because of breaking changes in meta reducer

@rickvandermey Thanks for noticing me! but I think most of the users are still on version 7.X. so I guess update it now could lead to some confusion at this point :)

Any news on this one?

Is there any more news? What have you done to contribute.

@classifieds-dev relax man! I was just asking!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

smorandi picture smorandi  路  3Comments

hccampos picture hccampos  路  3Comments

dmytro-gokun picture dmytro-gokun  路  3Comments

NathanWalker picture NathanWalker  路  3Comments

sandangel picture sandangel  路  3Comments