Skip to content
This repository was archived by the owner on Jun 17, 2023. It is now read-only.

Commit bc2a2bb

Browse files
committed
Remove unneeded DispatchQueue.main.async
1 parent e364ee1 commit bc2a2bb

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

Lib/CollectionViewPagingLayout.swift

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,9 @@ public class CollectionViewPagingLayout: UICollectionViewLayout {
222222

223223
// this is necessary when we want to set the current page without animation
224224
if !animated, page != currentPage, let collectionView = collectionView {
225-
DispatchQueue.main.async {
226-
collectionView.performBatchUpdates({
227-
collectionView.collectionViewLayout.invalidateLayout()
228-
})
229-
}
225+
collectionView.performBatchUpdates({
226+
collectionView.collectionViewLayout.invalidateLayout()
227+
})
230228
}
231229
}
232230

Samples/PagingLayoutSamples/Modules/Shapes/ShapesViewController.swift

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,19 +156,15 @@ class ShapesViewController: UIViewController, NibBased, ViewModelBased {
156156
}
157157

158158
private func invalidateLayoutTypeCollectionViewLayout() {
159-
DispatchQueue.main.async { [weak self] in
160-
self?.layoutTypeCollectionView?.performBatchUpdates({ [weak self] in
161-
self?.layoutTypeCollectionView?.collectionViewLayout.invalidateLayout()
162-
})
163-
}
159+
layoutTypeCollectionView?.performBatchUpdates({ [weak self] in
160+
self?.layoutTypeCollectionView?.collectionViewLayout.invalidateLayout()
161+
})
164162
}
165163

166164
private func invalidateCollectionViewLayout() {
167-
DispatchQueue.main.async { [weak self] in
168-
self?.collectionView?.performBatchUpdates({ [weak self] in
169-
self?.collectionView?.collectionViewLayout.invalidateLayout()
170-
})
171-
}
165+
collectionView?.performBatchUpdates({ [weak self] in
166+
self?.collectionView?.collectionViewLayout.invalidateLayout()
167+
})
172168
}
173169

174170
private func getPagingLayout(_ collectionView: UICollectionView) -> CollectionViewPagingLayout? {

0 commit comments

Comments
 (0)