Skip to content

Commit 7ede19f

Browse files
authored
Improve deprecation warnings for old binding helpers (#774)
* Improve deprecation warnings for old binding helpers * wip * wip * wip * esc * wip
1 parent 7d15362 commit 7ede19f

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

Sources/ComposableArchitecture/Internal/Deprecations.swift

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ import SwiftUI
66

77
#if compiler(>=5.4)
88
extension BindingAction {
9-
@available(*, deprecated, message: "Values are now wrapped in 'BindableState'")
9+
@available(
10+
*, deprecated,
11+
message:
12+
"For improved safety, bindable properties must now be wrapped explicitly in 'BindableState', and accessed via key paths to that 'BindableState', like '\\.$value'"
13+
)
1014
public static func set<Value>(
1115
_ keyPath: WritableKeyPath<Root, Value>,
1216
_ value: Value
@@ -20,7 +24,11 @@ import SwiftUI
2024
)
2125
}
2226

23-
@available(*, deprecated, message: "Values are now wrapped in 'BindableState'")
27+
@available(
28+
*, deprecated,
29+
message:
30+
"For improved safety, bindable properties must now be wrapped explicitly in 'BindableState', and accessed via key paths to that 'BindableState', like '\\.$value'"
31+
)
2432
public static func ~= <Value>(
2533
keyPath: WritableKeyPath<Root, Value>,
2634
bindingAction: Self
@@ -33,7 +41,7 @@ import SwiftUI
3341
@available(
3442
*, deprecated,
3543
message:
36-
"'Reducer.binding()' no longer takes an explicit extract function and instead relies on 'BindableAction'"
44+
"'Reducer.binding()' no longer takes an explicit extract function and instead the reducer's 'Action' type must conform to 'BindableAction'"
3745
)
3846
public func binding(action toBindingAction: @escaping (Action) -> BindingAction<State>?) -> Self
3947
{
@@ -46,7 +54,9 @@ import SwiftUI
4654

4755
extension ViewStore {
4856
@available(
49-
*, deprecated, message: "Bindings are now derived using 'BindableState' and 'BindableAction'"
57+
*, deprecated,
58+
message:
59+
"For improved safety, bindable properties must now be wrapped explicitly in 'BindableState'. Bindings are now derived via dynamic member lookup to that 'BindableState' (for example, 'viewStore.$value'). For dynamic member lookup to be available, the view store's 'Action' type must also conform to 'BindableAction'."
5060
)
5161
public func binding<LocalState>(
5262
keyPath: WritableKeyPath<State, LocalState>,
@@ -64,7 +74,7 @@ import SwiftUI
6474
@available(
6575
*, deprecated,
6676
message:
67-
"Values are now wrapped in 'BindableState'. Upgrade to Xcode 12.5 or greater for access to 'BindableState'."
77+
"For improved safety, bindable properties must now be wrapped explicitly in 'BindableState', and accessed via key paths to that 'BindableState', like '\\.$value'. Upgrade to Xcode 12.5 or greater for access to 'BindableState'."
6878
)
6979
public static func set<Value>(
7080
_ keyPath: WritableKeyPath<Root, Value>,
@@ -82,7 +92,7 @@ import SwiftUI
8292
@available(
8393
*, deprecated,
8494
message:
85-
"Values are now wrapped in 'BindableState'. Upgrade to Xcode 12.5 or greater for access to 'BindableState'."
95+
"For improved safety, bindable properties must now be wrapped explicitly in 'BindableState', and accessed via key paths to that 'BindableState', like '\\.$value'. Upgrade to Xcode 12.5 or greater for access to 'BindableState'."
8696
)
8797
public static func ~= <Value>(
8898
keyPath: WritableKeyPath<Root, Value>,
@@ -96,7 +106,7 @@ import SwiftUI
96106
@available(
97107
*, deprecated,
98108
message:
99-
"'Reducer.binding()' no longer takes an explicit extract function and instead relies on 'BindableAction'. Upgrade to Xcode 12.5 or greater for access to 'Reducer.binding()' and 'BindableAction'."
109+
"'Reducer.binding()' no longer takes an explicit extract function and instead the reducer's 'Action' type must conform to 'BindableAction'. Upgrade to Xcode 12.5 or greater for access to 'Reducer.binding()' and 'BindableAction'."
100110
)
101111
public func binding(action toBindingAction: @escaping (Action) -> BindingAction<State>?) -> Self
102112
{
@@ -111,7 +121,7 @@ import SwiftUI
111121
@available(
112122
*, deprecated,
113123
message:
114-
"Bindings are now derived using 'BindableState' and 'BindableAction'. Upgrade to Xcode 12.5 or greater for access to 'BindableState' and 'BindableAction'."
124+
"For improved safety, bindable properties must now be wrapped explicitly in 'BindableState'. Bindings are now derived via dynamic member lookup to that 'BindableState' (for example, 'viewStore.$value'). For dynamic member lookup to be available, the view store's 'Action' type must also conform to 'BindableAction'. Upgrade to Xcode 12.5 or greater for access to 'BindableState' and 'BindableAction'."
115125
)
116126
public func binding<LocalState>(
117127
keyPath: WritableKeyPath<State, LocalState>,

0 commit comments

Comments
 (0)