Replies: 1 comment
-
|
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. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
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")andvalue(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 (likeisSuccessequal totrueand a non-nullish value forerror), preventing bugs and leading to a more predictable state.Beta Was this translation helpful? Give feedback.
All reactions