WIP: ObjectRepresentable utilities

This commit is contained in:
John Estropia committed 2019-10-14 21:36:03 +09:00
1 parent f5a165d47d
commit 6b64eb7650
17 files changed
+315 -198

No files matched your search

@@ -116,12 +116,16 @@ extension Internals {
@objc
dynamic func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
var snapshot = Internals.DiffableDataSourceSnapshot(
sections: controller.sections ?? []
)
snapshot.reloadItems(self.reloadedIDs)
self.handler?.controller(
controller,
didChangeContentWith: Internals.DiffableDataSourceSnapshot(
sections: controller.sections ?? []
)
didChangeContentWith: snapshot
)
self.reloadedIDs.removeAll()
}
@objc
@@ -132,5 +136,17 @@ extension Internals {
sectionIndexTitleForSectionName: sectionName
)
}
@objc
dynamic func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {
let object = anObject as! NSManagedObject
self.reloadedIDs.append(object.objectID)
}
// MARK: Private
private var reloadedIDs: [NSManagedObjectID] = []
}
}