btroncone / ngrx-store-localstorage

Simple syncing between @ngrx store and local storage

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rehydrating lazy loaded feaure modules

nshathish opened this issue · comments

when rehydrating the session storage data to the state, only features modules that are loaded already have their features stores filled in from the session storage
how to rehydrate everything from the session storage into the state ?

1.) You have to make sure rehydrate: true is set!

export function localStorageSyncReducer(reducer: ActionReducer<any>): ActionReducer<any> {
  return localStorageSync({keys: ['someStorageKey'], rehydrate: true})(reducer);
}

2.) Registering localStorageSyncReducer in your root module:

StoreModule.forRoot({}, {
   ...
   ...
   metaReducers: [localStorageSyncReducer],
}),
``

we have exactly the same problem