Skip to content

Commit 90ea5d4

Browse files
stephencelisp4checo
authored andcommitted
Rename BindableState to BindingState (#1855)
The -`able` naming evokes protocols in Swift, and is an outlier when considered alongside the rest of TCA's binding tools: - `BindingAction`: concrete type - `BindableAction`: protocol - `BindingReducer`: concrete type So, let's make things consistent. The one caveat is that Swift diagnostics for such a deprecation aren't great, so users won't get proactive warnings here for the time being: swiftlang/swift#63139 We may just want to keep the deprecation around till it does... (cherry picked from commit 52c4a01437aa1429dab4e6b460062a8b7d6aeab6) # Conflicts: # Sources/ComposableArchitecture/Internal/Deprecations.swift # Sources/ComposableArchitecture/SwiftUI/Binding.swift # Tests/ComposableArchitectureTests/DebugTests.swift
1 parent 37d99ca commit 90ea5d4

File tree

9 files changed

+649
-641
lines changed

9 files changed

+649
-641
lines changed

Examples/CaseStudies/SwiftUICaseStudies/01-GettingStarted-Bindings-Forms.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ private let readMe = """
88
Bindable state and actions allow you to safely eliminate the boilerplate caused by needing to \
99
have a unique action for every UI control. Instead, all UI bindings can be consolidated into a \
1010
single `binding` action that holds onto a `BindingAction` value, and all bindable state can be \
11-
safeguarded with the `BindableState` property wrapper.
11+
safeguarded with the `BindingState` property wrapper.
1212
1313
It is instructive to compare this case study to the "Binding Basics" case study.
1414
"""
@@ -17,10 +17,10 @@ private let readMe = """
1717

1818
struct BindingForm: ReducerProtocol {
1919
struct State: Equatable {
20-
@BindableState var sliderValue = 5.0
21-
@BindableState var stepCount = 10
22-
@BindableState var text = ""
23-
@BindableState var toggleIsOn = false
20+
@BindingState var sliderValue = 5.0
21+
@BindingState var stepCount = 10
22+
@BindingState var text = ""
23+
@BindingState var toggleIsOn = false
2424
}
2525

2626
enum Action: BindableAction, Equatable {

Examples/CaseStudies/SwiftUICaseStudies/01-GettingStarted-FocusState.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ private let readMe = """
1010

1111
struct FocusDemo: ReducerProtocol {
1212
struct State: Equatable {
13-
@BindableState var focusedField: Field?
14-
@BindableState var password: String = ""
15-
@BindableState var username: String = ""
13+
@BindingState var focusedField: Field?
14+
@BindingState var password: String = ""
15+
@BindingState var username: String = ""
1616

1717
enum Field: String, Hashable {
1818
case username, password

Sources/ComposableArchitecture/Documentation.docc/Articles/Bindings.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,20 +177,20 @@ struct Settings: ReducerProtocol {
177177
```
178178

179179
This is a _lot_ of boilerplate for something that should be simple. Luckily, we can dramatically
180-
eliminate this boilerplate using ``BindableState``, ``BindableAction``, and ``BindingReducer``.
180+
eliminate this boilerplate using ``BindingState``, ``BindableAction``, and ``BindingReducer``.
181181

182-
First, we can annotate each bindable value of state with the ``BindableState`` property wrapper:
182+
First, we can annotate each bindable value of state with the ``BindingState`` property wrapper:
183183

184184
```swift
185185
struct Settings: ReducerProtocol {
186186
struct State: Equatable {
187-
@BindableState var digest = Digest.daily
188-
@BindableState var displayName = ""
189-
@BindableState var enableNotifications = false
187+
@BindingState var digest = Digest.daily
188+
@BindingState var displayName = ""
189+
@BindingState var enableNotifications = false
190190
var isLoading = false
191-
@BindableState var protectMyPosts = false
192-
@BindableState var sendEmailNotifications = false
193-
@BindableState var sendMobileNotifications = false
191+
@BindingState var protectMyPosts = false
192+
@BindingState var sendEmailNotifications = false
193+
@BindingState var sendMobileNotifications = false
194194
}
195195

196196
// ...

Sources/ComposableArchitecture/Documentation.docc/Extensions/SwiftUI.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ The Composable Architecture can be used to power applications built in many fram
1919

2020
- <doc:Bindings>
2121
- ``ViewStore/binding(get:send:)-65xes``
22-
- ``BindableState``
22+
- ``BindingState``
2323
- ``BindableAction``
2424
- ``BindingAction``
2525
- ``BindingReducer``

0 commit comments

Comments
 (0)