@@ -11,7 +11,7 @@ import SwiftUI
11
11
/// Read <doc:Bindings> for more information.
12
12
@dynamicMemberLookup
13
13
@propertyWrapper
14
- public struct BindableState < Value> {
14
+ public struct BindingState < Value> {
15
15
/// The underlying value wrapped by the bindable state.
16
16
public var wrappedValue : Value
17
17
@@ -23,13 +23,13 @@ public struct BindableState<Value> {
23
23
/// A projection that can be used to derive bindings from a view store.
24
24
///
25
25
/// Use the projected value to derive bindings from a view store with properties annotated with
26
- /// `@BindableState `. To get the `projectedValue`, prefix the property with `$`:
26
+ /// `@BindingState `. To get the `projectedValue`, prefix the property with `$`:
27
27
///
28
28
/// ```swift
29
29
/// TextField("Display name", text: viewStore.binding(\.$displayName))
30
30
/// ```
31
31
///
32
- /// See ``BindableState `` for more details.
32
+ /// See ``BindingState `` for more details.
33
33
public var projectedValue : Self {
34
34
get { self }
35
35
set { self = newValue }
@@ -41,17 +41,17 @@ public struct BindableState<Value> {
41
41
/// - Returns: A new bindable state.
42
42
public subscript< Subject> (
43
43
dynamicMember keyPath: WritableKeyPath < Value , Subject >
44
- ) -> BindableState < Subject > {
44
+ ) -> BindingState < Subject > {
45
45
get { . init( wrappedValue: self . wrappedValue [ keyPath: keyPath] ) }
46
46
set { self . wrappedValue [ keyPath: keyPath] = newValue. wrappedValue }
47
47
}
48
48
}
49
49
50
- extension BindableState : Equatable where Value: Equatable { }
50
+ extension BindingState : Equatable where Value: Equatable { }
51
51
52
- extension BindableState : Hashable where Value: Hashable { }
52
+ extension BindingState : Hashable where Value: Hashable { }
53
53
54
- extension BindableState : Decodable where Value: Decodable {
54
+ extension BindingState : Decodable where Value: Decodable {
55
55
public init ( from decoder: Decoder ) throws {
56
56
do {
57
57
let container = try decoder. singleValueContainer ( )
@@ -62,7 +62,7 @@ extension BindableState: Decodable where Value: Decodable {
62
62
}
63
63
}
64
64
65
- extension BindableState : Encodable where Value: Encodable {
65
+ extension BindingState : Encodable where Value: Encodable {
66
66
public func encode( to encoder: Encoder ) throws {
67
67
do {
68
68
var container = encoder. singleValueContainer ( )
@@ -73,29 +73,29 @@ extension BindableState: Encodable where Value: Encodable {
73
73
}
74
74
}
75
75
76
- extension BindableState : CustomReflectable {
76
+ extension BindingState : CustomReflectable {
77
77
public var customMirror : Mirror {
78
78
Mirror ( reflecting: self . wrappedValue)
79
79
}
80
80
}
81
81
82
- extension BindableState : CustomDumpRepresentable {
82
+ extension BindingState : CustomDumpRepresentable {
83
83
public var customDumpValue : Any {
84
84
self . wrappedValue
85
85
}
86
86
}
87
87
88
- extension BindableState : CustomDebugStringConvertible where Value: CustomDebugStringConvertible {
88
+ extension BindingState : CustomDebugStringConvertible where Value: CustomDebugStringConvertible {
89
89
public var debugDescription : String {
90
90
self . wrappedValue. debugDescription
91
91
}
92
92
}
93
93
94
- extension BindableState : Sendable where Value: Sendable { }
94
+ extension BindingState : Sendable where Value: Sendable { }
95
95
96
96
/// An action type that exposes a `binding` case that holds a ``BindingAction``.
97
97
///
98
- /// Used in conjunction with ``BindableState `` to safely eliminate the boilerplate typically
98
+ /// Used in conjunction with ``BindingState `` to safely eliminate the boilerplate typically
99
99
/// associated with mutating multiple fields in state.
100
100
///
101
101
/// Read <doc:Bindings> for more information.
@@ -116,7 +116,7 @@ extension BindableAction {
116
116
///
117
117
/// - Returns: A binding action.
118
118
public static func set< Value: Equatable > (
119
- _ keyPath: WritableKeyPath < State , BindableState < Value > > ,
119
+ _ keyPath: WritableKeyPath < State , BindingState < Value > > ,
120
120
_ value: Value
121
121
) -> Self {
122
122
self . binding ( . set( keyPath, value) )
@@ -129,7 +129,7 @@ extension ViewStore where ViewAction: BindableAction, ViewAction.State == ViewSt
129
129
/// - Parameter keyPath: A key path to a specific bindable state.
130
130
/// - Returns: A new binding.
131
131
public func binding< Value: Equatable > (
132
- _ keyPath: WritableKeyPath < ViewState , BindableState < Value > > ,
132
+ _ keyPath: WritableKeyPath < ViewState , BindingState < Value > > ,
133
133
file: StaticString = #file,
134
134
fileID: StaticString = #fileID,
135
135
line: UInt = #line
@@ -157,7 +157,7 @@ extension ViewStore where ViewAction: BindableAction, ViewAction.State == ViewSt
157
157
158
158
/// An action that describes simple mutations to some root state at a writable key path.
159
159
///
160
- /// Used in conjunction with ``BindableState `` and ``BindableAction`` to safely eliminate the
160
+ /// Used in conjunction with ``BindingState `` and ``BindableAction`` to safely eliminate the
161
161
/// boilerplate typically associated with mutating multiple fields in state.
162
162
///
163
163
/// Read <doc:Bindings> for more information.
@@ -180,12 +180,12 @@ extension BindingAction {
180
180
///
181
181
/// - Parameters:
182
182
/// - keyPath: A key path to the property that should be mutated. This property must be
183
- /// annotated with the ``BindableState `` property wrapper.
183
+ /// annotated with the ``BindingState `` property wrapper.
184
184
/// - value: A value to assign at the given key path.
185
185
/// - Returns: An action that describes simple mutations to some root state at a writable key
186
186
/// path.
187
187
public static func set< Value: Equatable > (
188
- _ keyPath: WritableKeyPath < Root , BindableState < Value > > ,
188
+ _ keyPath: WritableKeyPath < Root , BindingState < Value > > ,
189
189
_ value: Value
190
190
) -> Self {
191
191
return . init(
@@ -208,14 +208,14 @@ extension BindingAction {
208
208
/// // Return an authorization request effect
209
209
/// ```
210
210
public static func ~= < Value> (
211
- keyPath: WritableKeyPath < Root , BindableState < Value > > ,
211
+ keyPath: WritableKeyPath < Root , BindingState < Value > > ,
212
212
bindingAction: Self
213
213
) -> Bool {
214
214
keyPath == bindingAction. keyPath
215
215
}
216
216
217
217
init < Value: Equatable > (
218
- keyPath: WritableKeyPath < Root , BindableState < Value > > ,
218
+ keyPath: WritableKeyPath < Root , BindingState < Value > > ,
219
219
set: @escaping ( inout Root ) -> Void ,
220
220
value: Value
221
221
) {
@@ -233,15 +233,15 @@ extension BindingAction {
233
233
/// key path.
234
234
///
235
235
/// Useful in transforming binding actions on view state into binding actions on reducer state
236
- /// when the domain contains ``BindableState `` and ``BindableAction``.
236
+ /// when the domain contains ``BindingState `` and ``BindableAction``.
237
237
///
238
238
/// For example, we can model an feature that can bind an integer count to a stepper and make a
239
239
/// network request to fetch a fact about that integer with the following domain:
240
240
///
241
241
/// ```swift
242
242
/// struct MyFeature: ReducerProtocol {
243
243
/// struct State: Equatable {
244
- /// @BindableState var count = 0
244
+ /// @BindingState var count = 0
245
245
/// var fact: String?
246
246
/// ...
247
247
/// }
@@ -279,7 +279,7 @@ extension BindingAction {
279
279
/// ```swift
280
280
/// extension MyFeatureView {
281
281
/// struct ViewState: Equatable {
282
- /// @BindableState var count: Int
282
+ /// @BindingState var count: Int
283
283
/// let fact: String?
284
284
/// // no access to any other state on `MyFeature.State`, like child domains
285
285
/// }
0 commit comments