question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

rehydrate only works when devtools intrument enabled?

See original GitHub issue

I try to save the authentication information inside localStorage. Now, in development everything worked fine, but in production the information is not rehydrated.

In my root module imports I have the following line:

!environment.production ? StoreDevtoolsModule.instrument() : [],

When I change it to instrument in development as well as in production, suddenly also rehydration of the state works.

StoreDevtoolsModule.instrument(),

Do you have an idea what could cause the problem?

For completeness, here is how I activate ngrxLocalStorage (based on the ngrx example project in app/reducers/index.ts):

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

export const metaReducers: ActionReducer<any, any>[] = !environment.production
  ? [localStorageSyncReducer, logger]
  : [localStorageSyncReducer];

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6

github_iconTop GitHub Comments

4reactions
chuckmahcommented, Nov 24, 2017

I fixed it by moving the meta-reducer into the specific feature module of where i wanted to persist the state

StoreModule.forFeature('auth', reducers, { metaReducers: metaReducers }),

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

instead of

    StoreModule.forRoot(reducers, { metaReducers: metaReducers }),

export function localStorageSyncReducer(reducer: ActionReducer<any>): ActionReducer<any> {
  return localStorageSync({ keys: [{ 'auth': ['status'] }], rehydrate: true })(reducer);
}
0reactions
tanyagraycommented, Feb 22, 2018

This issue should be resolved as of v5.0.0 thanks to @nhaesler’s PR 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does JavaScript only work after opening developer tools ...
The console object is only activated when the Dev Toolbar is opened. Prior to that, calling the console object will result in it...
Read more >
Chrome DevTools
Chrome DevTools is a set of web developer tools built directly into the Google Chrome browser. ... Get started with Google Chrome's built-in...
Read more >
Use DevTools in Internet Explorer mode (IE mode)
In this article. Open DevTools on a tab in IE mode; Remote debugging in IE mode; Replace Internet Explorer automation; See also.
Read more >
Angular Ngrx DevTools: Important Practical Tips
This post is a step-by-step guide for setting up your Ngrx Development environment, namely the Ngrx DevTools, but not only: we will also ......
Read more >
Chrome DevTools Protocol - GitHub Pages
The Chrome DevTools Protocol allows for tools to instrument, inspect, debug and profile Chromium, Chrome and other Blink-based browsers.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found