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

Manual selection of theme #547

Open
Pierotimo opened this issue Feb 16, 2021 · 1 comment
Open

Manual selection of theme #547

Pierotimo opened this issue Feb 16, 2021 · 1 comment

Comments

@Pierotimo
Copy link

Hello,

Could you add a little code sample to show how to manually select the theme (such as to save it between sessions) ?

Thank you very much,
P.

@millbj92
Copy link
Contributor

millbj92 commented Aug 7, 2021

I'm not entirely sure what you're asking. In the demo you should be able to select the cog icon on the right hand side of the toolbar, and there will be a dropdown for selecting the theme you'd like. It also does persist state using a combination of ngrx and localStorage.
Check out both:

app/core/local-storage
app/core/settings.

You can see where app state is being set. Once you've read and understood those files, take a look at these:

app/core/meta-reducers/init-state-from-local-storage
app/core/core.module.ts (line 124)

That line is importing the local storage meta-reducer and rehydrating the state for you.

There are a vew reasons why your data wouldn't persist:

  • You're opening the app inside of an incognito window, which would allow writing to localStorage but delete it as soon as the tab is closed.
  • You're using an older version of IE that doesn't allow access to localStorage.
  • Your cache is somehow being cleared every run. Make sure you don't have any extensions, etc, that clear cache.

If all else fails, delete and re-clone the repo.

There's an excellent article on state re-hydration using local storage here
An explanation on all of the different storage options for a browser can be found here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants