Collection of Reducers, Scope and item access ? #147
Replies: 3 comments 2 replies
-
Hi @JeromeTonnelierOgury, I think this question would be best to ask in the library's repo so that more people can see it. And when you start a discussion over there, it would help to provide a bit more code to demonstrate the problem. But, as just one quick comment, if the horizontal lists of ingredients do not have significant behavior in them, such as side effects, then you may not need to split up the feature into smaller pieces. You can just use a collection of values and use |
Beta Was this translation helpful? Give feedback.
-
Ok thanks. |
Beta Was this translation helpful? Give feedback.
-
Ok but a Stepper needs a binding, how can I use it with a Collection (Array, set, ...) ForEach(viewStore.section) { section in
VStack {
Text(section.title)
HStack {
ForEach(section.ingredient) ( ingredient in
Stepper("",
value: viewStore.$section[???] // <-- how can I use index here ? $section is a Binding, so $section[index] does not work
)
}
}
}
} |
Beta Was this translation helpful? Give feedback.
-
Hi everyone,
still continuing to learn TCA, and I encoutered a weird case, I don't how to resolve this one 😓
Let's say I have a list of ingredient (flour, sugar, chocolate, ...) and I want to present a controller that allows me to choose the quantity of each ingredient.
I ordered my objects like this basically
I have a view with a stepper that allows me to increment the nb of a particular item. So I created a Reducer that holds an Ingredient as a State and it works fine.
Now I would like to put it all together with a double scroll view (an horizontal list of Ingredients ("Section") and a vertical list of sections, just like the App Store App for example).
So I have a reducer's State that will look like this
I managed to create the view, but I'm stuck when I have to
scope
my main reducer into the small one. Usually, from what I saw and used, we have to create a target reducer State inside the parent's state and use setters and getter to do the magic. But here, I have to do this from an array, so I cannot use a variable.Is it an architectural issue or more likely, the geniuses of PointFree have developed a stuff I'm not aware of :D
Thanks for your help <3
Beta Was this translation helpful? Give feedback.
All reactions