Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

[ASCollectionView] Add Method to Wait for Updates During Next Layout Pass #2186

Closed
wants to merge 4 commits into from

Conversation

Adlai-Holler
Copy link
Contributor

@Adlai-Holler Adlai-Holler commented Sep 3, 2016

During the normal flow, the initial data is loaded during the first layout pass. This adds a flag for the user to tell us "when the next layout pass happens, block the main thread until the data is up-to-date".

  • Simplifies our ASCollectionView testing setup by combining ASCollectionViewTestController and ASCollectionViewTestDelegate into just the controller.
  • Fixes an issue where waitUntilAllUpdatesAreCommitted fails if the initial reload hasn't been performed yet.
  • Minor: makes reloadData only be callable on the main thread for ASCollectionView. It's a pretty small API change, since all of our other editing operations are already required to be on the main thread. It was already required for table view.

Resolves #1584 and essentially #1642 also.

Ready for review!

@ghost ghost added the CLA Signed label Sep 3, 2016
@Adlai-Holler Adlai-Holler changed the title [ASCollectionView] Add Flag to Wait for Initial Data Load [ASCollectionView] Add Method to Wait for Updates During Next Layout Pass Sep 3, 2016
@ghost ghost added the CLA Signed label Sep 3, 2016
@Adlai-Holler
Copy link
Contributor Author

@maicki @levi @appleguy thoughts? It'll be important to raise the visibility of this option because it's very important. We may even want to connect it to ASViewController's neverShowPlaceholders flag since this is part of that.

@ghost ghost added the CLA Signed label Sep 8, 2016
@ghost ghost added the CLA Signed label Sep 27, 2016
- (void)waitForUpdatesDuringNextLayoutPass
{
ASDisplayNodeAssertMainThread();
[self setNeedsLayout];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Adlai-Holler should this actually set a new layout pass as being needed? The name doesn't currently imply that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're absolutely right – that was a holdover from some previous implementation I believe. Removed.

@ghost ghost added the CLA Signed label Sep 27, 2016
@Adlai-Holler
Copy link
Contributor Author

Ready for next review @maicki @appleguy @garrettmoon

@maicki
Copy link
Contributor

maicki commented Sep 28, 2016

LGTM

* main thread and wait for all items to be up-to-date.
*
* @discussion This is useful when you want to ensure that the user never sees an empty
* collection view. It is better to call this than to explicitly wait using `waitUntilAllUpdatesAreCommitted`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a @warning in the waitUntilAllUpdatesAreCommitted method indicating they might want to use this method instead?

@Adlai-Holler
Copy link
Contributor Author

This will be changed so much in light of the 2.0 ASCollectionView/ASTableView -> Node diff that it may as well be closed. Sayonara.

@Adlai-Holler Adlai-Holler deleted the AHWaitForInitialData branch January 20, 2017 01:09
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants