init(_:)
Creates a read-only shared reference from a shared reference.
init(_ base: Shared<Value>)
Parameters
- base
A shared reference.
Creates a read-only shared reference from a shared reference.
init(_ base: Shared<Value>)
A shared reference.
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 SharedReader<Value>
A property wrapper type that shares a read-only value with multiple parts of an application.
@dynamicMemberLookup @propertyWrapper struct Shared<Value>
A property wrapper type that shares a value with other parts of the application and/or external systems.
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.
init?(_ base: Shared<Value?>)
Unwraps a read-only shared reference to an optional value.
init?(_ base: SharedReader<Value?>)
Unwraps a read-only shared reference to an optional value.
init<Wrapped>(_ key: some SharedReaderKey<Value>) where Value == Wrapped?, Wrapped : Sendable
Creates a shared reference to an optional, read-only value using a shared key.
init(_ key: (some SharedReaderKey<Value>).Default)
Creates a shared reference to a read-only value using a shared key with a default value.
init(projectedValue: Self)
Creates a read-only shared reference from another read-only shared reference.
init(require key: some SharedReaderKey<Value>) async throws
Creates a shared reference to a read-only value using a shared key by loading it from its external source.
init(value: sending Value)
init(wrappedValue: @autoclosure () -> Value, _ key: (some SharedReaderKey<Value>).Default)
Creates a shared reference to a read-only value using a shared key by overriding its default value.
init(wrappedValue: @autoclosure () -> Value, _ key: some SharedReaderKey<Value>)
Creates a shared reference to a read-only value using a shared key.
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 read-only 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 wrappedValue: Value { get }
The underlying value referenced by the shared variable.
func load() async throws
Requests an up-to-date value from an external source.
func load(_ key: some SharedReaderKey<Value>) async throws
Replaces a shared reference’s key and attempts to load its value.
func update()
static func constant(_ value: sending Value) -> SharedReader<Value>