Add a default setState
action to every reducer that has State
#562
ferologics
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
I think what you’re looking for is Take a look at this sample project for an example of how to use it: https://github.com/pointfreeco/swift-composable-architecture/blob/0f026d395d414efab5cfdf8d697ec0ae766dd021/Examples/CaseStudies/SwiftUICaseStudies/01-GettingStarted-Bindings-Forms.swift |
Beta Was this translation helpful? Give feedback.
1 reply
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.
-
Many times we have to write custom
setVariableName(to:)
actions, I wonder if this code could be be generated for us somehow. It may also be possible to infer the state variables and provide a defaultset(stateKey:,stateValue:)
action that can be returned from reducers / sent with the view store when needed.Why we shouldn't do this? Well, it increases the surface of the domain in which you're operating, meaning, sometimes you don't want to have one-to-one state <-> action setters, and only do it for a few select state variables.
It would be a nice convenience, but could also inhibit testing, and the bunch.
Beta Was this translation helpful? Give feedback.
All reactions