ngrx-store-localstorage
ngrx-store-localstorage copied to clipboard
not syncing with local storage for feature module
Hi ,
i have tried to sync the store with following code. but it is not synching.
Please see the code.
export function localStorageSyncReducer(reducer: ActionReducer<any>): ActionReducer<any> {
return localStorageSync({keys: ['adminState'], rehydrate: true })(reducer);
}
const metaReducers: Array<MetaReducer<any, any>> = [localStorageSyncReducer];
here is my call in imports.
StoreModule.forFeature('adminState',userReducer,{ metaReducers }),
EffectsModule.forFeature([AdminEffects])
the main problem is it is not giving any error. it is not synching the store with local storage tried using feature module.
but it is fine working in root module.
help me to solve the issue.
Try passing an initial state to the third argument
StoreModule.forFeature('adminState', userReducer, { initialState: {}, metaReducers }),
or to the forRoot module.
...
StoreModule.forRoot({}),
StoreModule.forFeature('adminState', userReducer, { metaReducers }),
...
@santhoshrajuvysyaraju
Did you ever figure this out? I am running into the same issue, I believe it is just a configuration issue. But the localStorageSync is never being called for feature modules/stores, but the root module/store is working as expected.
Hello, I just created a PR to address this issue: https://github.com/btroncone/ngrx-store-localstorage/pull/249
Can you please check and review if it suffices.