Skip to content

Instantly share code, notes, and snippets.

@eilonkr
Created November 29, 2020 20:17
Show Gist options
  • Save eilonkr/6097adb950a4206b80465053e0a31930 to your computer and use it in GitHub Desktop.
Save eilonkr/6097adb950a4206b80465053e0a31930 to your computer and use it in GitHub Desktop.
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