-
I created a toy project that manages color palettes using the new @Reducer
public struct PaletteEditor: Reducer {
public struct State: Equatable {
public var colors: IdentifiedArrayOf<PaletteColor.State>
}
public enum Action {
case colors(IdentifiedActionOf<PaletteColor>)
}
public var body: some Reducer<State, Action> {
Reduce { state, action in
switch action {
case .colors:
return .none
}
}
.forEach(\.colors, action: \.colors) {
PaletteColor()
}
}
}
@Reducer
public struct PaletteColor {
public struct State: Equatable, Identifiable {
public var color: RGB
public var id: ID
public init(color: RGB, id: UUID? = nil) {
self.color = color
self.id = {
if let id { return Tagged(id) }
@Dependency(\.uuid) var uuid
return Tagged(uuid())
}()
}
public typealias ID = Tagged<Self, UUID>
}
public enum Action {}
public var body: some Reducer<State, Action> {
EmptyReducer()
}
} Then in the view for the palette, I get an error at the action keyPath: "Reference to member public struct PaletteEditorView: View {
let store: StoreOf<PaletteEditor>
public var body: some View {
ForEachStore(store.scope(state: \.colors, action: \.colors)) { colorStore in
// ^ Error
PaletteColorView(store: colorStore)
}
}
} I tried fully qualifying the keyPath (perhaps wrongly) with |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hi @seanmrich, the tools you are wanting to use are not released in 1.4. They are still in beta, which you can find the details here. If you want to try it out you will need to point your dependency on TCA to the branch |
Beta Was this translation helpful? Give feedback.
-
Well, that would explain it 🤦♂️. Separately, if I turn on strict concurrency I get a warning about the action key path in I tried setting both |
Beta Was this translation helpful? Give feedback.
That is a known issue in the swift compiler and it should be fixed very soon. You will have to ignore that warning for now.