Skip to content

Commit 2cdbe3f

Browse files
Re-adds Reducer.forEach method removed in 1.4 (#2570)
* Re-adds an initialiser that was removed in 1.4 * Update ForEachReducer.swift Only have two overloads: - `CaseKeyPath` to an `IdentifiedAction` - Deprecated `AnyCasePath` to an unnamed tuple * Update ForEachReducer.swift --------- Co-authored-by: Stephen Celis <[email protected]> Co-authored-by: Stephen Celis <[email protected]>
1 parent 92150bd commit 2cdbe3f

File tree

1 file changed

+9
-50
lines changed

1 file changed

+9
-50
lines changed

Sources/ComposableArchitecture/Reducer/Reducers/ForEachReducer.swift

Lines changed: 9 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -122,31 +122,31 @@ extension Reducer {
122122
iOS,
123123
deprecated: 9999,
124124
message:
125-
"Use an 'IdentifiedAction', instead. See the following migration guide for more information:\n\nhttps://pointfreeco.github.io/swift-composable-architecture/main/documentation/composablearchitecture/Migratingto14#Identified-actions"
125+
"Use a case key path to an 'IdentifiedAction', instead. See the following migration guide for more information:\n\nhttps://pointfreeco.github.io/swift-composable-architecture/main/documentation/composablearchitecture/migratingto1.4"
126126
)
127127
@available(
128128
macOS,
129129
deprecated: 9999,
130130
message:
131-
"Use an 'IdentifiedAction', instead. See the following migration guide for more information:\n\nhttps://pointfreeco.github.io/swift-composable-architecture/main/documentation/composablearchitecture/Migratingto14#Identified-actions"
131+
"Use a case key path to an 'IdentifiedAction', instead. See the following migration guide for more information:\n\nhttps://pointfreeco.github.io/swift-composable-architecture/main/documentation/composablearchitecture/migratingto1.4"
132132
)
133133
@available(
134134
tvOS,
135135
deprecated: 9999,
136136
message:
137-
"Use an 'IdentifiedAction', instead. See the following migration guide for more information:\n\nhttps://pointfreeco.github.io/swift-composable-architecture/main/documentation/composablearchitecture/Migratingto14#Identified-actions"
137+
"Use a case key path to an 'IdentifiedAction', instead. See the following migration guide for more information:\n\nhttps://pointfreeco.github.io/swift-composable-architecture/main/documentation/composablearchitecture/migratingto1.4"
138138
)
139139
@available(
140140
watchOS,
141141
deprecated: 9999,
142142
message:
143-
"Use an 'IdentifiedAction', instead. See the following migration guide for more information:\n\nhttps://pointfreeco.github.io/swift-composable-architecture/main/documentation/composablearchitecture/Migratingto14#Identified-actions"
143+
"Use a case key path to an 'IdentifiedAction', instead. See the following migration guide for more information:\n\nhttps://pointfreeco.github.io/swift-composable-architecture/main/documentation/composablearchitecture/migratingto1.4"
144144
)
145145
@inlinable
146146
@warn_unqualified_access
147147
public func forEach<ElementState, ElementAction, ID: Hashable, Element: Reducer>(
148148
_ toElementsState: WritableKeyPath<State, IdentifiedArray<ID, ElementState>>,
149-
action toElementAction: CaseKeyPath<Action, (id: ID, action: ElementAction)>,
149+
action toElementAction: AnyCasePath<Action, (ID, ElementAction)>,
150150
@ReducerBuilder<ElementState, ElementAction> element: () -> Element,
151151
fileID: StaticString = #fileID,
152152
line: UInt = #line
@@ -155,51 +155,10 @@ extension Reducer {
155155
_ForEachReducer(
156156
parent: self,
157157
toElementsState: toElementsState,
158-
toElementAction: AnyCasePath(toElementAction),
159-
element: element(),
160-
fileID: fileID,
161-
line: line
162-
)
163-
}
164-
165-
@available(
166-
iOS,
167-
deprecated: 9999,
168-
message:
169-
"Use an 'IdentifiedAction', instead. See the following migration guide for more information:\n\nhttps://pointfreeco.github.io/swift-composable-architecture/main/documentation/composablearchitecture/Migratingto14#Identified-actions"
170-
)
171-
@available(
172-
macOS,
173-
deprecated: 9999,
174-
message:
175-
"Use an 'IdentifiedAction', instead. See the following migration guide for more information:\n\nhttps://pointfreeco.github.io/swift-composable-architecture/main/documentation/composablearchitecture/Migratingto14#Identified-actions"
176-
)
177-
@available(
178-
tvOS,
179-
deprecated: 9999,
180-
message:
181-
"Use an 'IdentifiedAction', instead. See the following migration guide for more information:\n\nhttps://pointfreeco.github.io/swift-composable-architecture/main/documentation/composablearchitecture/Migratingto14#Identified-actions"
182-
)
183-
@available(
184-
watchOS,
185-
deprecated: 9999,
186-
message:
187-
"Use an 'IdentifiedAction', instead. See the following migration guide for more information:\n\nhttps://pointfreeco.github.io/swift-composable-architecture/main/documentation/composablearchitecture/Migratingto14#Identified-actions"
188-
)
189-
@inlinable
190-
@warn_unqualified_access
191-
public func forEach<ElementState, ElementAction, ID: Hashable, Element: Reducer>(
192-
_ toElementsState: WritableKeyPath<State, IdentifiedArray<ID, ElementState>>,
193-
action toElementAction: AnyCasePath<Action, (id: ID, action: ElementAction)>,
194-
@ReducerBuilder<ElementState, ElementAction> element: () -> Element,
195-
fileID: StaticString = #fileID,
196-
line: UInt = #line
197-
) -> _ForEachReducer<Self, ID, Element>
198-
where ElementState == Element.State, ElementAction == Element.Action {
199-
_ForEachReducer(
200-
parent: self,
201-
toElementsState: toElementsState,
202-
toElementAction: toElementAction,
158+
toElementAction: .init(
159+
embed: toElementAction.embed,
160+
extract: toElementAction.extract
161+
),
203162
element: element(),
204163
fileID: fileID,
205164
line: line

0 commit comments

Comments
 (0)