Created
November 29, 2020 20:17
-
-
Save eilonkr/6097adb950a4206b80465053e0a31930 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func update() { | |
var snapshot = NSDiffableDataSourceSnapshot<Section, Item>() | |
snapshot.appendSections([.main]) | |
snapshot.appendItems(items.value) | |
dataSource?.apply(snapshot) | |
} | |
public func add(_ items: [Item]) { | |
items.forEach { | |
self.items.value.append($0) | |
} | |
update() | |
} | |
public func remove(_ items: [Item]) { | |
items.forEach { item in | |
self.items.value.removeAll { $0 == item } | |
} | |
update() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment