Skip to content

Commit

Permalink
Rename: updatingDelegate -> updater
Browse files Browse the repository at this point in the history
  • Loading branch information
Adlai Holler committed Jan 3, 2017
1 parent 393fd47 commit bf24f58
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions Source/IGListAdapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ IGLK_SUBCLASSING_RESTRICTED
/**
The updater that this list adapter was created with.
*/
@property (nonatomic, strong, readonly) id <IGListUpdatingDelegate> updatingDelegate;
@property (nonatomic, strong, readonly) id <IGListUpdatingDelegate> updater;

/**
A bitmask of experiments to conduct on the adapter.
Expand All @@ -86,7 +86,7 @@ IGLK_SUBCLASSING_RESTRICTED
/**
Initializes a new `IGListAdapter` object.
@param updatingDelegate An object that manages updates to the collection view.
@param updater An object that manages updates to the collection view.
@param viewController The view controller that will house the adapter.
@param workingRangeSize The number of objects before and after the viewport to consider within the working range.
Expand All @@ -99,7 +99,7 @@ IGLK_SUBCLASSING_RESTRICTED
To opt out of using the working range, you can provide a value of `0`.
*/
- (instancetype)initWithUpdater:(id <IGListUpdatingDelegate>)updatingDelegate
- (instancetype)initWithUpdater:(id <IGListUpdatingDelegate>)updater
viewController:(nullable UIViewController *)viewController
workingRangeSize:(NSInteger)workingRangeSize NS_DESIGNATED_INITIALIZER;

Expand Down
24 changes: 12 additions & 12 deletions Source/IGListAdapter.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ - (void)dealloc {

#pragma mark - Init

- (instancetype)initWithUpdater:(id <IGListUpdatingDelegate>)updatingDelegate
- (instancetype)initWithUpdater:(id <IGListUpdatingDelegate>)updater
viewController:(UIViewController *)viewController
workingRangeSize:(NSInteger)workingRangeSize {
IGAssertMainThread();
IGParameterAssert(updatingDelegate);
IGParameterAssert(updater);

if (self = [super init]) {
NSPointerFunctions *keyFunctions = [updatingDelegate objectLookupPointerFunctions];
NSPointerFunctions *keyFunctions = [updater objectLookupPointerFunctions];
NSPointerFunctions *valueFunctions = [NSPointerFunctions pointerFunctionsWithOptions:NSPointerFunctionsStrongMemory];
NSMapTable *table = [[NSMapTable alloc] initWithKeyPointerFunctions:keyFunctions valuePointerFunctions:valueFunctions capacity:0];
_sectionMap = [[IGListSectionMap alloc] initWithMapTable:table];
Expand All @@ -52,7 +52,7 @@ - (instancetype)initWithUpdater:(id <IGListUpdatingDelegate>)updatingDelegate
_cellSectionControllerMap = [NSMapTable mapTableWithKeyOptions:NSMapTableObjectPointerPersonality | NSMapTableStrongMemory
valueOptions:NSMapTableStrongMemory];

_updatingDelegate = updatingDelegate;
_updater = updater;
_viewController = viewController;
}
return self;
Expand Down Expand Up @@ -259,7 +259,7 @@ - (void)performUpdatesAnimated:(BOOL)animated completion:(IGListUpdaterCompletio
NSArray *newItems = [[dataSource objectsForListAdapter:self] copy];

__weak __typeof__(self) weakSelf = self;
[self.updatingDelegate performUpdateWithCollectionView:collectionView
[self.updater performUpdateWithCollectionView:collectionView
fromObjects:fromObjects
toObjects:newItems
animated:animated
Expand Down Expand Up @@ -294,7 +294,7 @@ - (void)reloadDataWithCompletion:(nullable IGListUpdaterCompletion)completion {
NSArray *newItems = [[dataSource objectsForListAdapter:self] copy];

__weak __typeof__(self) weakSelf = self;
[self.updatingDelegate reloadDataWithCollectionView:collectionView reloadUpdateBlock:^{
[self.updater reloadDataWithCollectionView:collectionView reloadUpdateBlock:^{
// purge all section controllers from the item map so that they are regenerated
[weakSelf.sectionMap reset];
[weakSelf updateObjects:newItems dataSource:dataSource];
Expand Down Expand Up @@ -329,7 +329,7 @@ - (void)reloadObjects:(NSArray *)objects {
UICollectionView *collectionView = self.collectionView;
IGAssert(collectionView != nil, @"Tried to reload the adapter without a collection view");

[self.updatingDelegate reloadCollectionView:collectionView sections:sections];
[self.updater reloadCollectionView:collectionView sections:sections];
}


Expand Down Expand Up @@ -917,7 +917,7 @@ - (void)reloadInSectionController:(IGListSectionController<IGListSectionType> *)
[self insertInSectionController:sectionController atIndexes:indexes];
} else {
NSArray *indexPaths = [self indexPathsFromSectionController:sectionController indexes:indexes adjustForUpdateBlock:YES];
[self.updatingDelegate reloadItemsInCollectionView:collectionView indexPaths:indexPaths];
[self.updater reloadItemsInCollectionView:collectionView indexPaths:indexPaths];
}
}

Expand All @@ -933,7 +933,7 @@ - (void)insertInSectionController:(IGListSectionController<IGListSectionType> *)
}

NSArray *indexPaths = [self indexPathsFromSectionController:sectionController indexes:indexes adjustForUpdateBlock:NO];
[self.updatingDelegate insertItemsIntoCollectionView:collectionView indexPaths:indexPaths];
[self.updater insertItemsIntoCollectionView:collectionView indexPaths:indexPaths];
}

- (void)deleteInSectionController:(IGListSectionController<IGListSectionType> *)sectionController atIndexes:(NSIndexSet *)indexes {
Expand All @@ -948,7 +948,7 @@ - (void)deleteInSectionController:(IGListSectionController<IGListSectionType> *)
}

NSArray *indexPaths = [self indexPathsFromSectionController:sectionController indexes:indexes adjustForUpdateBlock:YES];
[self.updatingDelegate deleteItemsFromCollectionView:collectionView indexPaths:indexPaths];
[self.updater deleteItemsFromCollectionView:collectionView indexPaths:indexPaths];
}

- (void)reloadSectionController:(IGListSectionController <IGListSectionType> *)sectionController {
Expand All @@ -964,7 +964,7 @@ - (void)reloadSectionController:(IGListSectionController <IGListSectionType> *)s
}

NSIndexSet *sections = [NSIndexSet indexSetWithIndex:section];
[self.updatingDelegate reloadCollectionView:collectionView sections:sections];
[self.updater reloadCollectionView:collectionView sections:sections];
}

- (void)performBatchAnimated:(BOOL)animated updates:(void (^)())updates completion:(void (^)(BOOL))completion {
Expand All @@ -974,7 +974,7 @@ - (void)performBatchAnimated:(BOOL)animated updates:(void (^)())updates completi
IGAssert(collectionView != nil, @"Performing batch updates without a collection view.");

__weak __typeof__(self) weakSelf = self;
[self.updatingDelegate performUpdateWithCollectionView:collectionView animated:animated itemUpdates:^{
[self.updater performUpdateWithCollectionView:collectionView animated:animated itemUpdates:^{
weakSelf.isInUpdateBlock = YES;
updates();
weakSelf.isInUpdateBlock = NO;
Expand Down
2 changes: 1 addition & 1 deletion Source/Internal/IGListAdapterInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ IGListCollectionContext
__weak UICollectionView *_collectionView;
}

@property (nonatomic, strong) id <IGListUpdatingDelegate> updatingDelegate;
@property (nonatomic, strong) id <IGListUpdatingDelegate> updater;

@property (nonatomic, strong, readonly) IGListSectionMap *sectionMap;
@property (nonatomic, strong, readonly) IGListDisplayHandler *displayHandler;
Expand Down
8 changes: 4 additions & 4 deletions Tests/IGListAdapterTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ - (void)test_whenSectionControllerReloading_withEmptyIndexes_thatNoUpdatesHappen

id mockDelegate = [OCMockObject mockForProtocol:@protocol(IGListUpdatingDelegate)];
[[mockDelegate reject] reloadItemsInCollectionView:[OCMArg any] indexPaths:[OCMArg any]];
self.adapter.updatingDelegate = mockDelegate;
self.adapter.updater = mockDelegate;

id sectionController = [self.adapter sectionControllerForObject:@1];
[self.adapter reloadInSectionController:sectionController atIndexes:[NSIndexSet new]];
Expand All @@ -718,7 +718,7 @@ - (void)test_whenSectionControllerDeleting_withEmptyIndexes_thatNoUpdatesHappen

id mockDelegate = [OCMockObject mockForProtocol:@protocol(IGListUpdatingDelegate)];
[[mockDelegate reject] deleteItemsFromCollectionView:[OCMArg any] indexPaths:[OCMArg any]];
self.adapter.updatingDelegate = mockDelegate;
self.adapter.updater = mockDelegate;

id sectionController = [self.adapter sectionControllerForObject:@1];
[self.adapter deleteInSectionController:sectionController atIndexes:[NSIndexSet new]];
Expand All @@ -732,7 +732,7 @@ - (void)test_whenSectionControllerInserting_withEmptyIndexes_thatNoUpdatesHappen

id mockDelegate = [OCMockObject mockForProtocol:@protocol(IGListUpdatingDelegate)];
[[mockDelegate reject] insertItemsIntoCollectionView:[OCMArg any] indexPaths:[OCMArg any]];
self.adapter.updatingDelegate = mockDelegate;
self.adapter.updater = mockDelegate;

id sectionController = [self.adapter sectionControllerForObject:@1];
[self.adapter insertInSectionController:sectionController atIndexes:[NSIndexSet new]];
Expand All @@ -746,7 +746,7 @@ - (void)test_whenReloading_withSectionControllerNotFound_thatNoUpdatesHappen {

id mockDelegate = [OCMockObject mockForProtocol:@protocol(IGListUpdatingDelegate)];
[[mockDelegate reject] reloadCollectionView:[OCMArg any] sections:[OCMArg any]];
self.adapter.updatingDelegate = mockDelegate;
self.adapter.updater = mockDelegate;

id sectionController = [IGListSectionController new];
[self.adapter reloadSectionController:sectionController];
Expand Down

0 comments on commit bf24f58

Please sign in to comment.