SDK Setup Guides
...
Swift
Quick Tips for Swift
Animating UITableView with the Observe API
The Ditto observe callback will fire for any changes to the underlying query. These changes can happen from your own device or a replication. There are two parameters for the callback handler, the current snapshot of documents and an event that gives a bit more information about how snapshots evolve after subsequent calls.
The event parameter gives you information about how the live query has evolved from callback fire. It can tell you which document indices were inserted, updated, moved, or removed. The following example below shows a common pattern to parse the event parameter and apply tableView.performBatchUpdates using the indexes.
The following code snippet assumes that you only have one UITableView section.
Updated 11 Mar 2024
Did this page help you?