-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add store's action queue state on ViewStore and modify private only setter #64
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What you first suggested was necessary. Thanks!
However, I don't understand the need for your second suggestion about actionQueue
and isProcessing
. Could you explain why it is needed?
Note
Directly modifying the state of the store can lead to unintended side effects and is considered an anti-pattern. It is preferable to change the state only by calling send()
.
@DevYeom The reason of second one, just my opinion, is that i thought Combination with 'queue-based' system and Unidirectional system could be let know developers proper informations of I already know |
Your second suggestion also makes sense. However, There is a way to find out if a long-duration action is being processed could be as follows. func reduce(state: inout State, action: Action) -> AnyEffect<Action> {
// ...
case .request:
return .concat(
.just(.setIsLoading(true)),
.single {
let result = await longTimeAPI.request()
return .response(result)
},
.just(.setIsLoading(false))
)
case .setIsLoading(let isLoading):
state.isLoading = isLoading
return .none
}
// ...
} I also have a plan to support a debug print feature(e.g. printing changes in state to the console). I hope you understand that I try not to expose the interface externally( How about only including the first suggestion this time? |
Very acceptable decision! Please check it out! @DevYeom |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Related Issues 💭
I have two suggestion's for ViewStore.
One is making a limitation for allowing setter on public.
The other one is let viewstore be able to know of store's state, especially actionQueue.
Description 📝
Additional Notes 📚
Checklist ✅