Skip to content

Commit

Permalink
Re-adds Reducer.forEach method removed in 1.4 (#2570)
Browse files Browse the repository at this point in the history
* 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 <stephen.celis@gmail.com>
Co-authored-by: Stephen Celis <stephen@stephencelis.com>
  • Loading branch information
3 people authored Nov 15, 2023
1 parent 92150bd commit 2cdbe3f
Showing 1 changed file with 9 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,31 +122,31 @@ extension Reducer {
iOS,
deprecated: 9999,
message:
"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"
"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"
)
@available(
macOS,
deprecated: 9999,
message:
"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"
"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"
)
@available(
tvOS,
deprecated: 9999,
message:
"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"
"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"
)
@available(
watchOS,
deprecated: 9999,
message:
"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"
"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"
)
@inlinable
@warn_unqualified_access
public func forEach<ElementState, ElementAction, ID: Hashable, Element: Reducer>(
_ toElementsState: WritableKeyPath<State, IdentifiedArray<ID, ElementState>>,
action toElementAction: CaseKeyPath<Action, (id: ID, action: ElementAction)>,
action toElementAction: AnyCasePath<Action, (ID, ElementAction)>,
@ReducerBuilder<ElementState, ElementAction> element: () -> Element,
fileID: StaticString = #fileID,
line: UInt = #line
Expand All @@ -155,51 +155,10 @@ extension Reducer {
_ForEachReducer(
parent: self,
toElementsState: toElementsState,
toElementAction: AnyCasePath(toElementAction),
element: element(),
fileID: fileID,
line: line
)
}

@available(
iOS,
deprecated: 9999,
message:
"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"
)
@available(
macOS,
deprecated: 9999,
message:
"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"
)
@available(
tvOS,
deprecated: 9999,
message:
"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"
)
@available(
watchOS,
deprecated: 9999,
message:
"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"
)
@inlinable
@warn_unqualified_access
public func forEach<ElementState, ElementAction, ID: Hashable, Element: Reducer>(
_ toElementsState: WritableKeyPath<State, IdentifiedArray<ID, ElementState>>,
action toElementAction: AnyCasePath<Action, (id: ID, action: ElementAction)>,
@ReducerBuilder<ElementState, ElementAction> element: () -> Element,
fileID: StaticString = #fileID,
line: UInt = #line
) -> _ForEachReducer<Self, ID, Element>
where ElementState == Element.State, ElementAction == Element.Action {
_ForEachReducer(
parent: self,
toElementsState: toElementsState,
toElementAction: toElementAction,
toElementAction: .init(
embed: toElementAction.embed,
extract: toElementAction.extract
),
element: element(),
fileID: fileID,
line: line
Expand Down

0 comments on commit 2cdbe3f

Please sign in to comment.