Make -[IGListBindingSectionController object] Public

Summary:
Issue fixed: #572

I didn't add an entry into `CHANGELOG` since the entire component is new. I've been doing some proof-of-concepts for IGListBindingSectionController + AsyncDisplayKit in Pinterest and it's working like a charm!
Closes https://github.com/Instagram/IGListKit/pull/602

Reviewed By: rnystrom

Differential Revision: D4812758

Pulled By: jessesquires

fbshipit-source-id: 9c23f32882cb99f6539ab45dec0e76a274c64370
This commit is contained in:
Adlai Holler 2017-03-31 14:57:53 -07:00 committed by Facebook Github Bot
parent 2284ce3897
commit e9e09d726c
2 changed files with 11 additions and 2 deletions

View file

@ -47,7 +47,7 @@ NS_ASSUME_NONNULL_BEGIN
Only when `-diffIdentifier`s match is object equality compared, so you can assume the class is the same, and the
instance has already been checked.
*/
@interface IGListBindingSectionController : IGListSectionController<IGListSectionType>
@interface IGListBindingSectionController<__covariant ObjectType : id<IGListDiffable>> : IGListSectionController<IGListSectionType>
/**
A data source that transforms a top-level object into view models, and returns cells and sizes for given view models.
@ -59,6 +59,11 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (nonatomic, weak, nullable) id<IGListBindingSectionControllerSelectionDelegate> selectionDelegate;
/**
The object currently assigned to the section controller, if any.
*/
@property (nonatomic, strong, readonly, nullable) ObjectType object;
/**
The array of view models created from the data source. Values are changed when the top-level object changes or by
calling `-updateAnimated:completion:` manually.

View file

@ -54,7 +54,11 @@ typedef NS_ENUM(NSInteger, IGListDiffingSectionState) {
}
oldViewModels = self.viewModels;
self.viewModels = [self.dataSource sectionController:self viewModelsForObject:self.object];
id<IGListDiffable> object = self.object;
IGAssert(object != nil, @"Expected IGListBindingSectionController object to be non-nil before updating.");
self.viewModels = [self.dataSource sectionController:self viewModelsForObject:object];
result = IGListDiff(oldViewModels, self.viewModels, IGListDiffEquality);
[result.updates enumerateIndexesUsingBlock:^(NSUInteger oldUpdatedIndex, BOOL *stop) {