-[RCTUIManagerObserver uiManagerDidPerformMounting]
Reviewed By: rsnara Differential Revision: D6434461 fbshipit-source-id: a66407936cec3582cb27c57eb8e36dc225149c45
This commit is contained in:
parent
0a8721c340
commit
60dc9bed00
|
@ -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,25 +1143,30 @@ RCT_EXPORT_METHOD(dispatchViewManagerCommand:(nonnull NSNumber *)reactTag
|
|||
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)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
|
||||
|
|
Loading…
Reference in New Issue