Replies: 3 comments 1 reply
-
I suspect this is because, by nesting your identified array inside your own |
Beta Was this translation helpful? Give feedback.
-
Annotating RemoteResult with |
Beta Was this translation helpful? Give feedback.
-
Hi @kuglee, the reason syntax like this works: ForEach(store.scope(…)) { store in
…
} …is because we have a special overload of Really this is a domain modeling problem. You shouldn't compose features together like this: public var childStates: RemoteResult<IdentifiedArrayOf<ChildFeature.State>, AppError> Not only is public var result: RemoteResult<ChildrenFeature.State, AppError> And then have a dedicated if let store = self.store.scope(state: \.result.success, action: \.result) {
ForEach(store.scope(state: \.children, action: \.children)) { store in
…
}
} Since this is not an issue with the library I am going to convert it to a discussion. Please feel free to continue the conversation over there. |
Beta Was this translation helpful? Give feedback.
-
Description
I'd like to use ForEach with an optional state. In this example I'm using a type RemoteResult. RemoteResult is annotated with @CasePathable and @dynamicMemberLookup.
The reducer seem to compile fine, but in the view I have the following error: Generic struct 'ForEach' requires that 'Store<IdentifiedArray<UUID, ChildFeature.State>, IdentifiedAction<UUID, ChildFeature.Action>>' conform to 'RandomAccessCollection'
Checklist
main
branch of this package.Expected behavior
In the AppView I expected that after if let scoping the store I can pass it to ForEach:
Actual behavior
In the AppView I get the following error:
Generic struct 'ForEach' requires that 'Store<IdentifiedArray<UUID, ChildFeature.State>, IdentifiedAction<UUID, ChildFeature.Action>>' conform to 'RandomAccessCollection'
Steps to reproduce
Here's the demo project the example code is from: [TCACasePathIssue](https://github.com/kuglee/TCACasePathIssue)
Here's a simpler demo project with an if let ForEach that also has this issue: TCAForEachIssue
The Composable Architecture version information
1.14.0
Destination operating system
macOS
Xcode version information
Xcode 16.1 beta (16B5001e)
Swift Compiler version information
Beta Was this translation helpful? Give feedback.
All reactions