Ordering of Scope(s) and Reduce in ReducerProtocol body #1761
-
Just starting on migration our project to Should we do this: var body: some ReducerProtocol {
Scope(state: \.child1, action: /Action.child1) {
Child1()
}
Scope(state: \.child2, action: /Action.child2) {
Child2()
}
Reduce { state, action in
// parent reducer switch
}
} or this: var body: some ReducerProtocol {
Reduce { state, action in
// parent reducer switch
}
Scope(state: \.child1, action: /Action.child1) {
Child1()
}
Scope(state: \.child2, action: /Action.child2) {
Child2()
}
} The documentation has examples of both, although the documentation for Related to this question, we use the My question is, with the following code: var body: some ReducerProtocol {
Scope(state: \.child1, action: /Action.child1) {
Child1()
}
Scope(state: \.child2, action: /Action.child2) {
Child2()
}
Reduce { state, action in
// parent reducer switch
}
.onChange(of: \.child1.foo) { ... }
} will the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 10 replies
-
I have now tested it and can confirm that |
Beta Was this translation helpful? Give feedback.
I have now tested it and can confirm that
onChange
is only detecting changes made in theReduce
to which it is attached, not any changes made in theChild1()
reducer.