Replies: 2 comments 2 replies
-
Hello! detail
.pullback(state: /State.Route.detail, action: /Action.detail, …)
.optional()
.pullback(state: \.route, action: /Action.self, …) If you read from bottom to top, you go through |
Beta Was this translation helpful? Give feedback.
-
Hi @tgrapperon. Many thanks for a quick response. What you suggested almost works. :) extension Parent {
static let reducer: Reducer<State, Action, Void> =
Detail.reducer
.pullback(
state: /.detail,
action: /Action.detail,
environment: {}
)
.optional()
.pullback(
state: /.route, // Member 'route' in 'Parent.State' produces result of type 'Parent.State.Route?', but context expects 'Parent.State'
action: /Action.self,
environment: {}
)
} Conceptually, I understand your explanation starting with "If you read from bottom to top..." but I must admit that I just don't grasp how that actually happens in the code. The way I understand it, we start with a reducer ( At that point, the I don't know how to compose the case paths to achieve that result and then use only one I don't find all of this particularly dense but I do think it's very abstract and obscure. Anyway, it's late in the night here so I'm going to sleep and won't check this thread again until tomorrow. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello :)
I'm struggling to get the code below to compile when trying to use a case path to the
Detail
state in the reducerpullback
.As written below (and with suitable code for the
Detail
scene), the code compiles fine but then having to manually create a property to extract the child (detail) state from theroute
property defeats the purpose of using enums (with states as associated types) for navigation.When I tried the more natural code that is commented out, with or without the
.optional()
modifier for the reducer (by the way, it's not clear to me whether I should or shouldn't have it), I got the indicated error messages.I do understand the messages, in particular, that the two case paths (expected and provided) are of different types. My problem is that I don't know how to provide the correct one, given the set up for the
Parent
scene state.Any help or clarification would be greatly appreciated. Many thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions