(redux / ngrx) Would you recommend storing UI related states?
As far as I understand the principle of redux architecture, it eases the complexity when the application state changes (business logic?).
But is it also necessary to handle view-related states in a shorthand way? For example. whether the sidebar is currently open, or a specific block of information is unlocked, etc.?
This was done on the ngrx / store page . But since the application logic does not depend in any way on these view states, I cannot really see its benefits.
source to share
I had to do this for several reasons (this is more specific to the HTTP request loading status, error status, etc.):
-
Unable to determine status, success or http error . When we submit, post or upload a request, it is just a one-way flow. This will not give us if the request is successful or if it gave an error. Imagine the submit request gave a validation error, we need to save this
-
Less code in a component , easy to write unit tests, easy to code, easy to automate code. Services are always easy to test against components.
-
Update in multiple components . Imagine we are showing a summary in a dashboard and the actual data in a component. We need to show in the dashboard that the data is being updated, it is impossible if the status is stored in the component
- Save application state to localstorage . One scenario I had to save the UI status to local storage. Sidebar users' preference increased or decreased, text size, etc. Even in these cases, the store had to be used.
source to share