File tree 2 files changed +14
-0
lines changed
Sources/ComposableArchitecture/SharedState
2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,11 @@ public struct Shared<Value> {
95
95
self = projectedValue
96
96
}
97
97
98
+ public init ? ( _ base: Shared < Value ? > ) {
99
+ guard let shared = base [ dynamicMember: \. self] else { return nil }
100
+ self = shared
101
+ }
102
+
98
103
public subscript< Member> (
99
104
dynamicMember keyPath: WritableKeyPath < Value , Member >
100
105
) -> Shared < Member > {
Original file line number Diff line number Diff line change @@ -21,6 +21,15 @@ public struct SharedReader<Value> {
21
21
self = projectedValue
22
22
}
23
23
24
+ public init ? ( _ base: SharedReader < Value ? > ) {
25
+ guard let shared = base [ dynamicMember: \. self] else { return nil }
26
+ self = shared
27
+ }
28
+
29
+ public init ( _ base: Shared < Value > ) {
30
+ self = base. reader
31
+ }
32
+
24
33
public init ( _ value: Value , fileID: StaticString = #fileID, line: UInt = #line) {
25
34
self . init (
26
35
reference: ValueReference < Value , InMemoryKey < Value > > (
You can’t perform that action at this time.
0 commit comments