Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not syncing with local storage for feature module #96

Open
santhoshrajuvysyaraju opened this issue Jun 26, 2018 · 3 comments
Open

not syncing with local storage for feature module #96

santhoshrajuvysyaraju opened this issue Jun 26, 2018 · 3 comments
Labels
feature stores Functionality related to feature stores / modules known workaround There is a known workaround for this issue

Comments

@santhoshrajuvysyaraju
Copy link

santhoshrajuvysyaraju commented Jun 26, 2018

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.

@santhoshrajuvysyaraju santhoshrajuvysyaraju changed the title nor syncing with local storage for feature module not syncing with local storage for feature module Jun 26, 2018
@ernestomancebo
Copy link
Collaborator

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 }),
...

@broot02
Copy link

broot02 commented Oct 11, 2019

@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.

@Abhirocks889
Copy link

Hello, I just created a PR to address this issue: #249

Can you please check and review if it suffices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature stores Functionality related to feature stores / modules known workaround There is a known workaround for this issue
Projects
None yet
Development

No branches or pull requests

5 participants