Handling Updates When Table Is Out of View
We have a case where a table view is subscribed to a publisher that is continuously updated when the app is running.
When pushing a view controller on top the one the table is in (in a navigation stack), it will generate warnings and glitch because it's updated while being out of view.
Per https://forums.developer.apple.com/thread/120790, it seems to be because of animations.
I tried simple stuff like cancelling the subscription on viewDidDisappear and adding it again in viewWillAppear, and filtering the updates by checking if the table has a window (a suggested solution in the linked thread). Both seem to work but have pretty serious drawbacks and won't fix the problem completely.
Is this something that should be handled within the framework? Fixing it completely will cause so much boilerplate with CombineDataSources that it starts to lose its elegance.
This is what diffable data sources are designed to solve. When the view goes off screen the changes are ignored and when it returns to the window (willAppear) a snapshot of the data is created and applied to the view (without animation when view.window == nil) bringing it up to date. This has a major advantage over reloadData that the selection is maintained. So yes the framework could be improved to use diffable data source instead of the old perform batch update APIs but you would likely need to add/remove the combine yourself in willAppear and didDisappear.