README and documentationIGListKit version: 3.0My use case:
I essentially have 2 feeds (Feed 1 & Feed 2) however each feed has some common sections and I want transition smoothly between them. In order to do this I am using the same collectionView and same listAdapter for both of them. I pass reference and reuse the adapter from Feed 1 to Feed 2, all I do is set the adapter's dataSource = Feed 2. However, when I do this, the adapter resets the sectionMap which is unfortunate because the next time I call performBatchUpdates with the data from Feed 2 it crashes with NSInternalInconsistencyException (Wrong number of sections before/after), because the sectionMap no longer carries the data from the previous feed.
I've created a fix for this, but not sure if this jives well with Instagram's use case:
- (void)setDataSource:(id<IGListAdapterDataSource>)dataSource {
if (_dataSource != dataSource) {
BOOL shouldUpdate = false;
if (_dataSource == nil) {
shouldUpdate = true;
}
_dataSource = dataSource;
if(shouldUpdate) {
[self updateAfterPublicSettingsChange];
}
}
}
This only resets the section map if the dataSource was nil before.
What do you think?
@yusufoos I wouldn't change the data source, IGListAdapter isn't designed to do that, as you'd discovered. Your patch could work, but I'm not sure it's something we want to encourage.
Why can't you have a single data source and _within_ the data source fork between two sources that return stuff for objects(for listAdapter:)?
I'm also curious what separating data sources unlocks for you? Are you reusing the data sources elsewhere?
@rnystrom ahh you are right, I can create a higher level object and swap between my two sources pretty easily...
Most helpful comment
@rnystrom ahh you are right, I can create a higher level object and swap between my two sources pretty easily...