mirror of
https://github.com/HackPlan/AsyncDisplayKit.git
synced 2026-06-16 18:19:54 +08:00
Merge pull request #365 from facebook/issue-363
Range handlers use recursive actions
This commit is contained in:
@@ -331,10 +331,19 @@ typedef CALayer *(^ASDisplayNodeLayerBlock)();
|
||||
* This method is used to notify the node that it should purge any content that is both expensive to fetch and to
|
||||
* retain in memory.
|
||||
*
|
||||
* @see fetchRemoteData
|
||||
* @see clearRemoteData and fetchRemoteData
|
||||
*/
|
||||
- (void)recursivelyClearRemoteData;
|
||||
|
||||
/**
|
||||
* @abstract Calls -fetchRemoteData on the receiver and its subnode hierarchy.
|
||||
*
|
||||
* @discussion Fetches content from remote sources for the current node and all subnodes.
|
||||
*
|
||||
* @see fetchRemoteData and clearRemoteData
|
||||
*/
|
||||
- (void)recursivelyFetchRemoteData;
|
||||
|
||||
/**
|
||||
* @abstract Toggle displaying a placeholder over the node that covers content until the node and all subnodes are
|
||||
* displayed.
|
||||
|
||||
@@ -1348,6 +1348,14 @@ static NSInteger incrementIfFound(NSInteger i) {
|
||||
// subclass override
|
||||
}
|
||||
|
||||
- (void)recursivelyFetchRemoteData
|
||||
{
|
||||
for (ASDisplayNode *subnode in self.subnodes) {
|
||||
[subnode recursivelyFetchRemoteData];
|
||||
}
|
||||
[self fetchRemoteData];
|
||||
}
|
||||
|
||||
- (void)clearRemoteData
|
||||
{
|
||||
// subclass override
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
- (void)node:(ASDisplayNode *)node enteredRangeOfType:(ASLayoutRangeType)rangeType
|
||||
{
|
||||
ASDisplayNodeAssert(rangeType == ASLayoutRangeTypePreload, @"Preload delegate should not handle other ranges");
|
||||
[node fetchRemoteData];
|
||||
[node recursivelyFetchRemoteData];
|
||||
}
|
||||
|
||||
- (void)node:(ASDisplayNode *)node exitedRangeOfType:(ASLayoutRangeType)rangeType
|
||||
{
|
||||
ASDisplayNodeAssert(rangeType == ASLayoutRangeTypePreload, @"Preload delegate should not handle other ranges");
|
||||
[node clearRemoteData];
|
||||
[node recursivelyClearRemoteData];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user