Skip to content

Add back ReducerProtocolOf for 5.7.1 #1444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion Sources/ComposableArchitecture/ReducerProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
///
/// Implement this requirement for "primitive" reducers, or reducers that work on leaf node
/// features. To define a reducer by combining the logic of other reducers together, implement
/// the ``body-swift.property-7foai`` requirement instead.
/// the ``body-swift.property-97ymy`` requirement instead.
///
/// - Parameters:
/// - state: The current state of the reducer.
Expand Down Expand Up @@ -346,3 +346,27 @@ extension ReducerProtocol where Body: ReducerProtocol, Body.State == State, Body
self.body.reduce(into: &state, action: action)
}
}

// NB: This is available only in Swift 5.7.1 due to the following bug:
// https://github.com/apple/swift/issues/60550
#if swift(>=5.7.1)
/// A convenience for constraining a ``ReducerProtocol`` conformance. Available only in Swift
/// 5.7.1.
///
/// This allows you to specify the `body` of a ``ReducerProtocol`` conformance like so:
///
/// ```swift
/// var body: some ReducerProtocolOf<Self> {
/// // ...
/// }
/// ```
///
/// …instead of the more verbose:
///
/// ```swift
/// var body: some ReducerProtocol<State, Action> {
/// // ...
/// }
/// ```
public typealias ReducerProtocolOf<R: ReducerProtocol> = ReducerProtocol<R.State, R.Action>
#endif