Search code examples
javascriptpolymerpolymer-1.0predix

How to prevent js variables from being reset on reload in Polymer?


I am trying to build a simple app on polymer using predix, the problem I am facing is: When the page reloads, the variables go back to their initial state, I am using those variables to show/hide content on navigation to other pages(.html files). I have one main .html file, where the variables are declared and has routes to all the files .

Questions:

  1. What are the ways to prevent this?

  2. How can I do this better as I am planning to build another bigger and complex application, which will require users logging in and out?


Solution

  • Any information you need to store on the client should be written in localStorage. I personally prefer using redux with my state stored in localStorage. With this my users can continue to work exactly where they stopped. Athentication is something else you need to implement a Refresh Token mechanism like Auth0 is providing.