Open qhhonx opened 6 years ago
Great question!! You can still use the working range with a binding section controller. Just set self
as the working range delegate in init (alongside setting the data source) and you can implement the prefetch APIs as you see fit.
Now the only thing is you can’t have a per item prefetch event.
I’d recommend architecting a profile-type list with separate section controllers for each grid item. You can use our IGListCollectionViewLayout
to do this! In fact, that’s exactly how we do it in Instagram 😄
Sent with GitHawk
It is a feasible solution, but I think maybe it sounds tricky from a certain perspective.
As we known that IGListBindingSectionController
is lightweight of IGListAdapter
consisting of some IGListSectionController
s. It provides powerful IGListBindable
so that we fully take advantage of MVVM architecture which can be integrated easily. Apart from its binding technique, It is natural that IGListBindingSectionController
is used to display grid-items and ease to reuse not just single-item GridSectionController. I think IGListBindingSectionController
can be adopt in many situations if we give it more capabilities like work-range as many as IGListAdapter
already have.
So, if it is available I can try to contribute it.
Would be happy for the contribution! Might want a bit of a proposal written up at first though so that I can totally make sense of it.
Even for implementing grids, we recommend sticking to a single section controller per grid item so that you can fully encapsulate your data + business logic in the section controller. You can still enjoy all the benefits of MVVM w/ that design too!
@rnystrom I'm trying to implement a binding section controller with a working range as well but I couldn't figure it out how to prefetch each section controller. In my case its not a grid, its a feed with items similar to the binding section controller example.
@rnystrom could you please elaborate a little on using a dedicated section controller per grid item? What do you think would be a a good way of implementing inter-item and line spacing for the entire grid in this case? How do you usually implement "line breaks" for grid item lines and what would be a good approach to somehow incapsulating a "whole grid behaviour" logic, like, showing a spinner in place of the grid during a fetch or collapsing/expanding content sections? Do you use some sort of SectionSectionController
objects to manage, well, "logical" or content sections consisting of several UICollectionView
sections? I understand that ListKit is mostly about the presentation/"view" part of the MVC and my questions are probably out of scope, still an advice would be much appreciated.
New issue checklist
README
and documentationUICollectionView introduced
prefetchDataSource
in iOS10 that we can ease to do preparing stuffs like image-loading for incoming display cells.IGListKit disabled the builtin prefetching functionality due to performance, while it provides work range mechanism for prefetching. It works for sections based adapter like in Instagram main feed in which we place PostSectionControllers, but sucks in Instagram profile feed in which we probably use one IGListBindingSectionController to show user's all photos and one ProfileSectionController to show user's information. If implement it like this, we loose work-range feature to do prefetch jobs because there are only two objects (sections): user-info model and user-array-photos model.
So, does IGListKit consider to add prefetching functionality to IGListBindingSectionController?