File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 7070 */
7171@property (nonatomic , assign ) CGFloat leadingScreensForBatching;
7272
73+ /* *
74+ * Reload everything from scratch, destroying the working range and all cached nodes.
75+ *
76+ * @param completion block to run on completion of asynchronous loading or nil. If supplied, the block is run on
77+ * the main thread.
78+ * @warning This method is substantially more expensive than UICollectionView's version.
79+ */
80+ - (void )reloadDataWithCompletion : (void (^)())completion ;
81+
7382/* *
7483 * Reload everything from scratch, destroying the working range and all cached nodes.
7584 *
Original file line number Diff line number Diff line change @@ -162,13 +162,18 @@ - (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionVi
162162#pragma mark -
163163#pragma mark Overrides.
164164
165- - (void )reloadData
165+ - (void )reloadDataWithCompletion : ( void (^)()) completion
166166{
167167 ASDisplayNodeAssert (self.asyncDelegate , @" ASCollectionView's asyncDelegate property must be set." );
168168 ASDisplayNodePerformBlockOnMainThread (^{
169169 [super reloadData ];
170170 });
171- [_dataController reloadDataWithAnimationOption: kASCollectionViewAnimationNone ];
171+ [_dataController reloadDataWithAnimationOption: kASCollectionViewAnimationNone completion: completion];
172+ }
173+
174+ - (void )reloadData
175+ {
176+ [self reloadDataWithCompletion: nil ];
172177}
173178
174179- (void )setDataSource : (id <UICollectionViewDataSource>)dataSource
Original file line number Diff line number Diff line change @@ -226,7 +226,7 @@ - (void)addTarget:(id)target action:(SEL)action forControlEvents:(ASControlNodeE
226226 if (!eventDispatchTable)
227227 {
228228 // Create the dispatch table for this event.
229- eventDispatchTable = [NSMapTable strongToStrongObjectsMapTable ];
229+ eventDispatchTable = [NSMapTable weakToStrongObjectsMapTable ];
230230 [_controlEventDispatchTable setObject: eventDispatchTable forKey: eventKey];
231231 }
232232
Original file line number Diff line number Diff line change 7070 */
7171@property (nonatomic , assign ) CGFloat leadingScreensForBatching;
7272
73+ /* *
74+ * Reload everything from scratch, destroying the working range and all cached nodes.
75+ *
76+ * @param completion block to run on completion of asynchronous loading or nil. If supplied, the block is run on
77+ * the main thread.
78+ * @warning This method is substantially more expensive than UITableView's version.
79+ */
80+ -(void )reloadDataWithCompletion : (void (^)())completion ;
81+
7382/* *
7483 * Reload everything from scratch, destroying the working range and all cached nodes.
7584 *
Original file line number Diff line number Diff line change @@ -217,13 +217,18 @@ - (void)setAsyncDelegate:(id<ASTableViewDelegate>)asyncDelegate
217217 }
218218}
219219
220- - (void )reloadData
220+ - (void )reloadDataWithCompletion : ( void (^)()) completion
221221{
222222 ASDisplayNodeAssert (self.asyncDelegate , @" ASTableView's asyncDelegate property must be set." );
223223 ASDisplayNodePerformBlockOnMainThread (^{
224224 [super reloadData ];
225225 });
226- [_dataController reloadDataWithAnimationOption: UITableViewRowAnimationNone];
226+ [_dataController reloadDataWithAnimationOption: UITableViewRowAnimationNone completion: completion];
227+ }
228+
229+ - (void )reloadData
230+ {
231+ [self reloadDataWithCompletion: nil ];
227232}
228233
229234- (void )setTuningParameters : (ASRangeTuningParameters)tuningParameters forRangeType : (ASLayoutRangeType)rangeType
Original file line number Diff line number Diff line change @@ -155,7 +155,7 @@ typedef NSUInteger ASDataControllerAnimationOptions;
155155
156156- (void )moveRowAtIndexPath : (NSIndexPath *)indexPath toIndexPath : (NSIndexPath *)newIndexPath withAnimationOption : (ASDataControllerAnimationOptions)animationOption ;;
157157
158- - (void )reloadDataWithAnimationOption : (ASDataControllerAnimationOptions)animationOption ; ;
158+ - (void )reloadDataWithAnimationOption : (ASDataControllerAnimationOptions)animationOption completion : ( void (^)()) completion ;
159159
160160/* * @name Data Querying */
161161
Original file line number Diff line number Diff line change @@ -437,7 +437,7 @@ - (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)n
437437 });
438438}
439439
440- - (void )reloadDataWithAnimationOption : (ASDataControllerAnimationOptions)animationOption
440+ - (void )reloadDataWithAnimationOption : (ASDataControllerAnimationOptions)animationOption completion : ( void (^)()) completion
441441{
442442 [self performDataFetchingWithBlock: ^{
443443 // Fetching data in calling thread
@@ -478,6 +478,10 @@ - (void)reloadDataWithAnimationOption:(ASDataControllerAnimationOptions)animatio
478478 }];
479479
480480 [self _batchInsertNodes: updatedNodes atIndexPaths: updatedIndexPaths withAnimationOptions: animationOption];
481+
482+ if (completion) {
483+ dispatch_async (dispatch_get_main_queue (), completion);
484+ }
481485 });
482486 }];
483487}
You can’t perform that action at this time.
0 commit comments