Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling Updates When Table Is Out of View #10

Open
myyra opened this issue May 5, 2020 · 1 comment
Open

Handling Updates When Table Is Out of View #10

myyra opened this issue May 5, 2020 · 1 comment

Comments

@myyra
Copy link

myyra commented May 5, 2020

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.

@malhal
Copy link

malhal commented Jul 17, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants