Open lohenyumnam opened 4 years ago
@lohenyumnam the default is 2 screens for batching.
Unless you say collectionNode.leadingScreensForBatching = 0
, it'll pre-fetch 2 screens before the end.
@varyP Ya I did try setting collectionNode.leadingScreensForBatching = 0
too but no effect, beginBatchFetch keep firing like crazy.
But I notice something, as I am using it with IGListKit
and my layout is two column grid. I am stuck with ListCollectionViewLayout
. But if I change the layout to UICollectionViewFlowLayout
collectionNode.leadingScreensForBatching = 0
seems to work but not with ListCollectionViewLayout
. I think something is missing in ListCollectionViewLayout
.
@lohenyumnam , try this
override func didLoad() { super.didLoad() collectionNode.leadingScreensForBatching = 0 }
@varyP when I put collectionNode.leadingScreensForBatching = 0
inside the didLoad()
method, the IGlistKit's ASSectionController's func beginBatchFetch(with context: ASBatchContext)
or willBeginBatchFetchWithContext of Collection ASCollectionNode never got fired. I even tried setting ASCollection's delegate
to self.
For Now my current Solution is:
let currentVisibleCellSection = self.collectionNode.indexPathsForVisibleItems.last?.section ?? 0
let distance = self.loader.usersOfExploreGrid.count - currentVisibleCellSection
if distance < 25 {
self.fetchUsers()
} else {
context.completeBatchFetching(true)
}
I manually check if the current visible cell is really near the end of data. so I took the last visibleCell Indexpath's section and check agaist the count of data from the loader if the count is really low it means the cell is near the end and need to fetch more data.
when I put
collectionNode.leadingScreensForBatching = 0
inside thedidLoad()
method, the IGlistKit's ASSectionController'sfunc beginBatchFetch(with context: ASBatchContext)
or willBeginBatchFetchWithContext of Collection ASCollectionNode never got fired. I even tried settingASCollection's delegate
to self.
I thought that's what you wanted, setting it to 0
would mean that you don't want it to be called.
How about try 0.25, since it's a CGFloat. But remember to call it in didLoad.
@varyP Thanks for the advice, but its seems the problem is with ListCollectionViewLayout
when ever I set leadingScreensForBatching
any value greater then 0
batchFetch
firing won't stop. but I noticed that when CollectionNode is scrolling it stop firing.
Version: 2.8 Xcode: 10.3
Problem:
I am using ASColllectionNode with IGListKit, on SectionController which I have implemented using
ASSectionController
andListSectionController
has abeginBatchFetch
Method. which keep firing even when I am no way near the end. is this normal or am I doing something wrong.Here is the sample of my SectionController