diff --git a/Sources/AppState/Application/Application.swift b/Sources/AppState/Application/Application.swift index b3e71d8..5fee0c0 100644 --- a/Sources/AppState/Application/Application.swift +++ b/Sources/AppState/Application/Application.swift @@ -97,7 +97,7 @@ open class Application: NSObject, ObservableObject { self, selector: #selector(didChangeExternally), name: NSUbiquitousKeyValueStore.didChangeExternallyNotification, - object: nil + object: NSUbiquitousKeyValueStore.default ) } diff --git a/Sources/AppState/Application/Types/Application+SyncState.swift b/Sources/AppState/Application/Types/Application+SyncState.swift index be3517d..36c6720 100644 --- a/Sources/AppState/Application/Types/Application+SyncState.swift +++ b/Sources/AppState/Application/Types/Application+SyncState.swift @@ -6,8 +6,12 @@ extension Application { dependency(NSUbiquitousKeyValueStore.default) } - /// The `SyncState` struct is a data structure designed to handle the state synchronization of an application that supports the `Codable` type. - /// It utilizes Apple's iCloud Key-Value Store to propagate state changes across multiple devices. + /** + The `SyncState` struct is a data structure designed to handle the state synchronization of an application that supports the `Codable` type. + It utilizes Apple's iCloud Key-Value Store to propagate state changes across multiple devices. + + - Note: The key-value store is intended for storing data that changes infrequently. As you test your devices, if the app on a device makes frequent changes to the key-value store, the system may defer the synchronization of some changes in order to minimize the number of round trips to the server. The more frequently the app make changes, the more likely the changes will be deferred and will not immediately show up on the other devices. + */ public struct SyncState: CustomStringConvertible { @AppDependency(\.icloudStore) private var icloudStore: NSUbiquitousKeyValueStore diff --git a/Sources/AppState/PropertyWrappers/SyncState.swift b/Sources/AppState/PropertyWrappers/SyncState.swift index 477f67b..7895244 100644 --- a/Sources/AppState/PropertyWrappers/SyncState.swift +++ b/Sources/AppState/PropertyWrappers/SyncState.swift @@ -2,7 +2,11 @@ import Foundation import Combine import SwiftUI -/// `SyncState` is a property wrapper that allows SwiftUI views to subscribe to Application's state changes in a reactive way. The state is synchronized using `NSUbiquitousKeyValueStore`, and it works similarly to `State` and `Published`. +/** +`SyncState` is a property wrapper that allows SwiftUI views to subscribe to Application's state changes in a reactive way. The state is synchronized using `NSUbiquitousKeyValueStore`, and it works similarly to `State` and `Published`. + + - Note: The key-value store is intended for storing data that changes infrequently. As you test your devices, if the app on a device makes frequent changes to the key-value store, the system may defer the synchronization of some changes in order to minimize the number of round trips to the server. The more frequently the app make changes, the more likely the changes will be deferred and will not immediately show up on the other devices. + */ @propertyWrapper public struct SyncState: DynamicProperty { /// Holds the singleton instance of `Application`. @ObservedObject private var app: Application = Application.shared