diff --git a/Sources/ComposableArchitecture/Documentation.docc/Articles/Bindings.md b/Sources/ComposableArchitecture/Documentation.docc/Articles/Bindings.md index 0f2eb0604f92..e704c0e9beb0 100644 --- a/Sources/ComposableArchitecture/Documentation.docc/Articles/Bindings.md +++ b/Sources/ComposableArchitecture/Documentation.docc/Articles/Bindings.md @@ -277,16 +277,16 @@ store.send(.set(\.$protectMyPosts, true)) { ``` > Tip: If you use `@BindingState` on a larger struct and would like to observe changes to smaller -> fields, apply the ``ReducerProtocol/onChange(of:_:)`` modifier to the ``BindingReducer``: +> fields, apply the ``Reducer/onChange(of:_:)`` modifier to the ``BindingReducer``: > > ```swift -> struct Settings: ReducerProtocol { +> struct Settings: Reducer { > struct State { > @BindingState var developerSettings: DeveloperSettings > // ... > } > // ... -> var body: some ReducerProtocol { +> var body: some Reducer { > BindingReducer() > .onChange(of: \.developerSettings.showDiagnostics) { oldValue, newValue in > // Logic for when `showDiagnostics` changes... diff --git a/Sources/ComposableArchitecture/Effect.swift b/Sources/ComposableArchitecture/Effect.swift index 937aacbf585a..93e887183fad 100644 --- a/Sources/ComposableArchitecture/Effect.swift +++ b/Sources/ComposableArchitecture/Effect.swift @@ -82,7 +82,7 @@ public struct EffectPublisher { /// ```swift /// let effect: EffectOf /// ``` -public typealias EffectOf = EffectPublisher +public typealias EffectOf = EffectPublisher // MARK: - Creating Effects diff --git a/Sources/ComposableArchitecture/Reducer/Reducers/BindingReducer.swift b/Sources/ComposableArchitecture/Reducer/Reducers/BindingReducer.swift index 608edc152b72..5e39164a3d5d 100644 --- a/Sources/ComposableArchitecture/Reducer/Reducers/BindingReducer.swift +++ b/Sources/ComposableArchitecture/Reducer/Reducers/BindingReducer.swift @@ -41,7 +41,7 @@ import SwiftUI /// 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: ReducerProtocol +public struct BindingReducer: Reducer where State == ViewAction.State { @usableFromInline let toViewAction: (Action) -> ViewAction? diff --git a/Sources/ComposableArchitecture/Reducer/Reducers/OnChange.swift b/Sources/ComposableArchitecture/Reducer/Reducers/OnChange.swift index 5203029cdf69..6f82c04de392 100644 --- a/Sources/ComposableArchitecture/Reducer/Reducers/OnChange.swift +++ b/Sources/ComposableArchitecture/Reducer/Reducers/OnChange.swift @@ -1,11 +1,11 @@ -extension ReducerProtocol { +extension Reducer { /// Adds a reducer to run when this reducer changes the given value in state. /// /// Use this operator to trigger additional logic when a value changes, like when a /// ``BindingReducer`` makes a deeper change to a struct held in ``BindingState``. /// /// ```swift - /// struct Settings: ReducerProtocol { + /// struct Settings: Reducer { /// struct State { /// @BindingState var userSettings: UserSettings /// // ... @@ -16,7 +16,7 @@ extension ReducerProtocol { /// // ... /// } /// - /// var body: some ReducerProtocol { + /// var body: some Reducer { /// BindingReducer() /// .onChange(of: \.userSettings.isHapticFeedbackEnabled) { oldValue, newValue in /// Reduce { state, action in @@ -44,7 +44,7 @@ extension ReducerProtocol { /// - newValue: The new value that failed the comparison check. /// - Returns: A reducer that performs the @inlinable - public func onChange( + public func onChange( of toValue: @escaping (State) -> V, @ReducerBuilder _ reducer: @escaping (_ oldValue: V, _ newValue: V) -> R ) -> _OnChangeReducer { @@ -52,8 +52,7 @@ extension ReducerProtocol { } } -public struct _OnChangeReducer: - ReducerProtocol +public struct _OnChangeReducer: Reducer where Base.State == Body.State, Base.Action == Body.Action { @usableFromInline let base: Base diff --git a/Sources/ComposableArchitecture/SwiftUI/Binding.swift b/Sources/ComposableArchitecture/SwiftUI/Binding.swift index 29b1d7733dd8..36f7ce1dc7a0 100644 --- a/Sources/ComposableArchitecture/SwiftUI/Binding.swift +++ b/Sources/ComposableArchitecture/SwiftUI/Binding.swift @@ -257,7 +257,7 @@ public struct BindingViewStore { ) -> BindingViewState { BindingViewState( // OPTIMIZE: Can we derive bindings directly from `Store` and avoid the work of creating a `ViewStore`? - binding: ViewStore(self.store, removeDuplicates: { _, _ in false }).binding( + binding: ViewStore(self.store, observe: { $0 }, removeDuplicates: { _, _ in false }).binding( get: { $0[keyPath: keyPath].wrappedValue }, send: { value in #if DEBUG diff --git a/Tests/ComposableArchitectureTests/Reducers/OnChangeReducerTests.swift b/Tests/ComposableArchitectureTests/Reducers/OnChangeReducerTests.swift index 1d134cb7eb06..0a2b5f2429c3 100644 --- a/Tests/ComposableArchitectureTests/Reducers/OnChangeReducerTests.swift +++ b/Tests/ComposableArchitectureTests/Reducers/OnChangeReducerTests.swift @@ -4,7 +4,7 @@ import XCTest @MainActor final class OnChangeReducerTests: BaseTCATestCase { func testOnChange() async { - struct Feature: ReducerProtocol { + struct Feature: Reducer { struct State: Equatable { var count = 0 var description = "" @@ -13,7 +13,7 @@ final class OnChangeReducerTests: BaseTCATestCase { case incrementButtonTapped case decrementButtonTapped } - var body: some ReducerProtocolOf { + var body: some ReducerOf { Reduce { state, action in switch action { case .decrementButtonTapped: