add utility to create ObjectPublisher directly from a DynamicObject using its own context

This commit is contained in:
John Estropia
2019-12-02 12:21:06 +09:00
parent 3e2d62fe67
commit 9a19919392

View File

@@ -77,6 +77,16 @@ extension DynamicObject where Self: ObjectRepresentation {
// MARK: Public
/**
An `ObjectPublisher` wrapper for the exact same object
*/
public func asPublisher() -> ObjectPublisher<Self>? {
return self.cs_toRaw()
.managedObjectContext
.map({ $0.objectPublisher(objectID: self.cs_id()) })
}
/**
A thread-safe `struct` that is a full-copy of the object's properties
*/