diff --git a/Examples/CaseStudies/SwiftUICaseStudies/01-GettingStarted-Bindings-Forms.swift b/Examples/CaseStudies/SwiftUICaseStudies/01-GettingStarted-Bindings-Forms.swift index 5a087dcbe1f1..6848600d03c8 100644 --- a/Examples/CaseStudies/SwiftUICaseStudies/01-GettingStarted-Bindings-Forms.swift +++ b/Examples/CaseStudies/SwiftUICaseStudies/01-GettingStarted-Bindings-Forms.swift @@ -28,7 +28,7 @@ struct BindingForm { } var body: some Reducer { - BindingReducer() + BindingReducer(action: \.binding) Reduce { state, action in switch action { case .binding(\.stepCount): diff --git a/Examples/CaseStudies/SwiftUICaseStudies/01-GettingStarted-FocusState.swift b/Examples/CaseStudies/SwiftUICaseStudies/01-GettingStarted-FocusState.swift index 3338701bdb46..6d2d4da536ee 100644 --- a/Examples/CaseStudies/SwiftUICaseStudies/01-GettingStarted-FocusState.swift +++ b/Examples/CaseStudies/SwiftUICaseStudies/01-GettingStarted-FocusState.swift @@ -26,7 +26,7 @@ struct FocusDemo { } var body: some Reducer { - BindingReducer() + BindingReducer(action: \.binding) Reduce { state, action in switch action { case .binding: diff --git a/Examples/CaseStudies/SwiftUICaseStudies/02-SharedState-Onboarding.swift b/Examples/CaseStudies/SwiftUICaseStudies/02-SharedState-Onboarding.swift index a1f7ea5c3c82..b2d10a2b08cd 100644 --- a/Examples/CaseStudies/SwiftUICaseStudies/02-SharedState-Onboarding.swift +++ b/Examples/CaseStudies/SwiftUICaseStudies/02-SharedState-Onboarding.swift @@ -110,7 +110,7 @@ private struct BasicsFeature { case binding(BindingAction) } var body: some ReducerOf { - BindingReducer() + BindingReducer(action: \.binding) } } @@ -161,7 +161,7 @@ private struct PersonalInfoFeature { } @Dependency(\.dismiss) var dismiss var body: some ReducerOf { - BindingReducer() + BindingReducer(action: \.binding) } } @@ -217,7 +217,7 @@ private struct TopicsFeature { } @Dependency(\.dismiss) var dismiss var body: some ReducerOf { - BindingReducer() + BindingReducer(action: \.binding) Reduce { state, action in switch action { case .alert: diff --git a/Examples/Integration/Integration/Legacy/BindingLocalTestCase.swift b/Examples/Integration/Integration/Legacy/BindingLocalTestCase.swift index b23deaf8dcd0..e9cc53402281 100644 --- a/Examples/Integration/Integration/Legacy/BindingLocalTestCase.swift +++ b/Examples/Integration/Integration/Legacy/BindingLocalTestCase.swift @@ -77,7 +77,7 @@ private struct Child { case onDisappear } var body: some ReducerOf { - BindingReducer() + BindingReducer(action: \.binding) } } diff --git a/Examples/Integration/Integration/Legacy/LegacyPresentationTestCase.swift b/Examples/Integration/Integration/Legacy/LegacyPresentationTestCase.swift index 8f6db19c39a0..eb75abbced63 100644 --- a/Examples/Integration/Integration/Legacy/LegacyPresentationTestCase.swift +++ b/Examples/Integration/Integration/Legacy/LegacyPresentationTestCase.swift @@ -224,7 +224,7 @@ private enum PresentationTestCase { } @Dependency(\.dismiss) var dismiss var body: some ReducerOf { - BindingReducer() + BindingReducer(action: \.binding) Reduce { state, action in switch action { case .binding: diff --git a/Examples/Integration/Integration/iOS 17/ObservableBindingLocalTest.swift b/Examples/Integration/Integration/iOS 17/ObservableBindingLocalTest.swift index 5683925701cd..a69c02a56ad7 100644 --- a/Examples/Integration/Integration/iOS 17/ObservableBindingLocalTest.swift +++ b/Examples/Integration/Integration/iOS 17/ObservableBindingLocalTest.swift @@ -79,7 +79,7 @@ private struct Child { case onDisappear } var body: some ReducerOf { - BindingReducer() + BindingReducer(action: \.binding) } } diff --git a/Examples/Integration/Integration/iOS 17/ObservableSharedStateTestCase.swift b/Examples/Integration/Integration/iOS 17/ObservableSharedStateTestCase.swift index e4f3a1f27b44..9cf7227572ca 100644 --- a/Examples/Integration/Integration/iOS 17/ObservableSharedStateTestCase.swift +++ b/Examples/Integration/Integration/iOS 17/ObservableSharedStateTestCase.swift @@ -98,10 +98,10 @@ private struct Feature { } @Dependency(\.defaultAppStorage) var defaults var body: some ReducerOf { - BindingReducer() + BindingReducer(action: \.binding) Reduce { state, action in switch action { - case .binding(_): + case .binding: return .none case .deleteFileButtonTapped: return .run { _ in diff --git a/Examples/SyncUps/SyncUps/SyncUpForm.swift b/Examples/SyncUps/SyncUps/SyncUpForm.swift index 4e5e25e8d2ab..7a21c3035332 100644 --- a/Examples/SyncUps/SyncUps/SyncUpForm.swift +++ b/Examples/SyncUps/SyncUps/SyncUpForm.swift @@ -33,7 +33,7 @@ struct SyncUpForm { @Dependency(\.uuid) var uuid var body: some ReducerOf { - BindingReducer() + BindingReducer(action: \.binding) Reduce { state, action in switch action { case .addAttendeeButtonTapped: diff --git a/Examples/TicTacToe/tic-tac-toe/Sources/LoginCore/LoginCore.swift b/Examples/TicTacToe/tic-tac-toe/Sources/LoginCore/LoginCore.swift index 87223b7dcd76..7331ec321464 100644 --- a/Examples/TicTacToe/tic-tac-toe/Sources/LoginCore/LoginCore.swift +++ b/Examples/TicTacToe/tic-tac-toe/Sources/LoginCore/LoginCore.swift @@ -37,7 +37,7 @@ public struct Login: Sendable { public init() {} public var body: some Reducer { - BindingReducer(action: \.view) + BindingReducer(action: \.view.binding) Reduce { state, action in switch action { case .alert: diff --git a/Examples/TicTacToe/tic-tac-toe/Sources/NewGameCore/NewGameCore.swift b/Examples/TicTacToe/tic-tac-toe/Sources/NewGameCore/NewGameCore.swift index a82b5a3a1ae1..5b0f4d9d98ad 100644 --- a/Examples/TicTacToe/tic-tac-toe/Sources/NewGameCore/NewGameCore.swift +++ b/Examples/TicTacToe/tic-tac-toe/Sources/NewGameCore/NewGameCore.swift @@ -22,7 +22,7 @@ public struct NewGame { public init() {} public var body: some Reducer { - BindingReducer() + BindingReducer(action: \.binding) Reduce { state, action in switch action { case .binding: diff --git a/Examples/TicTacToe/tic-tac-toe/Sources/TwoFactorCore/TwoFactorCore.swift b/Examples/TicTacToe/tic-tac-toe/Sources/TwoFactorCore/TwoFactorCore.swift index bc2586da0ceb..db82c657de98 100644 --- a/Examples/TicTacToe/tic-tac-toe/Sources/TwoFactorCore/TwoFactorCore.swift +++ b/Examples/TicTacToe/tic-tac-toe/Sources/TwoFactorCore/TwoFactorCore.swift @@ -37,7 +37,7 @@ public struct TwoFactor: Sendable { public init() {} public var body: some ReducerOf { - BindingReducer(action: \.view) + BindingReducer(action: \.view.binding) Reduce { state, action in switch action { case .alert: diff --git a/Examples/Todos/Todos/Todo.swift b/Examples/Todos/Todos/Todo.swift index fdebac6a49ca..6c79ff9d6304 100644 --- a/Examples/Todos/Todos/Todo.swift +++ b/Examples/Todos/Todos/Todo.swift @@ -15,7 +15,7 @@ struct Todo { } var body: some Reducer { - BindingReducer() + BindingReducer(action: \.binding) } } diff --git a/Examples/Todos/Todos/Todos.swift b/Examples/Todos/Todos/Todos.swift index 9bf81e5dbe83..1a1a7d5ebf7d 100644 --- a/Examples/Todos/Todos/Todos.swift +++ b/Examples/Todos/Todos/Todos.swift @@ -39,7 +39,7 @@ struct Todos { private enum CancelID { case todoCompletion } var body: some Reducer { - BindingReducer() + BindingReducer(action: \.binding) Reduce { state, action in switch action { case .addTodoButtonTapped: diff --git a/Sources/ComposableArchitecture/Documentation.docc/Articles/Bindings.md b/Sources/ComposableArchitecture/Documentation.docc/Articles/Bindings.md index 6bea25c8306d..ca6cb69a3a83 100644 --- a/Sources/ComposableArchitecture/Documentation.docc/Articles/Bindings.md +++ b/Sources/ComposableArchitecture/Documentation.docc/Articles/Bindings.md @@ -223,7 +223,7 @@ struct Settings { enum Action: BindableAction { /* ... */ } var body: some Reducer { - BindingReducer() + BindingReducer(action: \.binding) } } ``` @@ -252,7 +252,7 @@ action for a given key path in the reducer: ```swift var body: some Reducer { - BindingReducer() + BindingReducer(action: \.binding) Reduce { state, action in switch action @@ -273,7 +273,7 @@ particular fields: ```swift var body: some Reducer { - BindingReducer() + BindingReducer(action: \.binding) .onChange(of: \.displayName) { oldValue, newValue in // Validate display name } diff --git a/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/SyncUpForm-01-code-0004.swift b/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/SyncUpForm-01-code-0004.swift index 4a36bb65ba73..7b9bebefe7b5 100644 --- a/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/SyncUpForm-01-code-0004.swift +++ b/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/SyncUpForm-01-code-0004.swift @@ -13,7 +13,7 @@ struct SyncUpForm { } var body: some ReducerOf { - BindingReducer() + BindingReducer(action: \.binding) Reduce { state, action in switch action { diff --git a/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/SyncUpForm-01-code-0005.swift b/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/SyncUpForm-01-code-0005.swift index 4ea3c7d02179..ba076e4bcaa6 100644 --- a/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/SyncUpForm-01-code-0005.swift +++ b/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/SyncUpForm-01-code-0005.swift @@ -14,7 +14,7 @@ struct SyncUpForm { } var body: some ReducerOf { - BindingReducer() + BindingReducer(action: \.binding) Reduce { state, action in switch action { diff --git a/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/SyncUpForm-01-code-0006.swift b/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/SyncUpForm-01-code-0006.swift index 62110462a50c..035bc8902927 100644 --- a/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/SyncUpForm-01-code-0006.swift +++ b/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/SyncUpForm-01-code-0006.swift @@ -15,7 +15,7 @@ struct SyncUpForm { } var body: some ReducerOf { - BindingReducer() + BindingReducer(action: \.binding) Reduce { state, action in switch action { diff --git a/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/SyncUpForm-03-code-0001-previous.swift b/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/SyncUpForm-03-code-0001-previous.swift index d4caec89a14c..bab0fee9bbdf 100644 --- a/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/SyncUpForm-03-code-0001-previous.swift +++ b/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/SyncUpForm-03-code-0001-previous.swift @@ -15,7 +15,7 @@ struct SyncUpForm { } var body: some ReducerOf { - BindingReducer() + BindingReducer(action: \.binding) Reduce { state, action in switch action { diff --git a/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/SyncUpForm-03-code-0001.swift b/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/SyncUpForm-03-code-0001.swift index 633e5cb21be2..8ab4274d142f 100644 --- a/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/SyncUpForm-03-code-0001.swift +++ b/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/SyncUpForm-03-code-0001.swift @@ -21,7 +21,7 @@ struct SyncUpForm { } var body: some ReducerOf { - BindingReducer() + BindingReducer(action: \.binding) Reduce { state, action in switch action { diff --git a/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/SyncUpForm-03-code-0002.swift b/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/SyncUpForm-03-code-0002.swift index f411c1ab9498..7c401862df40 100644 --- a/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/SyncUpForm-03-code-0002.swift +++ b/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/SyncUpForm-03-code-0002.swift @@ -21,7 +21,7 @@ struct SyncUpForm { } var body: some ReducerOf { - BindingReducer() + BindingReducer(action: \.binding) Reduce { state, action in switch action { diff --git a/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/SyncUpForm-03-code-0003.swift b/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/SyncUpForm-03-code-0003.swift index 0c04bb9d8d6c..f068aa02a527 100644 --- a/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/SyncUpForm-03-code-0003.swift +++ b/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/SyncUpForm-03-code-0003.swift @@ -21,7 +21,7 @@ struct SyncUpForm { } var body: some ReducerOf { - BindingReducer() + BindingReducer(action: \.binding) Reduce { state, action in switch action { diff --git a/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/TestingSyncUpForm-02-code-0004-previous.swift b/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/TestingSyncUpForm-02-code-0004-previous.swift index 0c04bb9d8d6c..f068aa02a527 100644 --- a/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/TestingSyncUpForm-02-code-0004-previous.swift +++ b/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/TestingSyncUpForm-02-code-0004-previous.swift @@ -21,7 +21,7 @@ struct SyncUpForm { } var body: some ReducerOf { - BindingReducer() + BindingReducer(action: \.binding) Reduce { state, action in switch action { diff --git a/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/TestingSyncUpForm-02-code-0004.swift b/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/TestingSyncUpForm-02-code-0004.swift index 6d0175a9f05e..d7122addaac2 100644 --- a/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/TestingSyncUpForm-02-code-0004.swift +++ b/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/TestingSyncUpForm-02-code-0004.swift @@ -23,7 +23,7 @@ struct SyncUpForm { @Dependency(\.uuid) var uuid var body: some ReducerOf { - BindingReducer() + BindingReducer(action: \.binding) Reduce { state, action in switch action { diff --git a/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/TestingSyncUpForm-02-code-0005.swift b/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/TestingSyncUpForm-02-code-0005.swift index 530779b4cb60..6d51b4482527 100644 --- a/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/TestingSyncUpForm-02-code-0005.swift +++ b/Sources/ComposableArchitecture/Documentation.docc/Tutorials/BuildingSyncUps/03-SyncUpForm/TestingSyncUpForm-02-code-0005.swift @@ -23,7 +23,7 @@ struct SyncUpForm { @Dependency(\.uuid) var uuid var body: some ReducerOf { - BindingReducer() + BindingReducer(action: \.binding) Reduce { state, action in switch action { diff --git a/Sources/ComposableArchitecture/Reducer/Reducers/BindingReducer.swift b/Sources/ComposableArchitecture/Reducer/Reducers/BindingReducer.swift index 23b60a75a377..a827f590ddf5 100644 --- a/Sources/ComposableArchitecture/Reducer/Reducers/BindingReducer.swift +++ b/Sources/ComposableArchitecture/Reducer/Reducers/BindingReducer.swift @@ -18,7 +18,7 @@ import SwiftUI /// } /// /// var body: some ReducerOf { -/// BindingReducer() +/// BindingReducer(action: \.binding) /// Reduce { state, action in /// // Your feature's logic... /// } @@ -35,47 +35,81 @@ import SwiftUI /// Reduce { state, action in /// // Your feature's logic... /// } -/// BindingReducer() +/// BindingReducer(action: \.binding) /// } /// ``` /// /// If you forget to compose the ``BindingReducer`` into your feature's reducer, then when a binding /// is written to it will cause a runtime purple Xcode warning letting you know what needs to be /// fixed. -public struct BindingReducer: Reducer -where State == ViewAction.State { +public struct BindingReducer: Reducer { @usableFromInline - let toViewAction: (Action) -> ViewAction? + let toBindingAction: (Action) -> BindingAction? + + @usableFromInline + init(internal toBindingAction: @escaping (Action) -> BindingAction?) { + self.toBindingAction = toBindingAction + } /// Initializes a reducer that updates bindable state when it receives binding actions. + /// + /// - Parameter toBindingAction: A case key path to the binding action case. @inlinable - public init() where Action == ViewAction { - self.init(internal: { $0 }) + public init(action toBindingAction: CaseKeyPath>) { + self.init(internal: AnyCasePath(toBindingAction).extract(from:)) } @inlinable - public init(action toViewAction: CaseKeyPath) where Action: CasePathable { - self.init(internal: { $0[case: toViewAction] }) + public func reduce(into state: inout State, action: Action) -> Effect { + guard let bindingAction = toBindingAction(action) + else { return .none } + + bindingAction.set(&state) + return .none } +} +@available( + iOS, deprecated: 9999, + message: "Pass an explicit case key path, for example: 'BindingReducer(action: \\.binding)'" +) +@available( + macOS, deprecated: 9999, + message: "Pass an explicit case key path, for example: 'BindingReducer(action: \\.binding)'" +) +@available( + tvOS, deprecated: 9999, + message: "Pass an explicit case key path, for example: 'BindingReducer(action: \\.binding)'" +) +@available( + watchOS, deprecated: 9999, + message: "Pass an explicit case key path, for example: 'BindingReducer(action: \\.binding)'" +) +extension BindingReducer { @inlinable - public init(action toViewAction: @escaping (_ action: Action) -> ViewAction?) { - self.init(internal: toViewAction) + public init() where Action: BindableAction { + self.init(internal: AnyCasePath(unsafe: { .binding($0) }).extract(from:)) } - @usableFromInline - init(internal toViewAction: @escaping (_ action: Action) -> ViewAction?) { - self.toViewAction = toViewAction + @_disfavoredOverload + @inlinable + public init>( + action toViewAction: CaseKeyPath + ) { + self.init( + internal: AnyCasePath(toViewAction) + .appending(path: AnyCasePath(unsafe: { .binding($0) })) + .extract(from:) + ) } + @_disfavoredOverload @inlinable - public func reduce(into state: inout State, action: Action) -> Effect { - // NB: Using a closure and not a `\.binding` key path literal to avoid a bug with archives: - // https://github.com/pointfreeco/swift-composable-architecture/pull/2641 - guard let bindingAction = self.toViewAction(action).flatMap({ $0.binding }) - else { return .none } - - bindingAction.set(&state) - return .none + public init>( + action toViewAction: @escaping (_ action: Action) -> ViewAction? + ) { + let toBindingAction = AnyCasePath>(unsafe: { .binding($0) }) + .extract(from:) + self.init(internal: { toViewAction($0).flatMap(toBindingAction) }) } } diff --git a/Sources/ComposableArchitecture/Reducer/Reducers/OnChange.swift b/Sources/ComposableArchitecture/Reducer/Reducers/OnChange.swift index ff43e6f284df..deb841cc574b 100644 --- a/Sources/ComposableArchitecture/Reducer/Reducers/OnChange.swift +++ b/Sources/ComposableArchitecture/Reducer/Reducers/OnChange.swift @@ -18,7 +18,7 @@ extension Reducer { /// } /// /// var body: some Reducer { - /// BindingReducer() + /// BindingReducer(action: \.binding) /// .onChange( /// of: { ($0.userSettings.isHapticFeedbackEnabled, $0.userSettings.isPushEnabled) }, /// removeDuplicates: == @@ -83,7 +83,7 @@ extension Reducer { /// } /// /// var body: some Reducer { - /// BindingReducer() + /// BindingReducer(action: \.binding) /// .onChange(of: \.userSettings.isHapticFeedbackEnabled) { oldValue, newValue in /// Reduce { state, action in /// .run { send in diff --git a/Sources/ComposableArchitecture/SwiftUI/Binding.swift b/Sources/ComposableArchitecture/SwiftUI/Binding.swift index 7ba0451f4769..98e592890c90 100644 --- a/Sources/ComposableArchitecture/SwiftUI/Binding.swift +++ b/Sources/ComposableArchitecture/SwiftUI/Binding.swift @@ -274,15 +274,6 @@ public protocol BindableAction { /// /// - Returns: A binding action. static func binding(_ action: BindingAction) -> Self - - /// Extracts a binding action from this action type. - var binding: BindingAction? { get } -} - -extension BindableAction { - public var binding: BindingAction? { - AnyCasePath(unsafe: { .binding($0) }).extract(from: self) - } } extension BindableAction { @@ -799,7 +790,8 @@ extension WithViewStore where ViewState: Equatable, Content: View { Action: \(typeName(self.bindableActionType)).binding(.set(_, \(value))) - To fix this, invoke "BindingReducer()" from your feature reducer's "body". + To fix this, invoke "BindingReducer(action: \\.binding)" from your feature reducer's \ + "body". """, fileID: fileID, filePath: filePath, diff --git a/Tests/ComposableArchitectureTests/Reducers/BindingReducerTests.swift b/Tests/ComposableArchitectureTests/Reducers/BindingReducerTests.swift index 77f1722074b4..e0f3c8b33756 100644 --- a/Tests/ComposableArchitectureTests/Reducers/BindingReducerTests.swift +++ b/Tests/ComposableArchitectureTests/Reducers/BindingReducerTests.swift @@ -17,7 +17,7 @@ final class BindingTests: BaseTCATestCase { } var body: some ReducerOf { - BindingReducer() + BindingReducer(action: \.binding) Reduce { state, action in switch action { case .binding(.set(\.$nested, State.Nested(field: "special"))): diff --git a/Tests/ComposableArchitectureTests/RuntimeWarningTests.swift b/Tests/ComposableArchitectureTests/RuntimeWarningTests.swift index 3890ad5fe69d..dbae86f43453 100644 --- a/Tests/ComposableArchitectureTests/RuntimeWarningTests.swift +++ b/Tests/ComposableArchitectureTests/RuntimeWarningTests.swift @@ -25,7 +25,8 @@ Action: RuntimeWarningTests.Action.binding(.set(_, 42)) - To fix this, invoke "BindingReducer()" from your feature reducer's "body". + To fix this, invoke "BindingReducer(action: \\.binding)" from your feature reducer's \ + "body". """ } } @@ -51,7 +52,8 @@ Action: RuntimeWarningTests.Action.binding(.set(_, 42)) - To fix this, invoke "BindingReducer()" from your feature reducer's "body". + To fix this, invoke "BindingReducer(action: \\.binding)" from your feature reducer's \ + "body". """ } } diff --git a/Tests/ComposableArchitectureTests/TestStoreTests.swift b/Tests/ComposableArchitectureTests/TestStoreTests.swift index 78cc900fb268..a55ec45166e1 100644 --- a/Tests/ComposableArchitectureTests/TestStoreTests.swift +++ b/Tests/ComposableArchitectureTests/TestStoreTests.swift @@ -695,7 +695,7 @@ struct SameNameForStateAndAction { case isOn(Bool) } var body: some ReducerOf { - BindingReducer() + BindingReducer(action: \.binding) Reduce { state, action in switch action { case .binding: