[Spike] Enforce a stronger directory structure in Redux state #1355
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Part 1: alternatives on the table
Since an architectural decision about where to put what was needed on the Redux-state-side-of-things, I took a bit of time to research on what we could do.
Alternatives taken into account were:
state
packageI personally found Rails-style really compelling but we are using
redux-toolkit
that is very opinionated towards ducks/slices, since we are using thecreateSlice
helper that automatically generates constants and action creators.Part 2: execution
Since ducks/slices is what we could be most comfortable with, I tried to just get rid of the current
actions
directory bringing related actions inside the dedicated files that contain the slices.We now have:
slices
subdirectory.sagas
subdirectory.selectors
subdirectory.Part 3: drawbacks of this approach
We have one drawback: action creators related to sagas now live along with slices and action creators generated by redux-toolkit. I found reasonable to have action creators all stuffed in one specific place, but I understand that it might not be the case for everyone.
Proposed directory structure