Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefetching events never triggered both for CollectionDirector and TableDirector #34

Closed
zdnk opened this issue Aug 25, 2019 · 1 comment
Assignees
Labels
bug Something isn't working
Milestone

Comments

@zdnk
Copy link
Contributor

zdnk commented Aug 25, 2019

Hello,

I see theres some implementation for prefetching API in CollectionDirector however the events are not triggered at all.

Setting I tried:

        let director = FlowCollectionDirector(collection: collectionView, flowLayout: layout)
        collectionView.prefetchDataSource = director
        collectionView.isPrefetchingEnabled = true

        let adapter = CollectionCellAdapter<ProductItemViewModel, RProductCell> { adapter in
            adapter.events.dequeue = { context in
                guard let cell = context.cell else {
                    return
                }
                
                cell.configure(with: context.element)
            }
            
            adapter.events.prefetch = { (items, indexes) in
                print("$$$$ prefetching")
                items.forEach { $0.loadIfNeeded() }
            }
            
            adapter.events.itemSize = { _ in
                let dim = (self.view.bounds.width - (16 + 16 + 10)) / 2
                return CGSize(width: dim, height: 338)
            }
        }
        
        director.registerAdapter(adapter)
        
        return director
@malcommac malcommac changed the title Prefetching Prefetching events never triggered both for CollectionDirector and TableDirector Sep 15, 2019
@malcommac
Copy link
Owner

Fixed!
Now you can enable prefetching events by setting the isPrefetchingEnabled = true in your CollectionDirector or TableDirector.

@malcommac malcommac self-assigned this Sep 15, 2019
@malcommac malcommac added the bug Something isn't working label Sep 15, 2019
@malcommac malcommac added this to the 1.1.0 milestone Sep 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants