LinkedInAttic / LayoutKit

LayoutKit is a fast view layout library for iOS, macOS, and tvOS.
http://layoutkit.org
Apache License 2.0
3.16k stars 267 forks source link

Fixing async issue on completion callback for perform batch updates #158

Closed e-liu closed 7 years ago

e-liu commented 7 years ago

Currently the completion callback when performing a reload with batch updates is being called prematurely because performing batch updates happens asynchronously on the animation thread. We should use the completion block provided by performBatchUpdates(:) instead

nicksnyder commented 7 years ago

You need to update the tests. They are failing.

e-liu commented 7 years ago

Fixing

e-liu commented 7 years ago

@nicksnyder I moved the pendingInsertedIndexPaths.removeAll() in flushPendingInserts call back outside of the completion block. It seems like calling it directly after calling reload and not waiting until completion is the right thing to do, is this correct?

nicksnyder commented 7 years ago

@e-liu yes, that makes sense to me. We handle them synchronously by queueing up the animation. We don't need to wait for the animation to finish before considering them handled.