Reducer to snapshot substate #1748
Unanswered
ibrahimkteish
asked this question in
Q&A
Replies: 2 comments 7 replies
-
If you use the @dependency system you could override the child env and guard if there is changes made before calling the networking dependency. |
Beta Was this translation helpful? Give feedback.
2 replies
-
@tgrapperon do you have any suggestion ? |
Beta Was this translation helpful? Give feedback.
5 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.
-
Imagine we have the following:
Imaging that the
ChildReducer
we are editing some properties then submitting a network request.I am trying to prevent a network request from being made if the child state has not changed, but I am unsure of how to handle the scenario where the user changes some properties and then reverts them back. I considered implementing a reducer to hold the initial state and a flag shouldSendRequest that is set to true and used to control the display of the send button in the UI, but I am not sure if this is the best approach.
So I came up with the following:
I am concerned that my current approach of using a reducer to store the initial state and a flag
shouldSendRequest
to control the display of the send button may not be the best solution because it is not generalizable and requires me to set/get a global variable. Additionally, I would need to implement the==
operator to skip checkingshouldSendRequest
.Any better alternative?
sendButtonTapped
is triggered?struct StateWrapper<T> { initial, current }
Do you have any recommendations or suggestions for these alternatives?
Beta Was this translation helpful? Give feedback.
All reactions