Reducing the boilerplate: tapped actions in a list #379
tiagoalmeida
started this conversation in
General
Replies: 1 comment 2 replies
-
Hi @tiagoalmeida, this sounds very interesting, but I think I would need to see more code to understand your situation exactly. Is it possible to whip up a small example with how the state/action/reducer and view code looks? |
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
-
First of all let me thank you for the last episode, it shows that you are thinking about real problems and usage of TCA.
I have been trying to reduce boilerplate for a while and FormAction/BindingAction is a great place to start!
However, I have a different challenge. I have a settings screen built with UIKit and a TableView that has a couple of options that open other screens. Each option fires an action (i.e : "Team" fires .teamTapped)
🧭 Starting the quest
I have started my quest to reduce boilerplate by wanting to do something like this when I am creating a row that belongs to the SettingsState:
.init(title: L10n.Settings.Row.team, action: . teamTapped),
Then in my reducer I would check: do I have an action? then just return it.
I started that by having a generic in the RowState and have a property let action: Action. But that always felt wrong to me, and introduces some problems you talked about in the last episode.
🤔 Trying to improve what I have with the ideas from last episode
After seeing the episode I was pumped and started to try to improve what I have, but I quickly found out some issues:
Any idea where I could start doing this?
Beta Was this translation helpful? Give feedback.
All reactions