@@ -5,7 +5,7 @@ import Foundation
55// - It supports ObservableObject
66// - It supports Optional<ObservableObject>
77@propertyWrapper
8- public struct State < Value> : DynamicProperty , StateProperty {
8+ public struct State < Value> : DynamicProperty , ObservableProperty {
99 class Storage {
1010 // This inner box is what stays constant between view updates. The
1111 // outer box (Storage) is used so that we can assign this box to
@@ -55,7 +55,7 @@ public struct State<Value>: DynamicProperty, StateProperty {
5555
5656 var storage : Storage
5757
58- var didChange : Publisher {
58+ public var didChange : Publisher {
5959 storage. box. didChange
6060 }
6161
@@ -109,7 +109,7 @@ public struct State<Value>: DynamicProperty, StateProperty {
109109 }
110110 }
111111
112- func tryRestoreFromSnapshot( _ snapshot: Data ) {
112+ public func tryRestoreFromSnapshot( _ snapshot: Data ) {
113113 guard
114114 let decodable = Value . self as? Codable . Type ,
115115 let state = try ? JSONDecoder ( ) . decode ( decodable, from: snapshot)
@@ -120,7 +120,7 @@ public struct State<Value>: DynamicProperty, StateProperty {
120120 storage. box. value = state as! Value
121121 }
122122
123- func snapshot( ) throws -> Data ? {
123+ public func snapshot( ) throws -> Data ? {
124124 if let value = storage. box as? Codable {
125125 return try JSONEncoder ( ) . encode ( value)
126126 } else {
@@ -129,7 +129,10 @@ public struct State<Value>: DynamicProperty, StateProperty {
129129 }
130130}
131131
132- protocol StateProperty {
132+ /// Declaring conformance to ObservableProperty is required for
133+ /// SwiftCrossUI to automatically register an observer on the
134+ /// conforming object's Publisher.
135+ public protocol ObservableProperty {
133136 var didChange : Publisher { get }
134137 func tryRestoreFromSnapshot( _ snapshot: Data )
135138 func snapshot( ) throws -> Data ?
0 commit comments