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

Document State Management Strategy #179

Open
murilo9 opened this issue Dec 9, 2024 · 1 comment
Open

Document State Management Strategy #179

murilo9 opened this issue Dec 9, 2024 · 1 comment
Labels
documentation Improvements or additions to documentation needs more info Not ready for coding just yet

Comments

@murilo9
Copy link
Contributor

murilo9 commented Dec 9, 2024

Prevent "impossible" state inside the store

I have noticed that in some places, the store uses a few variables to describe the state of the same thing (a request status). But the possible value combinations for these variables are not implicit, which could lead to impossible states in the long run, which are considerably difficult to debug.

My suggestion to prevent impossible states: map the possible states (maybe create an interface for each?) and add the types to the store. Or, to be more specific: instead of having multiple state variables (isProcessing, isSuccess, value, error) there could be only status ("processing" | "success" | "error") and value (either the success payload or the error message). That way we would get a compilation error every time we tried to assign an impossible state to the store (like isSuccess equal to true and a non-nullish value for error), preventing bugs and leading to a more predictable state.

@tyler-dane tyler-dane changed the title Prevent "impossible" state inside the store Redesign State Management Strategy Dec 16, 2024
@tyler-dane tyler-dane added needs more info Not ready for coding just yet documentation Improvements or additions to documentation labels Dec 16, 2024
@tyler-dane
Copy link
Contributor

Retitled this issue to make it a living document to discuss to improve the state management strategy.

We're currently focused on working with the tools/patterns we have, but we will need to make some changes over the medium term to avoid getting crippled by the tech debt.

Feel free to keep adding suggestions to this issue as they come up.

@tyler-dane tyler-dane changed the title Redesign State Management Strategy Document State Management Strategy Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation needs more info Not ready for coding just yet
Projects
None yet
Development

No branches or pull requests

2 participants