Replies: 2 comments 6 replies
-
Hi @nickkohrn, I see that you quoted my question and the subsequent answer that was provided there. As I tried to implement that answer, I ran into exactly the same problem you did and was, in fact, going to post a question to follow up, but you beat me to it! |
Beta Was this translation helpful? Give feedback.
-
Hi @nickkohrn, the problem is that a It's usually best to have the nesting of your actions match the nesting of your states. That gives you an opportunity to So, your action becomes this: enum Action: Equatable {
case dismissFilterFeatureView
case dismissSessionFeatureView
case route(Route)
case showFilterFeatureView
case showSessionFeatureView
enum Route: Equatable {
case filterFeatureAction(FilterFeatureReducer.Action)
case sessionFeatureAction(SessionFeatureReducer.Action)
}
} And your .ifLet(\.route, action: /Action.Route.self) {
EmptyReducer()
.ifCaseLet(/State.Route.filter, action: /Action.Route.filterFeatureAction) {
FilterFeatureReducer()
}
.ifCaseLet(/State.Route.session, action: /Action.Route.sessionFeatureAction) {
SessionFeatureReducer()
}
} This is the exact pattern we plan to codify directly into the navigation tools we are working on. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a view which can present two mutually exclusive sheets. Currently, my logic allows for invalid states:
In the view, I am using the following to present the respective content in a sheet:
Because of the possibility of invalid state (mismatching state/boolean, honest state and false, nil state and true, etc), I was looking at examples of using a
Route
enum. I found this answer, which guided me to using.ifLet(\.route, action: /Action.self) {
to access the non-nil
route:When I tap the button which should present the
FilterFeatureView
in a sheet, I receive the following output:Currently, I am not showing the sheet as I have not yet figured out how to do so with an optional
Route
type in my state.After stepping through with breakpoints, I see the
ifLet
being evaluated before getting toshowFilterFeatureView
where the route is then set. I understand the state isnil
before theFilterFeatureReducer()
is ran, but I don't know what I need to change.Can you help me better understand what I need to change so the state is initialized before the reducer is ran?
Beta Was this translation helpful? Give feedback.
All reactions