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

Refactor time selectors state shape to use array #1

Merged
merged 1 commit into from Nov 30, 2018

Conversation

johnschoeman
Copy link
Owner

Why:
Previously we were using a complex and nested object to encode selector
state in the application. This is both more structure than what is
required, increasing mental overhead to understand, and mixes the
concerns of updatable state and static presentational data, introducing
unnecessary coupling between components and the redux store. (We don't
need redux or a web server to tell us there is 7 days in the week and
what their names are.)

This commit:
Refactors the time selector components and their slice of redux state to
use an array to encode selected days. Components are provided constants
to supply button title information. These titles will also be used as
the toggle selector action payloads.

In general:

  • Redux should only contain information which can change during app use.
  • Components should stand on their own and not depend on redux to
    render a default state.
  • The redux should be as flat as possible, nested data is a code smell.

Why:
Previously we were using a complex and nested object to encode selector
state in the application. This is both more structure than what is
required, increasing mental overhead to understand, and mixes the
concerns of updatable state and static presentational data, introducing
unnecessary coupling between components and the redux store. (We don't
need redux or a web server to tell us there is 7 days in the week and
what their names are.)

This commit:
Refactors the time selector components and their slice of redux state to
use an array to encode selected days. Components are provided constants
to supply button title information. These titles will also be used as
the toggle selector action payloads.

In general:
- Redux should only contain information which can change during app use.
- Components should stand on their own and not depend on redux to
render a default state.
- The redux should be as flat as possible, nested data is a code smell.
@johnschoeman johnschoeman merged commit 09dac23 into master Nov 30, 2018
@johnschoeman johnschoeman deleted the jts-diff-state-shape branch November 30, 2018 19:19
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

Successfully merging this pull request may close these issues.

None yet

1 participant