-[RCTUIManagerObserver uiManagerDidPerformMounting]

Reviewed By: rsnara

Differential Revision: D6434461

fbshipit-source-id: a66407936cec3582cb27c57eb8e36dc225149c45
This commit is contained in:
Valentin Shergin 2017-12-11 16:54:54 -08:00 committed by Facebook Github Bot
parent 0a8721c340
commit 60dc9bed00
3 changed files with 46 additions and 21 deletions

View File

@ -431,7 +431,7 @@ static NSDictionary *deviceOrientationEventBody(UIDeviceOrientation orientation)
shadowView.backgroundColor = color;
[self _amendPendingUIBlocksWithStylePropagationUpdateForShadowView:shadowView];
[self flushUIBlocks];
[self flushUIBlocksWithCompletion:^{}];
} forTag:view.reactTag];
}
@ -1128,10 +1128,12 @@ RCT_EXPORT_METHOD(dispatchViewManagerCommand:(nonnull NSNumber *)reactTag
[_observerCoordinator uiManagerWillPerformMounting:self];
[self flushUIBlocks];
[self flushUIBlocksWithCompletion:^{
[self->_observerCoordinator uiManagerDidPerformMounting:self];
}];
}
- (void)flushUIBlocks
- (void)flushUIBlocksWithCompletion:(void (^)(void))completion;
{
RCTAssertUIManagerQueue();
@ -1141,7 +1143,11 @@ RCT_EXPORT_METHOD(dispatchViewManagerCommand:(nonnull NSNumber *)reactTag
NSArray<RCTViewManagerUIBlock> *previousPendingUIBlocks = _pendingUIBlocks;
_pendingUIBlocks = [NSMutableArray new];
if (previousPendingUIBlocks.count) {
if (previousPendingUIBlocks.count == 0) {
completion();
return;
}
// Execute the previously queued UI blocks
RCTProfileBeginFlowEvent();
RCTExecuteOnMainQueue(^{
@ -1158,9 +1164,10 @@ RCT_EXPORT_METHOD(dispatchViewManagerCommand:(nonnull NSNumber *)reactTag
RCTLogError(@"Exception thrown while executing UI block: %@", exception);
}
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
RCTExecuteOnUIManagerQueue(completion);
});
}
}
- (void)setNeedsLayout
{

View File

@ -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
/**

View File

@ -74,4 +74,16 @@
}
}
- (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