ObjectObserver
public protocol ObjectObserver : AnyObject
Implement the ObjectObserver protocol to observe changes to a single DynamicObject instance. ObjectObservers may register themselves to an ObjectMonitor‘s addObserver(_:) method:
let monitor = dataStack.monitorObject(object)
monitor.addObserver(self)
-
The
DynamicObjecttype for the observed objectDeclaration
Swift
associatedtype ObjectEntityType : DynamicObject -
objectMonitor(_:Default implementationwillUpdateObject: sourceIdentifier: ) Handles processing just before a change to the observed
objectoccurs. (Optional) The default implementation does nothing.Default Implementation
Declaration
Swift
func objectMonitor( _ monitor: ObjectMonitor<ObjectEntityType>, willUpdateObject object: ObjectEntityType, sourceIdentifier: Any? )Parameters
monitorthe
ObjectMonitormonitoring the object being observedobjectthe
DynamicObjectinstance being observedsourceIdentifieran optional identifier provided by the transaction source
-
objectMonitor(_:Default implementationwillUpdateObject: ) Handles processing just before a change to the observed
objectoccurs. (Optional) The default implementation does nothing.Default Implementation
Declaration
Swift
func objectMonitor( _ monitor: ObjectMonitor<ObjectEntityType>, willUpdateObject object: ObjectEntityType )Parameters
monitorthe
ObjectMonitormonitoring the object being observedobjectthe
DynamicObjectinstance being observed -
objectMonitor(_:Default implementationdidUpdateObject: changedPersistentKeys: sourceIdentifier: ) Handles processing right after a change to the observed
objectoccurs. (Optional) The default implementation does nothing.Default Implementation
Declaration
Swift
func objectMonitor( _ monitor: ObjectMonitor<ObjectEntityType>, didUpdateObject object: ObjectEntityType, changedPersistentKeys: Set<KeyPathString>, sourceIdentifier: Any? )Parameters
monitorthe
ObjectMonitormonitoring the object being observedobjectthe
DynamicObjectinstance being observedchangedPersistentKeysa
Setof key paths for the attributes that were changed. Note thatchangedPersistentKeysonly contains keys for attributes/relationships present in the persistent store, thus transient properties will not be reported.sourceIdentifieran optional identifier provided by the transaction source
-
objectMonitor(_:Default implementationdidUpdateObject: changedPersistentKeys: ) Handles processing right after a change to the observed
objectoccurs. (Optional) The default implementation does nothing.Default Implementation
Declaration
Swift
func objectMonitor( _ monitor: ObjectMonitor<ObjectEntityType>, didUpdateObject object: ObjectEntityType, changedPersistentKeys: Set<KeyPathString> )Parameters
monitorthe
ObjectMonitormonitoring the object being observedobjectthe
DynamicObjectinstance being observedchangedPersistentKeysa
Setof key paths for the attributes that were changed. Note thatchangedPersistentKeysonly contains keys for attributes/relationships present in the persistent store, thus transient properties will not be reported. -
objectMonitor(_:Default implementationdidDeleteObject: sourceIdentifier: ) Handles processing right after
objectis deleted. (Optional) The default implementation does nothing.Default Implementation
Declaration
Swift
func objectMonitor( _ monitor: ObjectMonitor<ObjectEntityType>, didDeleteObject object: ObjectEntityType, sourceIdentifier: Any? )Parameters
monitorthe
ObjectMonitormonitoring the object being observedobjectthe
DynamicObjectinstance being observedsourceIdentifieran optional identifier provided by the transaction source
-
objectMonitor(_:Default implementationdidDeleteObject: ) Handles processing right after
objectis deleted. (Optional) The default implementation does nothing.Default Implementation
Declaration
Swift
func objectMonitor( _ monitor: ObjectMonitor<ObjectEntityType>, didDeleteObject object: ObjectEntityType )Parameters
monitorthe
ObjectMonitormonitoring the object being observedobjectthe
DynamicObjectinstance being observed
View on GitHub
ObjectObserver Protocol Reference