Modeling array of enums with associated values #1835
Unanswered
tylerjames
asked this question in
Q&A
Replies: 1 comment 2 replies
-
Does it help if you refactor your struct Model {
var args: Args
var isActive: Bool
}
enum Args {
case alpha(AlphaArgs)
case beta(BetaArgs)
case gamma(GammaArgs)
case delta(DeltaArgs)
case epsilon
} This kind of data type may play more nicely with TCA. |
Beta Was this translation helpful? Give feedback.
2 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.
-
I'm modelling some state based on an array of objects that have some common properties and a field called
args
that contains properties unique to each type. I've modelled it using an enum like this:So I have a parent state with
IdentifiedArrayOf<Mode>
and a child feature that represents an individual mode.And I need to create a Form based on the properties of the mode and its args, the
isActive
and all of the customargs
will map to toggles or text fields that can be edited.Here's where I'm stuck
I'm not sure how to model the
args
state and the actions here since every differentMode
type would need to have some different actions.There's a small number of different modes and changeable properties so I wouldn't be averse to creating a custom View for each Has anybody run into this sort of issue before? I feel like I'm missing something obvious or trying to shoehorn this solution when I should be taking a different approach.
Beta Was this translation helpful? Give feedback.
All reactions