public protocol ThreadConfined
Objects of types which conform to ThreadConfined
can be managed by a Realm, which will make them bound to a thread-specific Realm
instance. Managed objects must be explicitly exported and imported to be passed between threads.
Managed instances of objects conforming to this protocol can be converted to a thread-safe reference for transport between threads by passing to the ThreadSafeReference(to:)
constructor.
Note that only types defined by Realm can meaningfully conform to this protocol, and defining new classes which attempt to conform to it will not make them work with ThreadSafeReference
.
The Realm which manages the object, or nil
if the object is unmanaged.
Unmanaged objects are not confined to a thread and cannot be passed to methods expecting a ThreadConfined
object.
Swift
var realm: Realm? { get }
Indicates if the object can no longer be accessed because it is now invalid.
DeclarationSwift
var isInvalidated: Bool { get }
Indicates if the object is frozen.
Frozen objects are not confined to their source thread. Forming a ThreadSafeReference
to a frozen object is allowed, but is unlikely to be useful.
Swift
var isFrozen: Bool { get }
Returns a frozen snapshot of this object.
Unlike normal Realm live objects, the frozen copy can be read from any thread, and the values read will never update to reflect new writes to the Realm. Frozen collections can be queried like any other Realm collection. Frozen objects cannot be mutated, and cannot be observed for change notifications.
Unmanaged Realm objects cannot be frozen.
DeclarationSwift
func freeze() -> Self
Returns a live (mutable) reference of this object. Will return self if called on an already live object.
DeclarationSwift
func thaw() -> Self?
Create a Binding
for a given property, allowing for automatically transacted reads and writes behind the scenes.
This is a convenience method for SwiftUI views (e.g., TextField, DatePicker) that require a Binding
to be passed in. SwiftUI will automatically read/write from the binding.
Swift
@MainActor
public func bind<V>(_ keyPath: ReferenceWritableKeyPath<Self, V>) -> Binding<V> where V : _Persistable, V : Equatable
Self
: ObjectBase
Create a Binding
for a given property, allowing for automatically transacted reads and writes behind the scenes.
This is a convenience method for SwiftUI views (e.g., TextField, DatePicker) that require a Binding
to be passed in. SwiftUI will automatically read/write from the binding.
Swift
@MainActor
public func bind<V>(_ keyPath: ReferenceWritableKeyPath<Self, V>) -> Binding<V> where V : _Persistable, V : Equatable
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4