jessesquires / jessesquires/ReactiveCollectionsKit

[DataSource] implement prefetching

Open
#18 0 comments 0 reactions 0 assignees View on GitHub
difficulty: hard feature request
Dominant language
Swift
Stars
194
Forks
12
PR merge metrics
No merged PRs in 30d

Description

### Discussion

Initial thoughts:

- Create a new `DataPrefetchAdapter` class that conforms to `UICollectionViewDataSourcePrefetching`
- This should map the prefetch API index paths to identifiers
- Tell the client "preload these identifiers"
- Maybe have clients pass in closures or something?
- Pass this object into `CollectionViewDriver` and hook it up to the `collectionView.prefetchDataSource`
- Allow client to provide a prefetching queue

### Potential problems

- `CollectionViewModel` is designed to be stateless, so maybe this just doesn't make sense?
- When prefetching operations complete, we need a way to say "ok, now update the collection view."
- Would this involve needed to regenerate the `CollectionViewModel`? Would `CellViewModel` instances be mutable?

### Docs

- https://developer.apple.com/documentation/uikit/uicollectionviewdatasourceprefetching
- https://developer.apple.com/documentation/uikit/uicollectionview/1771768-prefetchdatasource

### Sample Code

- [Prefetching collection view data](https://developer.apple.com/documentation/uikit/uicollectionviewdatasourceprefetching/prefetching_collection_view_data)
- [Building High-Performance Lists and Collection Views](https://developer.apple.com/documentation/uikit/uiimage/building_high-performance_lists_and_collection_views)

This sample code is pretty interesting. They use `NSOperationQueue` or `DispatchQueue`. There's lots of boilerplate there that we should attempt to encapsulate. Clients can give us a queue, or we can maintain our own.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.