Slide 23
Slide 23 text
let options: SaladaOptions = SaladaOptions()
options.limit = 10
options.ascending = false
self.datasource = DataSource(parentKey: userID,
referenceKey: "feedIDs",
options: options,
block: { [weak self](changes) in
guard let tableView: UITableView = self?.tableView else { return }
switch changes {
case .initial:
tableView.reloadData()
case .update(let deletions, let insertions, let modifications):
tableView.beginUpdates()
tableView.insertRows(at: insertions.map { IndexPath(item: 0, section: $0) }, with: .automatic)
tableView.deleteRows(at: deletions.map { IndexPath(item: 0, section: $0) }, with: .automatic)
tableView.reloadRows(at: modifications.map { IndexPath(item: 0, section: $0) }, with: .automatic
tableView.insertSections(IndexSet(insertions), with: .automatic)
tableView.deleteSections(IndexSet(deletions), with: .automatic)
tableView.reloadSections(IndexSet(modifications), with: .automatic)
tableView.endUpdates()
case .error(let error):
print(error)
}
})