Если я понимаю ваш вопрос, вы можете найти ответ в Документация Firebase .
// Listen for new comments in the Firebase database
commentsRef.observe(.childAdded, with: { (snapshot) -> Void in
self.comments.append(snapshot)
self.tableView.insertRows(at: [IndexPath(row: self.comments.count-1, section: self.kSectionComments)], with: UITableViewRowAnimation.automatic)
})
// Listen for deleted comments in the Firebase database
commentsRef.observe(.childRemoved, with: { (snapshot) -> Void in
let index = self.indexOfMessage(snapshot)
self.comments.remove(at: index)
self.tableView.deleteRows(at: [IndexPath(row: index, section: self.kSectionComments)], with: UITableViewRowAnimation.automatic)
})
И вы можете использовать commentsRef.observe(.childChanged, .....)
также