Replies: 2 comments
-
This is similar to #1296 but here, the enum value is nullable. Also that discussion looks stale and not sure if 1.7 introduced any updated syntax. |
Beta Was this translation helpful? Give feedback.
0 replies
-
The solution I found is pretty clunky: struct State {
var result: Result?
@CasePathable
@dynamicMemberLookup
enum Result { // Have to re-define Result to use @dynamicMemberLookup
case success(Child.State)
case failure(Error)
}
}
var body {
Reduce {}
.ifLet(\.result, action: \.action) {
Scope(state: \.success, action: \.self) {
Child()
}
} Then in the view layer: if let store1 = store.scope(state: \.result, action: \.action) {
self.cancellable = store1.scope(state: \.success, action: \.self).ifLet { store in
ChildView(store: store)
}
} |
Beta Was this translation helpful? Give feedback.
0 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.
Uh oh!
There was an error while loading. Please reload this page.
-
Having some trouble understanding CasePath/KeyPath syntax.
Take the following where a child is based on some result:
This works, but I actually want it to be modeled like:
I can't figure out how to scope the child correctly and can't find any examples like this where a nested enum value is optional. Any help would be appreciated!
Beta Was this translation helpful? Give feedback.
All reactions