Allow purging of datasource

This commit is contained in:
John Estropia committed 2019-12-17 21:10:01 +09:00
1 parent eef1c99f11
commit 57745f36a8
7 files changed
+86 -41

No files matched your search

+8 -2
View File
@@ -83,7 +83,10 @@ public struct ListSnapshot<O: DynamicObject>: RandomAccessCollection, Hashable {
*/
public subscript(safeIndex index: Index) -> ObjectPublisher<O>? {
let context = self.context!
guard let context = self.context else {
return nil
}
let itemIDs = self.diffableSnapshot.itemIdentifiers
guard itemIDs.indices.contains(index) else {
@@ -118,7 +121,10 @@ public struct ListSnapshot<O: DynamicObject>: RandomAccessCollection, Hashable {
*/
public subscript(safeSectionIndex sectionIndex: Int, safeItemIndex itemIndex: Int) -> ObjectPublisher<O>? {
let context = self.context!
guard let context = self.context else {
return nil
}
let snapshot = self.diffableSnapshot
let sectionIDs = snapshot.sectionIdentifiers
guard sectionIDs.indices.contains(sectionIndex) else {