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

Adds the ability to integrate with collection/table view prefetch #161

Closed
wants to merge 1 commit into from

Conversation

g-Off
Copy link
Contributor

@g-Off g-Off commented Apr 18, 2019

Prefetch operations are requested from CellActions and executed in a private OperationQueue. The actual fetching/cancelling is delayed by a short period of time because iOS may trigger rapid fetch/cancel operations and this is an attempt to reduce the amount of fetch/cancel/fetch of the same IndexPath

This PR introduces a common prefetch data source that's usable by both collection and tableview's. They essentially have the same delegate methods, just passing in a UICollectionView in one and a UITableView in the other. Object conforms to both, takes advantage of the same mechanism for queueing and dequeuing operations/cancelling/etc.

This resolves #152

Copy link
Contributor

@raulriera raulriera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like testBackground crashed. but this looks great!

}

private extension NSLocking {
func withLock<T> (_ body: () throws -> T) rethrows -> T {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was wondering about this withLock. I t thought it was a new thing in iOS


private func section(withPrefetch prefetchAction: @escaping CellActions.PrefetchAction) -> TableSection {
let actions = CellActions(prefetchAction: prefetchAction)
let cell = HostCell<UIView, String, LayoutMarginsTableItemLayout>(key: "prefetch-cell", actions: actions, state: "Actions") { (_, _) in }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure we have some TestCell or something out there

Prefetch operations are requested from CellActions and executed in a private OperationQueue. The actual fetching/cancelling is delayed by a short period of time because iOS may trigger rapid fetch/cancel operations and this is an attempt to reduce the amount of fetch/cancel/fetch of the same IndexPath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for UITableView and UICollectionView prefetch data source
2 participants