Skip to content

Conversation

@adamjernst
Copy link
Contributor

This was never updated after we transitioned away from CKComponentLifecycleManager, so it was mostly broken. Now instead of attempting to use the view hierarchy to trigger reflow, we simply message all interested parties and tell them to update themselves.

Crucially this means that offscreen components are recomputed too, not just onscreen ones. Neat.

This was never updated after we transitioned away from `CKComponentLifecycleManager`, so it was mostly broken. Now instead of attempting to use the view hierarchy to trigger reflow, we simply message all interested parties and tell them to update themselves.

Crucially this means that offscreen components are recomputed too, not just onscreen ones. Neat.
}

static CK::StaticMutex l = CK_MUTEX_INITIALIZER;
CK::StaticMutexLocker lock(l);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

unnecessary; mount is only performed on the main thread.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to assert this is called on the main thread? Or do you think that's overkill in this case?

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 think it's overkill in this particular case.

if (view) {
CKRecursiveComponentReflow(view);
for (id<CKComponentDebugReflowListener> listener in copiedListeners) {
[listener didReceiveReflowComponentsRequest];
Copy link
Contributor

Choose a reason for hiding this comment

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

This is so much better than traversing the view hierarchy to find the component lifecycle manager or explicitly telling component hosting views to layout.

if (self = [super init]) {
_componentProvider = componentProvider;
_sizeRangeProvider = sizeRangeProvider;
[CKComponentDebugController registerReflowListener:self];
Copy link
Contributor

Choose a reason for hiding this comment

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

Though it's a bit of a shame to have CKComponentLifecycleManager aware of debug code I think it's totally worthwhile considering how much it simplifies CKComponentDebugController.

Copy link
Contributor

Choose a reason for hiding this comment

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

It is a bit weird, definitely. How about having a separate registry of lifecycle managers (exposed in an internal header) that the debug controller can then access? At least that would get the debug controller code out of CKComponentLifecycleManager.

}
std::lock_guard<std::mutex> l(reflowMutex);
if (reflowListeners == nil) {
reflowListeners = [NSHashTable weakObjectsHashTable];
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice. So we weakly hold the reflow listeners to naturally keep the collection bounded.

}

static CK::StaticMutex l = CK_MUTEX_INITIALIZER;
CK::StaticMutexLocker lock(l);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to assert this is called on the main thread? Or do you think that's overkill in this case?

@eczarny
Copy link
Contributor

eczarny commented Dec 8, 2016

Looks good to merge to me. I like how much this simplifies things.

@adamjernst adamjernst merged commit fcc1512 into facebook:master Dec 8, 2016
@ocrickard
Copy link
Contributor

Looks good to me.

Copy link
Contributor

@natansh natansh left a comment

Choose a reason for hiding this comment

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

It's definitely much better than before, but I am a bit concerned about introducing debugging code into the core internals - the footprint of debug code in these internals is still pretty small, though, so its cool! 👍

if (self = [super init]) {
_componentProvider = componentProvider;
_sizeRangeProvider = sizeRangeProvider;
[CKComponentDebugController registerReflowListener:self];
Copy link
Contributor

Choose a reason for hiding this comment

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

It is a bit weird, definitely. How about having a separate registry of lifecycle managers (exposed in an internal header) that the debug controller can then access? At least that would get the debug controller code out of CKComponentLifecycleManager.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants