Permalink
Browse files

-[RCTUIManagerObserver uiManagerDidPerformMounting]

Reviewed By: rsnara

Differential Revision: D6434461

fbshipit-source-id: a66407936cec3582cb27c57eb8e36dc225149c45
  • Loading branch information...
shergin authored and facebook-github-bot committed Dec 12, 2017
1 parent 0a8721c commit 60dc9bed00cc13652752bf84f83c920ce66d5e39
@@ -431,7 +431,7 @@ - (void)setBackgroundColor:(UIColor *)color forView:(UIView *)view
shadowView.backgroundColor = color;
[self _amendPendingUIBlocksWithStylePropagationUpdateForShadowView:shadowView];
[self flushUIBlocks];
[self flushUIBlocksWithCompletion:^{}];
} forTag:view.reactTag];
}
@@ -1128,10 +1128,12 @@ - (void)_layoutAndMount
[_observerCoordinator uiManagerWillPerformMounting:self];
[self flushUIBlocks];
[self flushUIBlocksWithCompletion:^{
[self->_observerCoordinator uiManagerDidPerformMounting:self];
}];
}
- (void)flushUIBlocks
- (void)flushUIBlocksWithCompletion:(void (^)(void))completion;
{
RCTAssertUIManagerQueue();
@@ -1141,25 +1143,30 @@ - (void)flushUIBlocks
NSArray<RCTViewManagerUIBlock> *previousPendingUIBlocks = _pendingUIBlocks;
_pendingUIBlocks = [NSMutableArray new];
if (previousPendingUIBlocks.count) {
// Execute the previously queued UI blocks
RCTProfileBeginFlowEvent();
RCTExecuteOnMainQueue(^{
RCTProfileEndFlowEvent();
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"-[UIManager flushUIBlocks]", (@{
@"count": [@(previousPendingUIBlocks.count) stringValue],
}));
@try {
for (RCTViewManagerUIBlock block in previousPendingUIBlocks) {
block(self, self->_viewRegistry);
}
}
@catch (NSException *exception) {
RCTLogError(@"Exception thrown while executing UI block: %@", exception);
}
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
});
if (previousPendingUIBlocks.count == 0) {
completion();
return;
}
// Execute the previously queued UI blocks
RCTProfileBeginFlowEvent();
RCTExecuteOnMainQueue(^{
RCTProfileEndFlowEvent();
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"-[UIManager flushUIBlocks]", (@{
@"count": [@(previousPendingUIBlocks.count) stringValue],
}));
@try {
for (RCTViewManagerUIBlock block in previousPendingUIBlocks) {
block(self, self->_viewRegistry);
}
}
@catch (NSException *exception) {
RCTLogError(@"Exception thrown while executing UI block: %@", exception);
}
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
RCTExecuteOnUIManagerQueue(completion);
});
}
- (void)setNeedsLayout
@@ -45,6 +45,12 @@
*/
- (void)uiManagerWillPerformMounting:(RCTUIManager *)manager;
/**
* Called just after flushing UI blocks.
* This is called from the UIManager queue.
*/
- (void)uiManagerDidPerformMounting:(RCTUIManager *)manager;
@end
/**
@@ -74,4 +74,16 @@ - (void)uiManagerWillPerformMounting:(RCTUIManager *)manager
}
}
- (void)uiManagerDidPerformMounting:(RCTUIManager *)manager
{
std::lock_guard<std::mutex> lock(_mutex);
for (id<RCTUIManagerObserver> observer in _observers) {
if ([observer respondsToSelector:@selector(uiManagerDidPerformMounting:)]) {
[observer uiManagerDidPerformMounting:manager];
}
}
}
@end

0 comments on commit 60dc9be

Please sign in to comment.