Cancellable issue with children #2889
Unanswered
arnauddorgans
asked this question in
Q&A
Replies: 1 comment 2 replies
-
Hi @arnauddorgans. You are reusing the exact same cancel ID for effects, which are both created and executed in the parent feature using You can make the cancel IDs unique to fix things: @Reducer
struct ChildFeature {
…
- enum CancelID {
- case fetch
+ enum CancelID: Hashable {
+ case fetch(UUID)
}
+
+ let id = UUID()
var body: some Reducer<State, Action> {
Reduce { state, action in
switch action {
case .fetch:
state.isLoading = true
return .run { send in
…
}
- .cancellable(id: CancelID.fetch, cancelInFlight: true)
+ .cancellable(id: CancelID.fetch(self.id), cancelInFlight: true)
…
}
}
} But I would suggest moving the |
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
-
Description
I have an issue when a parent feature contains two child features with a cancellable effect.
The cancellable effect with ID is propagated between the two child features.
I made a simple app to reproduce the issue. It may be a feature, but it seems strange that a child feature can impact neighbors.
I expect both children to complete their tasks instead of canceling the other.
Checklist
main
branch of this package.Expected behavior
Both child features are loaded
Actual behavior
One child feature is cancelled
Steps to reproduce
The Composable Architecture version information
1.9.2
Destination operating system
iOS 17
Xcode version information
Xcode 15.2
Swift Compiler version information
Beta Was this translation helpful? Give feedback.
All reactions