update
Shared.swift:458func update()
func update()
import Sharing
Instantly share state among your app’s features and external persistence layers, including user defaults, the file system, and more.
@dynamicMemberLookup @propertyWrapper struct Shared<Value>
A property wrapper type that shares a value with other parts of the application and/or external systems.
init<Wrapped>(_ key: some SharedKey<Value>) where Value == Wrapped?, Wrapped : Sendable
Creates a shared reference to an optional value using a shared key.
init(_ key: (some SharedKey<Value>).Default)
Creates a shared reference to a value using a shared key with a default value.
init?(_ base: Shared<Value?>)
Unwraps a shared reference to an optional value.
init(projectedValue: Self)
Creates a shared reference from another shared reference.
init(require key: some SharedKey<Value>) async throws
Creates a shared reference to a value using a shared key by loading it from its external source.
init(value: sending Value)
init(wrappedValue: @autoclosure () -> Value, _ key: (some SharedKey<Value>).Default)
Creates a shared reference to a value using a shared key by overriding its default value.
init(wrappedValue: @autoclosure () -> Value, _ key: some SharedKey<Value>)
Creates a shared reference to a value using a shared key.
var _customDiffValues: (Any, Any) { get }
var _objectIdentifier: ObjectIdentifier { get }
var customDumpValue: Any { get }
var description: String { get }
var isLoading: Bool { get }
Whether or not an associated shared key is loading data from an external source.
var loadError: (any Error)? { get }
An error encountered during the most recent attempt to load data.
var projectedValue: Self { get nonmutating set }
A projection of the shared value that returns a shared reference.
var publisher: some Publisher<Value, Never> { get }
Returns a publisher that emits events when the underlying value changes.
var saveError: (any Error)? { get }
An error encountered during the most recent attempt to save data.
var wrappedValue: Value { get nonmutating set }
subscript<Member>(dynamicMember keyPath: KeyPath<Value, Member>) -> SharedReader<Member> { get }
Returns a read-only shared reference to the resulting value of a given key path.
subscript<Member>(dynamicMember keyPath: WritableKeyPath<Value, Member>) -> Shared<Member> { get }
Returns a shared reference to the resulting value of a given key path.
func load() async throws
Requests an up-to-date value from an external source.
func load(_ key: some SharedKey<Value>) async throws
Replaces a shared reference’s key and attempts to load its value.
func save() async throws
Requests the underlying value be persisted to an external source.
func withLock<R>(_ operation: (inout Value) throws -> R, fileID: StaticString = #fileID, filePath: StaticString = #filePath, line: UInt = #line, column: UInt = #column) rethrows -> R
Perform an operation on shared state with isolated access to the underlying value.