Skip to content

Commit 3e55f2f

Browse files
Adlai-HollerAdlai Holler
authored andcommitted
[Cherry-pick] facebookarchive#504 nodeViewModel -> nodeModel
1 parent 5e298b1 commit 3e55f2f

12 files changed

+66
-66
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
- [ASTextNode2] Provide compile flag to globally enable new implementation of ASTextNode: ASTEXTNODE_EXPERIMENT_GLOBAL_ENABLE. [Scott Goodson](https://github.com/appleguy) [#396](https://github.com/TextureGroup/Texture/pull/410)
1515
- Add ASCollectionGalleryLayoutDelegate - an async collection layout that makes same-size collections (e.g photo galleries, pagers, etc) fast and lightweight! [Huy Nguyen](https://github.com/nguyenhuy/) [#76](https://github.com/TextureGroup/Texture/pull/76) [#451](https://github.com/TextureGroup/Texture/pull/451)
1616
- Fix an issue that causes infinite layout loop in ASDisplayNode after [#428](https://github.com/TextureGroup/Texture/pull/428) [Huy Nguyen](https://github.com/nguyenhuy) [#455](https://github.com/TextureGroup/Texture/pull/455)
17-
- Rename ASCellNode.viewModel to ASCellNode.nodeViewModel to reduce collisions with subclass properties implemented by clients. [Adlai Holler](https://github.com/Adlai-Holler) [#499](https://github.com/TextureGroup/Texture/pull/499)
17+
- Rename ASCellNode.viewModel to ASCellNode.nodeModel to reduce collisions with subclass properties implemented by clients. [Adlai Holler](https://github.com/Adlai-Holler) [#504](https://github.com/TextureGroup/Texture/pull/504)
1818

1919
##2.3.4
2020
- [Yoga] Rewrite YOGA_TREE_CONTIGUOUS mode with improved behavior and cleaner integration [Scott Goodson](https://github.com/appleguy)

Source/ASCellNode.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,14 @@ typedef NS_ENUM(NSUInteger, ASCellNodeVisibilityEvent) {
123123
*
124124
* This property may be set off the main thread, but this method will never be invoked concurrently on the
125125
*/
126-
@property (atomic, nullable) id nodeViewModel;
126+
@property (atomic, nullable) id nodeModel;
127127

128128
/**
129-
* Asks the node whether it can be updated to the given view model.
129+
* Asks the node whether it can be updated to the given node model.
130130
*
131131
* The default implementation returns YES if the class matches that of the current view-model.
132132
*/
133-
- (BOOL)canUpdateToViewModel:(id)viewModel;
133+
- (BOOL)canUpdateToNodeModel:(id)nodeModel;
134134

135135
/**
136136
* The backing view controller, or @c nil if the node wasn't initialized with backing view controller

Source/ASCellNode.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,9 @@ - (void)__setHighlightedFromUIKit:(BOOL)highlighted;
170170
}
171171
}
172172

173-
- (BOOL)canUpdateToViewModel:(id)viewModel
173+
- (BOOL)canUpdateToNodeModel:(id)nodeModel
174174
{
175-
return [self.nodeViewModel class] == [viewModel class];
175+
return [self.nodeModel class] == [nodeModel class];
176176
}
177177

178178
- (NSIndexPath *)indexPath

Source/ASCollectionNode.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -419,15 +419,15 @@ NS_ASSUME_NONNULL_BEGIN
419419
- (nullable __kindof ASCellNode *)nodeForItemAtIndexPath:(NSIndexPath *)indexPath AS_WARN_UNUSED_RESULT;
420420

421421
/**
422-
* Retrieves the view-model for the item at the given index path, if any.
422+
* Retrieves the node-model for the item at the given index path, if any.
423423
*
424424
* @param indexPath The index path of the requested item.
425425
*
426-
* @return The view-model for the given item, or @c nil if no item exists at the specified path or no view-model was provided.
426+
* @return The node-model for the given item, or @c nil if no item exists at the specified path or no node-model was provided.
427427
*
428428
* @warning This API is beta and subject to change. We'll try to provide an easy migration path.
429429
*/
430-
- (nullable id)viewModelForItemAtIndexPath:(NSIndexPath *)indexPath AS_WARN_UNUSED_RESULT;
430+
- (nullable id)nodeModelForItemAtIndexPath:(NSIndexPath *)indexPath AS_WARN_UNUSED_RESULT;
431431

432432
/**
433433
* Retrieve the index path for the item with the given node.
@@ -523,7 +523,7 @@ NS_ASSUME_NONNULL_BEGIN
523523
*
524524
* @return An object that contains all the data for this item.
525525
*/
526-
- (nullable id)collectionNode:(ASCollectionNode *)collectionNode viewModelForItemAtIndexPath:(NSIndexPath *)indexPath;
526+
- (nullable id)collectionNode:(ASCollectionNode *)collectionNode nodeModelForItemAtIndexPath:(NSIndexPath *)indexPath;
527527

528528
/**
529529
* Similar to -collectionNode:nodeForItemAtIndexPath:

Source/ASCollectionNode.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,10 +594,10 @@ - (ASCellNode *)nodeForItemAtIndexPath:(NSIndexPath *)indexPath
594594
return [self.dataController.pendingMap elementForItemAtIndexPath:indexPath].node;
595595
}
596596

597-
- (id)viewModelForItemAtIndexPath:(NSIndexPath *)indexPath
597+
- (id)nodeModelForItemAtIndexPath:(NSIndexPath *)indexPath
598598
{
599599
[self reloadDataInitiallyIfNeeded];
600-
return [self.dataController.pendingMap elementForItemAtIndexPath:indexPath].viewModel;
600+
return [self.dataController.pendingMap elementForItemAtIndexPath:indexPath].nodeModel;
601601
}
602602

603603
- (NSIndexPath *)indexPathForNode:(ASCellNode *)cellNode

Source/ASCollectionView.mm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ @interface ASCollectionView () <ASRangeControllerDataSource, ASRangeControllerDe
202202
unsigned int collectionViewNumberOfItemsInSection:1;
203203
unsigned int collectionNodeNodeForItem:1;
204204
unsigned int collectionNodeNodeBlockForItem:1;
205-
unsigned int viewModelForItem:1;
205+
unsigned int nodeModelForItem:1;
206206
unsigned int collectionNodeNodeForSupplementaryElement:1;
207207
unsigned int collectionNodeNodeBlockForSupplementaryElement:1;
208208
unsigned int collectionNodeSupplementaryElementKindsInSection:1;
@@ -431,7 +431,7 @@ - (void)setAsyncDataSource:(id<ASCollectionDataSource>)asyncDataSource
431431
_asyncDataSourceFlags.collectionNodeNodeForSupplementaryElement = [_asyncDataSource respondsToSelector:@selector(collectionNode:nodeForSupplementaryElementOfKind:atIndexPath:)];
432432
_asyncDataSourceFlags.collectionNodeNodeBlockForSupplementaryElement = [_asyncDataSource respondsToSelector:@selector(collectionNode:nodeBlockForSupplementaryElementOfKind:atIndexPath:)];
433433
_asyncDataSourceFlags.collectionNodeSupplementaryElementKindsInSection = [_asyncDataSource respondsToSelector:@selector(collectionNode:supplementaryElementKindsInSection:)];
434-
_asyncDataSourceFlags.viewModelForItem = [_asyncDataSource respondsToSelector:@selector(collectionNode:viewModelForItemAtIndexPath:)];
434+
_asyncDataSourceFlags.nodeModelForItem = [_asyncDataSource respondsToSelector:@selector(collectionNode:nodeModelForItemAtIndexPath:)];
435435

436436
_asyncDataSourceFlags.interop = [_asyncDataSource conformsToProtocol:@protocol(ASCollectionDataSourceInterop)];
437437
if (_asyncDataSourceFlags.interop) {
@@ -1662,14 +1662,14 @@ - (void)_beginBatchFetching
16621662

16631663
#pragma mark - ASDataControllerSource
16641664

1665-
- (id)dataController:(ASDataController *)dataController viewModelForItemAtIndexPath:(NSIndexPath *)indexPath
1665+
- (id)dataController:(ASDataController *)dataController nodeModelForItemAtIndexPath:(NSIndexPath *)indexPath
16661666
{
1667-
if (!_asyncDataSourceFlags.viewModelForItem) {
1667+
if (!_asyncDataSourceFlags.nodeModelForItem) {
16681668
return nil;
16691669
}
16701670

16711671
GET_COLLECTIONNODE_OR_RETURN(collectionNode, nil);
1672-
return [_asyncDataSource collectionNode:collectionNode viewModelForItemAtIndexPath:indexPath];
1672+
return [_asyncDataSource collectionNode:collectionNode nodeModelForItemAtIndexPath:indexPath];
16731673
}
16741674

16751675
- (ASCellNodeBlock)dataController:(ASDataController *)dataController nodeBlockAtIndexPath:(NSIndexPath *)indexPath

Source/ASTableView.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1621,7 +1621,7 @@ - (void)rangeController:(ASRangeController *)rangeController updateWithChangeSet
16211621

16221622
#pragma mark - ASDataControllerSource
16231623

1624-
- (id)dataController:(ASDataController *)dataController viewModelForItemAtIndexPath:(NSIndexPath *)indexPath
1624+
- (id)dataController:(ASDataController *)dataController nodeModelForItemAtIndexPath:(NSIndexPath *)indexPath
16251625
{
16261626
// Not currently supported for tables. Will be added when the collection API stabilizes.
16271627
return nil;

Source/Details/ASCollectionElement.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ AS_SUBCLASSING_RESTRICTED
3030
@property (nonatomic, assign) ASSizeRange constrainedSize;
3131
@property (nonatomic, readonly, weak) id<ASRangeManagingNode> owningNode;
3232
@property (nonatomic, assign) ASPrimitiveTraitCollection traitCollection;
33-
@property (nonatomic, readonly, nullable) id viewModel;
33+
@property (nonatomic, readonly, nullable) id nodeModel;
3434

35-
- (instancetype)initWithViewModel:(nullable id)viewModel
35+
- (instancetype)initWithNodeModel:(nullable id)nodeModel
3636
nodeBlock:(ASCellNodeBlock)nodeBlock
3737
supplementaryElementKind:(nullable NSString *)supplementaryElementKind
3838
constrainedSize:(ASSizeRange)constrainedSize

Source/Details/ASCollectionElement.mm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ @implementation ASCollectionElement {
3131
ASCellNode *_node;
3232
}
3333

34-
- (instancetype)initWithViewModel:(id)viewModel
34+
- (instancetype)initWithNodeModel:(id)nodeModel
3535
nodeBlock:(ASCellNodeBlock)nodeBlock
3636
supplementaryElementKind:(NSString *)supplementaryElementKind
3737
constrainedSize:(ASSizeRange)constrainedSize
@@ -41,7 +41,7 @@ - (instancetype)initWithViewModel:(id)viewModel
4141
NSAssert(nodeBlock != nil, @"Node block must not be nil");
4242
self = [super init];
4343
if (self) {
44-
_viewModel = viewModel;
44+
_nodeModel = nodeModel;
4545
_nodeBlock = nodeBlock;
4646
_supplementaryElementKind = [supplementaryElementKind copy];
4747
_constrainedSize = constrainedSize;
@@ -64,7 +64,7 @@ - (ASCellNode *)node
6464
node.owningNode = _owningNode;
6565
node.collectionElement = self;
6666
ASTraitCollectionPropagateDown(node, _traitCollection);
67-
node.nodeViewModel = _viewModel;
67+
node.nodeModel = _nodeModel;
6868
_node = node;
6969
}
7070
return _node;

Source/Details/ASDataController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ extern NSString * const ASCollectionInvalidUpdateException;
7878
*/
7979
- (BOOL)dataController:(ASDataController *)dataController presentedSizeForElement:(ASCollectionElement *)element matchesSize:(CGSize)size;
8080

81-
- (nullable id)dataController:(ASDataController *)dataController viewModelForItemAtIndexPath:(NSIndexPath *)indexPath;
81+
- (nullable id)dataController:(ASDataController *)dataController nodeModelForItemAtIndexPath:(NSIndexPath *)indexPath;
8282

8383
@optional
8484

0 commit comments

Comments
 (0)