Using RCTExecuteOnUIManagerQueue convinient func in all conseptually identical cases

Summary:
Reasons:
 * It is more clear and readable;
 * It is more semantical;
 * It allows us to add some magic (and complexity, to be fair) to the RCTExecuteOnUIManagerQueue. (See next diffs in the stack.)

Reviewed By: javache

Differential Revision: D5935466

fbshipit-source-id: aeb18d6e11c047eb19182a656da581b6ce073602
This commit is contained in:
Valentin Shergin 2017-10-02 18:07:42 -07:00 коммит произвёл Facebook Github Bot
Родитель be27f44e1b
Коммит feba4f6a92
1 изменённых файлов: 8 добавлений и 8 удалений

Просмотреть файл

@ -174,7 +174,7 @@ RCT_EXPORT_MODULE()
body:@([_bridge.accessibilityManager multiplier])]; body:@([_bridge.accessibilityManager multiplier])];
#pragma clang diagnostic pop #pragma clang diagnostic pop
dispatch_async(RCTGetUIManagerQueue(), ^{ RCTExecuteOnUIManagerQueue(^{
[[NSNotificationCenter defaultCenter] postNotificationName:RCTUIManagerWillUpdateViewsDueToContentSizeMultiplierChangeNotification [[NSNotificationCenter defaultCenter] postNotificationName:RCTUIManagerWillUpdateViewsDueToContentSizeMultiplierChangeNotification
object:self]; object:self];
[self setNeedsLayout]; [self setNeedsLayout];
@ -259,7 +259,7 @@ static NSDictionary *deviceOrientationEventBody(UIDeviceOrientation orientation)
_viewRegistry[reactTag] = rootView; _viewRegistry[reactTag] = rootView;
// Register shadow view // Register shadow view
dispatch_async(RCTGetUIManagerQueue(), ^{ RCTExecuteOnUIManagerQueue(^{
if (!self->_viewRegistry) { if (!self->_viewRegistry) {
return; return;
} }
@ -296,7 +296,7 @@ static NSDictionary *deviceOrientationEventBody(UIDeviceOrientation orientation)
{ {
RCTAssertMainQueue(); RCTAssertMainQueue();
NSNumber *reactTag = rootView.reactTag; NSNumber *reactTag = rootView.reactTag;
dispatch_async(RCTGetUIManagerQueue(), ^{ RCTExecuteOnUIManagerQueue(^{
RCTRootShadowView *shadowView = (RCTRootShadowView *)self->_shadowViewRegistry[reactTag]; RCTRootShadowView *shadowView = (RCTRootShadowView *)self->_shadowViewRegistry[reactTag];
RCTAssert(shadowView != nil, @"Could not locate shadow view with tag #%@", reactTag); RCTAssert(shadowView != nil, @"Could not locate shadow view with tag #%@", reactTag);
RCTAssert([shadowView isKindOfClass:[RCTRootShadowView class]], @"Located shadow view (with tag #%@) is actually not root view.", reactTag); RCTAssert([shadowView isKindOfClass:[RCTRootShadowView class]], @"Located shadow view (with tag #%@) is actually not root view.", reactTag);
@ -315,7 +315,7 @@ static NSDictionary *deviceOrientationEventBody(UIDeviceOrientation orientation)
RCTAssertMainQueue(); RCTAssertMainQueue();
NSNumber *tag = view.reactTag; NSNumber *tag = view.reactTag;
dispatch_async(RCTGetUIManagerQueue(), ^{ RCTExecuteOnUIManagerQueue(^{
RCTShadowView *shadowView = self->_shadowViewRegistry[tag]; RCTShadowView *shadowView = self->_shadowViewRegistry[tag];
RCTAssert(shadowView != nil, @"Could not locate shadow view with tag #%@", tag); RCTAssert(shadowView != nil, @"Could not locate shadow view with tag #%@", tag);
@ -356,7 +356,7 @@ static NSDictionary *deviceOrientationEventBody(UIDeviceOrientation orientation)
RCTAssertMainQueue(); RCTAssertMainQueue();
NSNumber *reactTag = view.reactTag; NSNumber *reactTag = view.reactTag;
dispatch_async(RCTGetUIManagerQueue(), ^{ RCTExecuteOnUIManagerQueue(^{
RCTShadowView *shadowView = self->_shadowViewRegistry[reactTag]; RCTShadowView *shadowView = self->_shadowViewRegistry[reactTag];
RCTAssert(shadowView != nil, @"Could not locate shadow view with tag #%@", reactTag); RCTAssert(shadowView != nil, @"Could not locate shadow view with tag #%@", reactTag);
@ -374,7 +374,7 @@ static NSDictionary *deviceOrientationEventBody(UIDeviceOrientation orientation)
RCTAssertMainQueue(); RCTAssertMainQueue();
NSNumber *reactTag = view.reactTag; NSNumber *reactTag = view.reactTag;
dispatch_async(RCTGetUIManagerQueue(), ^{ RCTExecuteOnUIManagerQueue(^{
RCTShadowView *shadowView = self->_shadowViewRegistry[reactTag]; RCTShadowView *shadowView = self->_shadowViewRegistry[reactTag];
if (shadowView == nil) { if (shadowView == nil) {
RCTLogWarn(@"Could not locate shadow view with tag #%@, this is probably caused by a temporary inconsistency between native views and shadow views.", reactTag); RCTLogWarn(@"Could not locate shadow view with tag #%@, this is probably caused by a temporary inconsistency between native views and shadow views.", reactTag);
@ -393,7 +393,7 @@ static NSDictionary *deviceOrientationEventBody(UIDeviceOrientation orientation)
RCTAssertMainQueue(); RCTAssertMainQueue();
NSNumber *reactTag = view.reactTag; NSNumber *reactTag = view.reactTag;
dispatch_async(RCTGetUIManagerQueue(), ^{ RCTExecuteOnUIManagerQueue(^{
if (!self->_viewRegistry) { if (!self->_viewRegistry) {
return; return;
} }
@ -1510,7 +1510,7 @@ RCT_EXPORT_METHOD(configureNextLayoutAnimation:(NSDictionary *)config
return; return;
} }
dispatch_async(RCTGetUIManagerQueue(), ^{ RCTExecuteOnUIManagerQueue(^{
NSNumber *rootTag = [self shadowViewForReactTag:reactTag].rootView.reactTag; NSNumber *rootTag = [self shadowViewForReactTag:reactTag].rootView.reactTag;
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
UIView *rootView = nil; UIView *rootView = nil;