Procházet zdrojové kódy

async await fix for ios

yogevbd před 7 roky
rodič
revize
fd4e7091c0

+ 7
- 6
ios/RCCManagerModule.m Zobrazit soubor

@@ -143,7 +143,7 @@ RCT_EXPORT_MODULE(RCCManager);
143 143
 -(void)dismissAllModalPresenters:(NSMutableArray*)allPresentedViewControllers resolver:(RCTPromiseResolveBlock)resolve
144 144
 {
145 145
     UIViewController *rootViewController = [UIApplication sharedApplication].delegate.window.rootViewController;
146
-
146
+    
147 147
     if (allPresentedViewControllers.count > 0)
148 148
     {
149 149
         dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),^
@@ -205,25 +205,26 @@ RCT_EXPORT_MODULE(RCCManager);
205 205
 #pragma mark - RCT exported methods
206 206
 
207 207
 RCT_EXPORT_METHOD(
208
-                  setRootController:(NSDictionary*)layout animationType:(NSString*)animationType globalProps:(NSDictionary*)globalProps)
208
+                  setRootController:(NSDictionary*)layout animationType:(NSString*)animationType globalProps:(NSDictionary*)globalProps resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
209 209
 {
210 210
     if ([[RCCManager sharedInstance] getBridge].loading) {
211
-        [self deferSetRootControllerWhileBridgeLoading:layout animationType:animationType globalProps:globalProps];
211
+        [self deferSetRootControllerWhileBridgeLoading:layout animationType:animationType globalProps:globalProps resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject];
212 212
         return;
213 213
     }
214 214
     
215 215
     dispatch_async(dispatch_get_main_queue(), ^{
216 216
         [self performSetRootController:layout animationType:animationType globalProps:globalProps];
217
+        resolve(nil);
217 218
     });
218 219
 }
219 220
 
220 221
 /**
221 222
  * on RN31 there's a timing issue, we must wait for the bridge to finish loading
222 223
  */
223
--(void)deferSetRootControllerWhileBridgeLoading:(NSDictionary*)layout animationType:(NSString*)animationType globalProps:(NSDictionary*)globalProps
224
+-(void)deferSetRootControllerWhileBridgeLoading:(NSDictionary*)layout animationType:(NSString*)animationType globalProps:(NSDictionary*)globalProps resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject
224 225
 {
225 226
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.0001 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
226
-        [self setRootController:layout animationType:animationType globalProps:globalProps];
227
+        [self setRootController:layout animationType:animationType globalProps:globalProps resolver:resolve rejecter:reject];
227 228
     });
228 229
 }
229 230
 
@@ -421,7 +422,7 @@ RCT_EXPORT_METHOD(
421 422
     }
422 423
     else
423 424
     {
424
-      resolve(nil);
425
+        resolve(nil);
425 426
     }
426 427
 }
427 428
 

+ 2
- 3
src/deprecated/controllers/index.js Zobrazit soubor

@@ -121,13 +121,13 @@ var Controllers = {
121 121
     registerController: function (appKey, getControllerFunc) {
122 122
       _controllerRegistry[appKey] = getControllerFunc();
123 123
     },
124
-    setRootController: function (appKey, animationType = 'none', passProps = {}) {
124
+    setRootController: async function (appKey, animationType = 'none', passProps = {}) {
125 125
       var controller = _controllerRegistry[appKey];
126 126
       if (controller === undefined) return;
127 127
       var layout = controller.render();
128 128
       _validateDrawerProps(layout);
129 129
       _processProperties(_.get(layout, 'props.appStyle', {}));
130
-      RCCManager.setRootController(layout, animationType, passProps);
130
+      return await RCCManager.setRootController(layout, animationType, passProps);
131 131
     }
132 132
   },
133 133
 
@@ -328,4 +328,3 @@ var Controllers = {
328 328
 };
329 329
 
330 330
 module.exports = Controllers;
331
-

+ 4
- 4
src/deprecated/platformSpecificDeprecated.ios.js Zobrazit soubor

@@ -14,7 +14,7 @@ import _ from 'lodash';
14 14
 
15 15
 import PropRegistry from '../PropRegistry';
16 16
 
17
-function startTabBasedApp(params) {
17
+async function startTabBasedApp(params) {
18 18
   if (!params.tabs) {
19 19
     console.error('startTabBasedApp(params): params.tabs is required');
20 20
     return;
@@ -119,10 +119,10 @@ function startTabBasedApp(params) {
119 119
   _.set(params, 'passProps.timestamp', Date.now());
120 120
 
121 121
   ControllerRegistry.registerController(controllerID, () => Controller);
122
-  ControllerRegistry.setRootController(controllerID, params.animationType, params.passProps || {});
122
+  return await ControllerRegistry.setRootController(controllerID, params.animationType, params.passProps || {});
123 123
 }
124 124
 
125
-function startSingleScreenApp(params) {
125
+async function startSingleScreenApp(params) {
126 126
   if (!params.screen) {
127 127
     console.error('startSingleScreenApp(params): params.screen is required');
128 128
     return;
@@ -199,7 +199,7 @@ function startSingleScreenApp(params) {
199 199
   savePassProps(params);
200 200
 
201 201
   ControllerRegistry.registerController(controllerID, () => Controller);
202
-  ControllerRegistry.setRootController(controllerID, params.animationType, params.passProps || {});
202
+  return await ControllerRegistry.setRootController(controllerID, params.animationType, params.passProps || {});
203 203
 }
204 204
 
205 205
 function _mergeScreenSpecificSettings(screenID, screenInstanceID, params) {