Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

IGListKit Support II: Electric Boogaloo #2942

Merged
merged 12 commits into from
Jan 30, 2017
Merged

Conversation

Adlai-Holler
Copy link
Contributor

@Adlai-Holler Adlai-Holler commented Jan 28, 2017

This supersedes #2848 which was a bit hacky and messy.

  • Add ASCollectionDataSourceInterop and ASCollectionDelegateInterop protocols to formalize what hooks we need to support IGListKit.
  • Add IGListAdapterBasedDataSource to connect IGListKit to AsyncDisplayKit using the existing dataSource/delegate architecture.
  • Beef up ASDKgram to use a header node on the IGListKit tab.

To use IGListKit:

  • Have your section controllers conform to ASSectionController.
  • Have your supplementary view sources conform to ASSupplementaryNodeSource.
  • On your IGListAdapter, call -setASDKCollectionNode: to make the connection.

Note: Use the provided implementations from ASIGListKitMethodImplementations.h to cover required IGListKit methods that don't apply when used with ASDK.

@ay8s @appleguy @nguyenhuy @maicki @garrettmoon @jessesquires @ocrickard

ASDisplayNodeAssertThreadAffinity(self);
ASDN::MutexUnlocker l(__instanceLock__);
body(self);
} else if (_onDidLoadBlocks == nil) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed this behavior to call -didLoad before any onDidLoadBlocks, and no longer to throw if they call on main on a loaded node (just runs block).

Copy link
Contributor

@appleguy appleguy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fantastic effort this patch represents! Thanks for including a really solid gauntlet of tests (it will be a good base to use in the automated performance tests, and we'll add sophistication over time)

Definitely interested in anything you might want to put up which implements this capability while taking advantage of some of these codepaths. #2948


@implementation ASListKitTests

- (void)setUp {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: The default-inserted methods use the brace-at-end-of-name style, so we should bump it down.

return [[ASListTestObject alloc] initWithKey:self.key value:self.value];
}


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Extra return here. Is there a standard on protocol names? Would it make sense for the pragma mark to say or protocol ?

@@ -26,8 +27,8 @@
#pragma mark - _ASCollectionPendingState

@interface _ASCollectionPendingState : NSObject
@property (weak, nonatomic) id <ASCollectionDelegate> delegate;
@property (weak, nonatomic) id <ASCollectionDataSource> dataSource;
@property (weak, nonatomic) id <ASCollectionDelegate> delegate;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert this change unless you see a benefit

@@ -27,6 +28,8 @@
#import "ASSectionContext.h"
#import "ASCollectionView+Undeprecated.h"
#import "_ASHierarchyChangeSet.h"
#import <objc/runtime.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put runtime.h at the bottom (or top). This imports list should have its order cleaned up (alphabetized or grouped by functional area)


memset(&_asyncDataSourceFlags, 0, sizeof(_asyncDataSourceFlags));
_asyncDataSourceFlags = {};

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not have space after. I'm split on this change -- I think the memset is much more explicit, at least since I'm not sure it is widespread knowledge that {} will zero memory for the specific size of a struct type (particularly in an equality like this, where we need to overwrite existing values, as opposed to initialization-time).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've applied all of your suggestions save this one, with the rationale that:

  • This is a higher level of abstraction (symbol vs memory)
  • If a dev doesn't understand what = {} means then they should look it up and learn, tough love 💪

Copy link
Contributor

@appleguy appleguy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Sample applications each give a valuable reference for new users of *ListKit, too!

cc @rnystrom, @jessesquires, @zhubofei thanks for building a great framework in IGListKit! It helped reduce the complexity of ASDK by removing our custom diffing implementation 👍

@jessesquires
Copy link

💯 🎉

@Adlai-Holler
Copy link
Contributor Author

Here we go!

@Adlai-Holler Adlai-Holler merged commit 38aac9d into master Jan 30, 2017
@Adlai-Holler Adlai-Holler deleted the AHIGListKit-NoProtocols branch January 30, 2017 19:17
@rnystrom
Copy link
Contributor

So awesome, great work @Adlai-Holler, going to have to play around w/ this!

Also 👋 @appleguy ❤️, we've come full circle!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants