Should I reset my redux store on each router navigation?

Viewed 772

I'm using Angular to write my application, and I use Redux through ngrx/store to store my application state.

Everything work fine, but now that my application get pretty large, I came with the following observation:

For nearly each page/resource, I use a different resolver that fetch from my backend, all the data necessary to correctly display and act on this particular page.

This resolver allow me to make this page independent from the previous state of the application.

So if the application is loaded and started from, let's say: https://myapp.com/resourcetype1/resourceId

The resolver will load the resourcetype1 with id resourceId in order for my page to work out of the box.

Knowing that, I was wondering if it could be a good idea to fully reset my redux store on each router navigation start.

I think this could have two benefits:

  • Provide a cleaner redux store without residual data from a previously executed page.
  • Provide an empty store before each 'page display', which could help to detect when a page is using data from a previously loaded page (and so which would have crashed if loaded 'directly' using its urm).

So the questions are:

  • What do you think about this reflexion?
  • What are your habit concerning that?
  • Are you resetting your redux store at some point or no?
1 Answers
Related