Implement ObjectRepresentation on ObjectMonitor, ObjectPublisher, and ObjectSnapshot for future APIs

This commit is contained in:
John Estropia
2021-01-02 09:59:15 +09:00
parent e1aed37da0
commit 2cd8101987
4 changed files with 101 additions and 43 deletions

View File

@@ -48,17 +48,25 @@ public struct ObjectSnapshot<O: DynamicObject>: ObjectRepresentation, Hashable {
return self.values
}
// MARK: ObjectRepresentation
public typealias ObjectType = O
// MARK: AnyObjectRepresentation
public func objectID() -> O.ObjectID {
return self.id
}
public func cs_dataStack() -> DataStack? {
return self.context.parentStack
}
// MARK: ObjectRepresentation
public typealias ObjectType = O
public func asPublisher(in dataStack: DataStack) -> ObjectPublisher<O> {
let context = dataStack.unsafeContext()
@@ -86,11 +94,6 @@ public struct ObjectSnapshot<O: DynamicObject>: ObjectRepresentation, Hashable {
let context = transaction.unsafeContext()
return ObjectSnapshot<O>(objectID: self.id, context: context)
}
public func cs_dataStack() -> DataStack? {
return self.context.parentStack
}
// MARK: Equatable