This was possible because the view controller used to be observing the live query directly, instead of using the Ditto manager design pattern, so it knows the newCount value that shows what the new value in the Ditto Document is.
We decided not to handle Ditto events in view controllers directly and separate view code and ditto code.
Current code:
After the live query callback catches value changes, the table view's delegate method is triggered by reloadRows(at:):
This way is slower because the tableView cellForRowAt delegate method won't be called instantly after reloadRows(at:).
How to fix it?
The new counter values are not being passed to the view controller directly now.
Should we pass them through the current Passthrough object?
Should we observe the live query in the view controller and receives the callback events directly, so that the view controller has all the information about updates?
What is this?
Where is the problem?
Before the refactoring:
newCount
value that shows what the new value in the Ditto Document is.Current code:
reloadRows(at:)
:tableView cellForRowAt
delegate method won't be called instantly afterreloadRows(at:)
.How to fix it?