ObservableProperty.swift 751 B

12345678910111213141516171819
  1. import Foundation
  2. /// View properties that conform to ObservableProperty are automatically observed by SwiftCrossUI.
  3. ///
  4. /// This protocol is intended to be implemented by property wrappers. You shouldn't
  5. /// have to implement it for your own model types.
  6. public protocol ObservableProperty: DynamicProperty {
  7. var didChange: Publisher { get }
  8. }
  9. /// View properties that conform to SnapshottableProperty can be snapshotted by
  10. /// the hot reloading mechanism.
  11. ///
  12. /// This protocol is intended to be implemented by property wrappers. You shouldn't
  13. /// have to implement it for your own model types.
  14. public protocol SnapshottableProperty: ObservableProperty {
  15. func tryRestoreFromSnapshot(_ snapshot: Data)
  16. func snapshot() throws -> Data?
  17. }