镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Handling Updates When Table Is Out of View #10

Open

Description

@myyra

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.

Activity

  1. malhal commented on Jul 17, 2020

    @malhal

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions