WIP: ObjectRepresentable utilities

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

View File

@@ -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] = []
}
}