Replies: 4 comments 17 replies
-
If it's just an oversight, migrators can use this for now: @inlinable
func forEach<Element: ReducerProtocol, Key>(
_ toDictionaryState: WritableKeyPath<State, [Key: Element.State]>,
action toKeyedAction: CasePath<Action, (Key, Element.Action)>,
@ReducerBuilderOf<Element> _ element: @escaping () -> Element,
file: StaticString = #file,
fileID: StaticString = #fileID,
line: UInt = #line
) -> CombineReducers<ReducerBuilder<Self.State, Self.Action>._Sequence<Reduce<Self.State, Self.Action>, Self>> {
CombineReducers {
Reduce { state, action in
AnyReducer {
element()
}
.forEach(
state: toDictionaryState,
action: toKeyedAction,
environment: { _ in },
file: file,
fileID: fileID,
line: line
)
.callAsFunction(&state, action, ())
}
self
}
} |
Beta Was this translation helpful? Give feedback.
-
Thanks for bringing this up @heyltsjay! I think like the other operators, we want to take some time to re-envision the use of this one, which we haven't used ourselves in practice. The main a few things that come to mind:
Does anyone out there have some real world experience using |
Beta Was this translation helpful? Give feedback.
-
Interesting... let me know if you figure out how to reproduce it.
Could probably also do something like: public var data: Data { state.value }
let state: CurrentValueSubject<Data, Never>
Which is understandable :) Looks like it would be a powerful tool. Maybe
Yeah it isn't quite an
Yeah that makes sense. |
Beta Was this translation helpful? Give feedback.
-
Any chance we can try to get this into 1.0? I feel confident that an ordered dictionary is a nice data structure to model state. Leaves shouldn't necessarily have to carry their own ID or be aware of their usage context. |
Beta Was this translation helpful? Give feedback.
-
_ForEachReducer
drops support for dictionary-based collections, which was unexpected and not documented in the migration guide. Should either support or call out the design decision to move away from it.Our app (UIKit) currently models forms using dictionaries, mostly to help coalesce actions that come in:
Beta Was this translation helpful? Give feedback.
All reactions