Explorar el Código

Fixes command completion event commandId (#4766)

* Fixes command completion event commandId

* Fix e2e
Yogev Ben David hace 5 años
padre
commit
0e29a03a40
No account linked to committer's email address

+ 3
- 3
e2e/StaticLifecycleEvents.test.js Ver fichero

@@ -17,7 +17,7 @@ describe('static lifecycle events', () => {
17 17
     await expect(elementByLabel('componentDidDisappear | EventsScreen')).toBeVisible();
18 18
   });
19 19
 
20
-  it(':ios: pushing and popping screen dispatch static event', async () => {
20
+  it('pushing and popping screen dispatch static event', async () => {
21 21
     await expect(elementByLabel('Static Lifecycle Events Overlay')).toBeVisible();
22 22
     await expect(elementByLabel('componentDidAppear | EventsOverlay')).toBeVisible();
23 23
     await elementById(TestIDs.PUSH_BTN).tap();
@@ -26,14 +26,14 @@ describe('static lifecycle events', () => {
26 26
     await expect(elementByLabel('pop')).toBeVisible();
27 27
   });
28 28
 
29
-  it(':ios: showModal and dismissModal dispatch static event', async () => {
29
+  it('showModal and dismissModal dispatch static event', async () => {
30 30
     await elementById(TestIDs.MODAL_BTN).tap();
31 31
     await expect(elementByLabel('showModal')).toBeVisible();
32 32
     await elementById(TestIDs.DISMISS_MODAL_BTN).tap();
33 33
     await expect(elementByLabel('dismissModal')).toBeVisible();
34 34
   });
35 35
 
36
-  it(':ios: unmounts when dismissed', async () => {
36
+  it('unmounts when dismissed', async () => {
37 37
     await elementById(TestIDs.PUSH_BTN).tap();
38 38
     await expect(elementByLabel('Static Lifecycle Events Overlay')).toBeVisible();
39 39
     await elementById(TestIDs.DISMISS_BTN).tap();

+ 11
- 11
lib/ios/RNNBridgeModule.m Ver fichero

@@ -20,7 +20,7 @@ RCT_EXPORT_MODULE();
20 20
 #pragma mark - JS interface
21 21
 
22 22
 RCT_EXPORT_METHOD(setRoot:(NSString*)commandId layout:(NSDictionary*)layout resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
23
-	[_commandsHandler setRoot:layout completion:^{
23
+	[_commandsHandler setRoot:layout commandId:commandId completion:^{
24 24
 		resolve(layout);
25 25
 	}];
26 26
 }
@@ -38,61 +38,61 @@ RCT_EXPORT_METHOD(setDefaultOptions:(NSDictionary*)options resolver:(RCTPromiseR
38 38
 }
39 39
 
40 40
 RCT_EXPORT_METHOD(push:(NSString*)commandId componentId:(NSString*)componentId layout:(NSDictionary*)layout resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
41
-	[_commandsHandler push:componentId layout:layout completion:^{
41
+	[_commandsHandler push:componentId commandId:commandId layout:layout completion:^{
42 42
 		resolve(componentId);
43 43
 	} rejection:reject];
44 44
 }
45 45
 
46 46
 RCT_EXPORT_METHOD(pop:(NSString*)commandId componentId:(NSString*)componentId mergeOptions:(NSDictionary*)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
47
-	[_commandsHandler pop:componentId mergeOptions:(NSDictionary*)options completion:^{
47
+	[_commandsHandler pop:componentId commandId:commandId mergeOptions:(NSDictionary*)options completion:^{
48 48
 		resolve(componentId);
49 49
 	} rejection:reject];
50 50
 }
51 51
 
52 52
 RCT_EXPORT_METHOD(setStackRoot:(NSString*)commandId componentId:(NSString*)componentId children:(NSArray*)children resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
53
-	[_commandsHandler setStackRoot:componentId children:children completion:^{
53
+	[_commandsHandler setStackRoot:componentId commandId:commandId children:children completion:^{
54 54
 		resolve(componentId);
55 55
 	} rejection:reject];
56 56
 }
57 57
 
58 58
 RCT_EXPORT_METHOD(popTo:(NSString*)commandId componentId:(NSString*)componentId mergeOptions:(NSDictionary*)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
59
-	[_commandsHandler popTo:componentId mergeOptions:options completion:^{
59
+	[_commandsHandler popTo:componentId commandId:commandId mergeOptions:options completion:^{
60 60
 		resolve(componentId);
61 61
 	} rejection:reject];
62 62
 }
63 63
 
64 64
 RCT_EXPORT_METHOD(popToRoot:(NSString*)commandId componentId:(NSString*)componentId mergeOptions:(NSDictionary*)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
65
-	[_commandsHandler popToRoot:componentId mergeOptions:options completion:^{
65
+	[_commandsHandler popToRoot:componentId commandId:commandId mergeOptions:options completion:^{
66 66
 		resolve(componentId);
67 67
 	} rejection:reject];
68 68
 }
69 69
 
70 70
 RCT_EXPORT_METHOD(showModal:(NSString*)commandId layout:(NSDictionary*)layout resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
71
-	[_commandsHandler showModal:layout completion:^(NSString *componentId) {
71
+	[_commandsHandler showModal:layout commandId:commandId completion:^(NSString *componentId) {
72 72
 		resolve(componentId);
73 73
 	}];
74 74
 }
75 75
 
76 76
 RCT_EXPORT_METHOD(dismissModal:(NSString*)commandId componentId:(NSString*)componentId mergeOptions:(NSDictionary*)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
77
-	[_commandsHandler dismissModal:componentId mergeOptions:options completion:^{
77
+	[_commandsHandler dismissModal:componentId commandId:commandId mergeOptions:options completion:^{
78 78
 		resolve(componentId);
79 79
 	} rejection:reject];
80 80
 }
81 81
 
82 82
 RCT_EXPORT_METHOD(dismissAllModals:(NSString*)commandId mergeOptions:(NSDictionary*)options resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
83
-	[_commandsHandler dismissAllModals:options completion:^{
83
+	[_commandsHandler dismissAllModals:options commandId:commandId completion:^{
84 84
 		resolve(nil);
85 85
 	}];
86 86
 }
87 87
 
88 88
 RCT_EXPORT_METHOD(showOverlay:(NSString*)commandId layout:(NSDictionary*)layout resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
89
-	[_commandsHandler showOverlay:layout completion:^{
89
+	[_commandsHandler showOverlay:layout commandId:commandId completion:^{
90 90
 		resolve(layout[@"id"]);
91 91
 	}];
92 92
 }
93 93
 
94 94
 RCT_EXPORT_METHOD(dismissOverlay:(NSString*)commandId componentId:(NSString*)componentId resolve:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
95
-	[_commandsHandler dismissOverlay:componentId completion:^{
95
+	[_commandsHandler dismissOverlay:componentId commandId:commandId completion:^{
96 96
 		resolve(@(1));
97 97
 	} rejection:reject];
98 98
 }

+ 11
- 11
lib/ios/RNNCommandsHandler.h Ver fichero

@@ -11,30 +11,30 @@
11 11
 
12 12
 - (instancetype)initWithStore:(RNNStore*)store controllerFactory:(RNNControllerFactory*)controllerFactory eventEmitter:(RNNEventEmitter *)eventEmitter stackManager:(RNNNavigationStackManager *)stackManager modalManager:(RNNModalManager *)modalManager overlayManager:(RNNOverlayManager *)overlayManager mainWindow:(UIWindow *)mainWindow;
13 13
 
14
-- (void)setRoot:(NSDictionary*)layout completion:(RNNTransitionCompletionBlock)completion;
14
+- (void)setRoot:(NSDictionary*)layout commandId:(NSString*)commandId completion:(RNNTransitionCompletionBlock)completion;
15 15
 
16 16
 - (void)mergeOptions:(NSString*)componentId options:(NSDictionary*)options completion:(RNNTransitionCompletionBlock)completion;
17 17
 
18 18
 - (void)setDefaultOptions:(NSDictionary*)options completion:(RNNTransitionCompletionBlock)completion;
19 19
 
20
-- (void)push:(NSString*)componentId layout:(NSDictionary*)layout completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection;
20
+- (void)push:(NSString*)componentId commandId:(NSString*)commandId layout:(NSDictionary*)layout completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection;
21 21
 
22
-- (void)pop:(NSString*)componentId mergeOptions:(NSDictionary*)options completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection;
22
+- (void)pop:(NSString*)componentId commandId:(NSString*)commandId mergeOptions:(NSDictionary*)options completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection;
23 23
 
24
-- (void)popTo:(NSString*)componentId mergeOptions:(NSDictionary*)options completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection;
24
+- (void)popTo:(NSString*)componentId commandId:(NSString*)commandId mergeOptions:(NSDictionary*)options completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection;
25 25
 
26
-- (void)popToRoot:(NSString*)componentId mergeOptions:(NSDictionary*)options completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection;
26
+- (void)popToRoot:(NSString*)componentId commandId:(NSString*)commandId mergeOptions:(NSDictionary*)options completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection;
27 27
 
28
-- (void)setStackRoot:(NSString*)componentId children:(NSArray*)children completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection;
28
+- (void)setStackRoot:(NSString*)componentId commandId:(NSString*)commandId children:(NSArray*)children completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection;
29 29
 
30
-- (void)showModal:(NSDictionary*)layout completion:(RNNTransitionWithComponentIdCompletionBlock)completion;
30
+- (void)showModal:(NSDictionary*)layout commandId:(NSString*)commandId completion:(RNNTransitionWithComponentIdCompletionBlock)completion;
31 31
 
32
-- (void)dismissModal:(NSString*)componentId mergeOptions:(NSDictionary*)options completion:(RNNTransitionCompletionBlock)completion rejection:(RNNTransitionRejectionBlock)reject;
32
+- (void)dismissModal:(NSString*)componentId commandId:(NSString*)commandId mergeOptions:(NSDictionary*)options completion:(RNNTransitionCompletionBlock)completion rejection:(RNNTransitionRejectionBlock)reject;
33 33
 
34
-- (void)dismissAllModals:(NSDictionary *)options completion:(RNNTransitionCompletionBlock)completion;
34
+- (void)dismissAllModals:(NSDictionary *)options commandId:(NSString*)commandId completion:(RNNTransitionCompletionBlock)completion;
35 35
 
36
-- (void)showOverlay:(NSDictionary *)layout completion:(RNNTransitionCompletionBlock)completion;
36
+- (void)showOverlay:(NSDictionary *)layout commandId:(NSString*)commandId completion:(RNNTransitionCompletionBlock)completion;
37 37
 
38
-- (void)dismissOverlay:(NSString*)componentId completion:(RNNTransitionCompletionBlock)completion rejection:(RNNTransitionRejectionBlock)reject;
38
+- (void)dismissOverlay:(NSString*)componentId commandId:(NSString*)commandId completion:(RNNTransitionCompletionBlock)completion rejection:(RNNTransitionRejectionBlock)reject;
39 39
 
40 40
 @end

+ 23
- 23
lib/ios/RNNCommandsHandler.m Ver fichero

@@ -53,7 +53,7 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
53 53
 
54 54
 #pragma mark - public
55 55
 
56
-- (void)setRoot:(NSDictionary*)layout completion:(RNNTransitionCompletionBlock)completion {
56
+- (void)setRoot:(NSDictionary*)layout commandId:(NSString*)commandId completion:(RNNTransitionCompletionBlock)completion {
57 57
 	[self assertReady];
58 58
 
59 59
 	if (@available(iOS 9, *)) {
@@ -79,7 +79,7 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
79 79
 	
80 80
 	[vc renderTreeAndWait:[vc.resolveOptions.animations.setRoot.waitForRender getWithDefaultValue:NO] perform:^{
81 81
 		_mainWindow.rootViewController = vc;
82
-		[_eventEmitter sendOnNavigationCommandCompletion:setRoot params:@{@"layout": layout}];
82
+		[_eventEmitter sendOnNavigationCommandCompletion:setRoot commandId:commandId params:@{@"layout": layout}];
83 83
 		completion() ;
84 84
 	}];
85 85
 }
@@ -111,7 +111,7 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
111 111
 	completion();
112 112
 }
113 113
 
114
-- (void)push:(NSString*)componentId layout:(NSDictionary*)layout completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
114
+- (void)push:(NSString*)componentId commandId:(NSString*)commandId layout:(NSDictionary*)layout completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
115 115
 	[self assertReady];
116 116
 	
117 117
 	UIViewController<RNNLayoutProtocol> *newVc = [_controllerFactory createLayout:layout];
@@ -131,7 +131,7 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
131 131
 				if ([newVc.resolveOptions.preview.commit getWithDefaultValue:NO]) {
132 132
 					[CATransaction begin];
133 133
 					[CATransaction setCompletionBlock:^{
134
-						[self->_eventEmitter sendOnNavigationCommandCompletion:push params:@{@"componentId": componentId}];
134
+						[self->_eventEmitter sendOnNavigationCommandCompletion:push commandId:commandId params:@{@"componentId": componentId}];
135 135
 						completion();
136 136
 					}];
137 137
 					[rvc.navigationController pushViewController:newVc animated:YES];
@@ -162,14 +162,14 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
162 162
 		id animationDelegate = (newVc.resolveOptions.animations.push.hasCustomAnimation || newVc.resolveOptions.customTransition.animations) ? newVc : nil;
163 163
 		[newVc renderTreeAndWait:([newVc.resolveOptions.animations.push.waitForRender getWithDefaultValue:NO] || animationDelegate) perform:^{
164 164
 			[_stackManager push:newVc onTop:fromVC animated:[newVc.resolveOptions.animations.push.enable getWithDefaultValue:YES] animationDelegate:animationDelegate completion:^{
165
-				[_eventEmitter sendOnNavigationCommandCompletion:push params:@{@"componentId": componentId}];
165
+				[_eventEmitter sendOnNavigationCommandCompletion:push commandId:commandId params:@{@"componentId": componentId}];
166 166
 				completion();
167 167
 			} rejection:rejection];
168 168
 		}];
169 169
 	}
170 170
 }
171 171
 
172
-- (void)setStackRoot:(NSString*)componentId children:(NSArray*)children completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
172
+- (void)setStackRoot:(NSString*)componentId commandId:(NSString*)commandId children:(NSArray*)children completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
173 173
 	[self assertReady];
174 174
 	
175 175
  	NSArray<RNNLayoutProtocol> *childViewControllers = [_controllerFactory createChildrenLayout:children];
@@ -180,12 +180,12 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
180 180
 	UIViewController *fromVC = [_store findComponentForId:componentId];
181 181
 	__weak typeof(RNNEventEmitter*) weakEventEmitter = _eventEmitter;
182 182
 	[_stackManager setStackChildren:childViewControllers fromViewController:fromVC animated:[options.animations.setStackRoot.enable getWithDefaultValue:YES] completion:^{
183
-		[weakEventEmitter sendOnNavigationCommandCompletion:setStackRoot params:@{@"componentId": componentId}];
183
+		[weakEventEmitter sendOnNavigationCommandCompletion:setStackRoot commandId:commandId params:@{@"componentId": componentId}];
184 184
 		completion();
185 185
 	} rejection:rejection];
186 186
 }
187 187
 
188
-- (void)pop:(NSString*)componentId mergeOptions:(NSDictionary*)mergeOptions completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
188
+- (void)pop:(NSString*)componentId commandId:(NSString*)commandId mergeOptions:(NSDictionary*)mergeOptions completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
189 189
 	[self assertReady];
190 190
 	
191 191
 	RNNRootViewController *vc = (RNNRootViewController*)[_store findComponentForId:componentId];
@@ -208,25 +208,25 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
208 208
 	
209 209
 	[_stackManager pop:vc animated:[vc.resolveOptions.animations.pop.enable getWithDefaultValue:YES] completion:^{
210 210
 		[_store removeComponent:componentId];
211
-		[_eventEmitter sendOnNavigationCommandCompletion:pop params:@{@"componentId": componentId}];
211
+		[_eventEmitter sendOnNavigationCommandCompletion:pop commandId:commandId params:@{@"componentId": componentId}];
212 212
 		completion();
213 213
 	} rejection:rejection];
214 214
 }
215 215
 
216
-- (void)popTo:(NSString*)componentId mergeOptions:(NSDictionary *)mergeOptions completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
216
+- (void)popTo:(NSString*)componentId commandId:(NSString*)commandId mergeOptions:(NSDictionary *)mergeOptions completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
217 217
 	[self assertReady];
218 218
 	RNNRootViewController *vc = (RNNRootViewController*)[_store findComponentForId:componentId];
219 219
 	RNNNavigationOptions *options = [[RNNNavigationOptions alloc] initWithDict:mergeOptions];
220 220
 	[vc overrideOptions:options];
221 221
 	
222 222
 	[_stackManager popTo:vc animated:[vc.resolveOptions.animations.pop.enable getWithDefaultValue:YES] completion:^(NSArray *poppedViewControllers) {
223
-		[_eventEmitter sendOnNavigationCommandCompletion:popTo params:@{@"componentId": componentId}];
223
+		[_eventEmitter sendOnNavigationCommandCompletion:popTo commandId:commandId params:@{@"componentId": componentId}];
224 224
 		[self removePopedViewControllers:poppedViewControllers];
225 225
 		completion();
226 226
 	} rejection:rejection];
227 227
 }
228 228
 
229
-- (void)popToRoot:(NSString*)componentId mergeOptions:(NSDictionary *)mergeOptions completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
229
+- (void)popToRoot:(NSString*)componentId commandId:(NSString*)commandId mergeOptions:(NSDictionary *)mergeOptions completion:(RNNTransitionCompletionBlock)completion rejection:(RCTPromiseRejectBlock)rejection {
230 230
 	[self assertReady];
231 231
 	RNNRootViewController *vc = (RNNRootViewController*)[_store findComponentForId:componentId];
232 232
 	RNNNavigationOptions *options = [[RNNNavigationOptions alloc] initWithDict:mergeOptions];
@@ -234,7 +234,7 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
234 234
 	
235 235
 	[CATransaction begin];
236 236
 	[CATransaction setCompletionBlock:^{
237
-		[_eventEmitter sendOnNavigationCommandCompletion:popToRoot params:@{@"componentId": componentId}];
237
+		[_eventEmitter sendOnNavigationCommandCompletion:popToRoot commandId:commandId params:@{@"componentId": componentId}];
238 238
 		completion();
239 239
 	}];
240 240
 	
@@ -247,20 +247,20 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
247 247
 	[CATransaction commit];
248 248
 }
249 249
 
250
-- (void)showModal:(NSDictionary*)layout completion:(RNNTransitionWithComponentIdCompletionBlock)completion {
250
+- (void)showModal:(NSDictionary*)layout commandId:(NSString *)commandId completion:(RNNTransitionWithComponentIdCompletionBlock)completion {
251 251
 	[self assertReady];
252 252
 	
253 253
 	UIViewController<RNNParentProtocol> *newVc = [_controllerFactory createLayout:layout];
254 254
 	
255 255
 	[newVc renderTreeAndWait:[newVc.resolveOptions.animations.showModal.waitForRender getWithDefaultValue:NO] perform:^{
256 256
 		[_modalManager showModal:newVc animated:[newVc.getCurrentChild.resolveOptions.animations.showModal.enable getWithDefaultValue:YES] hasCustomAnimation:newVc.getCurrentChild.resolveOptions.animations.showModal.hasCustomAnimation completion:^(NSString *componentId) {
257
-			[_eventEmitter sendOnNavigationCommandCompletion:showModal params:@{@"layout": layout}];
257
+			[_eventEmitter sendOnNavigationCommandCompletion:showModal commandId:commandId params:@{@"layout": layout}];
258 258
 			completion(componentId);
259 259
 		}];
260 260
 	}];
261 261
 }
262 262
 
263
-- (void)dismissModal:(NSString*)componentId mergeOptions:(NSDictionary *)mergeOptions completion:(RNNTransitionCompletionBlock)completion rejection:(RNNTransitionRejectionBlock)reject {
263
+- (void)dismissModal:(NSString*)componentId commandId:(NSString*)commandId mergeOptions:(NSDictionary *)mergeOptions completion:(RNNTransitionCompletionBlock)completion rejection:(RNNTransitionRejectionBlock)reject {
264 264
 	[self assertReady];
265 265
 	
266 266
 	UIViewController<RNNParentProtocol> *modalToDismiss = (UIViewController<RNNParentProtocol>*)[_store findComponentForId:componentId];
@@ -277,7 +277,7 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
277 277
 	
278 278
 	[CATransaction begin];
279 279
 	[CATransaction setCompletionBlock:^{
280
-		[_eventEmitter sendOnNavigationCommandCompletion:dismissModal params:@{@"componentId": componentId}];
280
+		[_eventEmitter sendOnNavigationCommandCompletion:dismissModal commandId:commandId params:@{@"componentId": componentId}];
281 281
 	}];
282 282
 	
283 283
 	[_modalManager dismissModal:modalToDismiss completion:completion];
@@ -285,12 +285,12 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
285 285
 	[CATransaction commit];
286 286
 }
287 287
 
288
-- (void)dismissAllModals:(NSDictionary *)mergeOptions completion:(RNNTransitionCompletionBlock)completion {
288
+- (void)dismissAllModals:(NSDictionary *)mergeOptions commandId:(NSString*)commandId completion:(RNNTransitionCompletionBlock)completion {
289 289
 	[self assertReady];
290 290
 	
291 291
 	[CATransaction begin];
292 292
 	[CATransaction setCompletionBlock:^{
293
-		[_eventEmitter sendOnNavigationCommandCompletion:dismissAllModals params:@{}];
293
+		[_eventEmitter sendOnNavigationCommandCompletion:dismissAllModals commandId:commandId params:@{}];
294 294
 		completion();
295 295
 	}];
296 296
 	RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initWithDict:mergeOptions];
@@ -299,7 +299,7 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
299 299
 	[CATransaction commit];
300 300
 }
301 301
 
302
-- (void)showOverlay:(NSDictionary *)layout completion:(RNNTransitionCompletionBlock)completion {
302
+- (void)showOverlay:(NSDictionary *)layout commandId:(NSString*)commandId completion:(RNNTransitionCompletionBlock)completion {
303 303
 	[self assertReady];
304 304
 	
305 305
 	UIViewController<RNNParentProtocol>* overlayVC = [_controllerFactory createLayout:layout];
@@ -307,17 +307,17 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
307 307
 		UIWindow* overlayWindow = [[RNNOverlayWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
308 308
 		overlayWindow.rootViewController = overlayVC;
309 309
 		[_overlayManager showOverlayWindow:overlayWindow];
310
-		[_eventEmitter sendOnNavigationCommandCompletion:showOverlay params:@{@"layout": layout}];
310
+		[_eventEmitter sendOnNavigationCommandCompletion:showOverlay commandId:commandId params:@{@"layout": layout}];
311 311
 		completion();
312 312
 	}];
313 313
 }
314 314
 
315
-- (void)dismissOverlay:(NSString*)componentId completion:(RNNTransitionCompletionBlock)completion rejection:(RNNTransitionRejectionBlock)reject {
315
+- (void)dismissOverlay:(NSString*)componentId commandId:(NSString*)commandId completion:(RNNTransitionCompletionBlock)completion rejection:(RNNTransitionRejectionBlock)reject {
316 316
 	[self assertReady];
317 317
 	UIViewController* viewController = [_store findComponentForId:componentId];
318 318
 	if (viewController) {
319 319
 		[_overlayManager dismissOverlay:viewController];
320
-		[_eventEmitter sendOnNavigationCommandCompletion:dismissOverlay params:@{@"componentId": componentId}];
320
+		[_eventEmitter sendOnNavigationCommandCompletion:dismissOverlay commandId:commandId params:@{@"componentId": componentId}];
321 321
 		completion();
322 322
 	} else {
323 323
 		[RNNErrorHandler reject:reject withErrorCode:1010 errorDescription:@"ComponentId not found"];

+ 9
- 9
lib/ios/RNNEventEmitter.h Ver fichero

@@ -6,23 +6,23 @@
6 6
 
7 7
 @interface RNNEventEmitter : RCTEventEmitter <RCTBridgeModule>
8 8
 
9
--(void)sendOnAppLaunched;
9
+- (void)sendOnAppLaunched;
10 10
 
11
--(void)sendComponentDidAppear:(NSString*)componentId componentName:(NSString*)componentName;
11
+- (void)sendComponentDidAppear:(NSString*)componentId componentName:(NSString*)componentName;
12 12
 
13
--(void)sendComponentDidDisappear:(NSString*)componentId componentName:(NSString*)componentName;
13
+- (void)sendComponentDidDisappear:(NSString*)componentId componentName:(NSString*)componentName;
14 14
 
15
--(void)sendOnNavigationButtonPressed:(NSString*)componentId buttonId:(NSString*)buttonId;
15
+- (void)sendOnNavigationButtonPressed:(NSString*)componentId buttonId:(NSString*)buttonId;
16 16
 
17
--(void)sendBottomTabSelected:(NSNumber *)selectedTabIndex unselected:(NSNumber*)unselectedTabIndex;
17
+- (void)sendBottomTabSelected:(NSNumber *)selectedTabIndex unselected:(NSNumber*)unselectedTabIndex;
18 18
 
19
--(void)sendOnNavigationCommandCompletion:(NSString *)commandName params:(NSDictionary*)params;
19
+- (void)sendOnNavigationCommandCompletion:(NSString *)commandName commandId:(NSString *)commandId params:(NSDictionary*)params;
20 20
 
21
--(void)sendOnSearchBarUpdated:(NSString *)componentId text:(NSString*)text isFocused:(BOOL)isFocused;
21
+- (void)sendOnSearchBarUpdated:(NSString *)componentId text:(NSString*)text isFocused:(BOOL)isFocused;
22 22
 
23
--(void)sendOnSearchBarCancelPressed:(NSString *)componentId;
23
+- (void)sendOnSearchBarCancelPressed:(NSString *)componentId;
24 24
 
25
--(void)sendOnPreviewCompleted:(NSString *)componentId previewComponentId:(NSString *)previewComponentId;
25
+- (void)sendOnPreviewCompleted:(NSString *)componentId previewComponentId:(NSString *)previewComponentId;
26 26
 
27 27
 - (void)sendModalsDismissedEvent:(NSString *)componentId numberOfModalsDismissed:(NSNumber *)modalsDismissed;
28 28
 

+ 3
- 2
lib/ios/RNNEventEmitter.m Ver fichero

@@ -70,9 +70,10 @@ static NSString* const PreviewCompleted         = @"RNN.PreviewCompleted";
70 70
 									  }];
71 71
 }
72 72
 
73
--(void)sendOnNavigationCommandCompletion:(NSString *)commandName params:(NSDictionary*)params {
73
+-(void)sendOnNavigationCommandCompletion:(NSString *)commandName commandId:(NSString *)commandId params:(NSDictionary*)params {
74 74
 	[self send:CommandCompleted body:@{
75
-									   @"commandId":commandName,
75
+									   @"commandId":commandId,
76
+									   @"commandName":commandName,
76 77
 									   @"params": params,
77 78
 									   @"completionTime": [RNNUtils getCurrentTimestamp]
78 79
 									   }];

+ 21
- 21
lib/ios/ReactNativeNavigationTests/RNNCommandsHandlerTest.m Ver fichero

@@ -82,9 +82,9 @@
82 82
 	for (NSString* methodName in methods) {
83 83
 		SEL s = NSSelectorFromString(methodName);
84 84
 		IMP imp = [self.uut methodForSelector:s];
85
-		void (*func)(id, SEL, id, id, id) = (void *)imp;
85
+		void (*func)(id, SEL, id, id, id, id, id) = (void *)imp;
86 86
 		
87
-		XCTAssertThrowsSpecificNamed(func(self.uut,s, nil, nil, nil), NSException, @"BridgeNotLoadedError");
87
+		XCTAssertThrowsSpecificNamed(func(self.uut,s, nil, nil, nil, nil, nil), NSException, @"BridgeNotLoadedError");
88 88
 	}
89 89
 }
90 90
 
@@ -168,7 +168,7 @@
168 168
 	[self.store setReadyToReceiveCommands:true];
169 169
 	XCTestExpectation *expectation = [self expectationWithDescription:@"Testing Async Method"];
170 170
 	
171
-	[self.uut pop:@"vc3" mergeOptions:nil completion:^{
171
+	[self.uut pop:@"vc3" commandId:@"" mergeOptions:nil completion:^{
172 172
 		XCTAssertNil([self.store findComponentForId:@"vc3"]);
173 173
 		XCTAssertNotNil([self.store findComponentForId:@"vc2"]);
174 174
 		XCTAssertNotNil([self.store findComponentForId:@"vc1"]);
@@ -184,7 +184,7 @@
184 184
 	[self.store setReadyToReceiveCommands:true];
185 185
 	XCTestExpectation *expectation = [self expectationWithDescription:@"Testing Async Method"];
186 186
 	_nvc.willReturnVCs = @[self.vc2, self.vc3];
187
-	[self.uut popTo:@"vc1" mergeOptions:nil completion:^{
187
+	[self.uut popTo:@"vc1" commandId:@"" mergeOptions:nil completion:^{
188 188
 		XCTAssertNil([self.store findComponentForId:@"vc2"]);
189 189
 		XCTAssertNil([self.store findComponentForId:@"vc3"]);
190 190
 		XCTAssertNotNil([self.store findComponentForId:@"vc1"]);
@@ -198,7 +198,7 @@
198 198
 	[self.store setReadyToReceiveCommands:true];
199 199
 	_nvc.willReturnVCs = @[self.vc2, self.vc3];
200 200
 	XCTestExpectation *expectation = [self expectationWithDescription:@"Testing Async Method"];
201
-	[self.uut popToRoot:@"vc3" mergeOptions:nil completion:^{
201
+	[self.uut popToRoot:@"vc3" commandId:@"" mergeOptions:nil completion:^{
202 202
 		XCTAssertNil([self.store findComponentForId:@"vc2"]);
203 203
 		XCTAssertNil([self.store findComponentForId:@"vc3"]);
204 204
 		XCTAssertNotNil([self.store findComponentForId:@"vc1"]);
@@ -214,7 +214,7 @@
214 214
 	NSDictionary* layout = @{};
215 215
 	
216 216
 	[[self.controllerFactory expect] createLayout:layout];
217
-	[self.uut showOverlay:layout completion:^{}];
217
+	[self.uut showOverlay:layout commandId:@"" completion:^{}];
218 218
 	[self.controllerFactory verify];
219 219
 }
220 220
 
@@ -224,7 +224,7 @@
224 224
 	OCMStub([self.controllerFactory createLayout:[OCMArg any]]);
225 225
 	
226 226
 	[[self.controllerFactory expect] createLayout:[OCMArg any]];
227
-	[self.uut showOverlay:@{} completion:^{}];
227
+	[self.uut showOverlay:@{} commandId:@"" completion:^{}];
228 228
 	[self.overlayManager verify];
229 229
 }
230 230
 
@@ -234,7 +234,7 @@
234 234
 	OCMStub([self.controllerFactory createLayout:[OCMArg any]]).andReturn(layoutVC);
235 235
 	
236 236
 	[[self.overlayManager expect] showOverlayWindow:[OCMArg any]];
237
-	[self.uut showOverlay:@{} completion:^{}];
237
+	[self.uut showOverlay:@{} commandId:@"" completion:^{}];
238 238
 	[self.overlayManager verify];
239 239
 }
240 240
 
@@ -246,8 +246,8 @@
246 246
 	
247 247
 	NSDictionary* layout = @{};
248 248
 	
249
-	[[self.eventEmmiter expect] sendOnNavigationCommandCompletion:@"showOverlay" params:[OCMArg any]];
250
-	[self.uut showOverlay:layout completion:^{}];
249
+	[[self.eventEmmiter expect] sendOnNavigationCommandCompletion:@"showOverlay" commandId:[OCMArg any] params:[OCMArg any]];
250
+	[self.uut showOverlay:layout commandId:@"" completion:^{}];
251 251
 	[self.eventEmmiter verify];
252 252
 }
253 253
 
@@ -255,7 +255,7 @@
255 255
 	[self.store setReadyToReceiveCommands:true];
256 256
 	NSString* componentId = @"componentId";
257 257
 	[[self.store expect] findComponentForId:componentId];
258
-	[self.uut dismissOverlay:componentId completion:^{} rejection:^(NSString *code, NSString *message, NSError *error) {}];
258
+	[self.uut dismissOverlay:componentId commandId:@"" completion:^{} rejection:^(NSString *code, NSString *message, NSError *error) {}];
259 259
 	[self.store verify];
260 260
 }
261 261
 
@@ -266,7 +266,7 @@
266 266
 	OCMStub([self.store findComponentForId:componentId]).andReturn(returnedView);
267 267
 	
268 268
 	[[self.overlayManager expect] dismissOverlay:returnedView];
269
-	[self.uut dismissOverlay:componentId completion:^{} rejection:^(NSString *code, NSString *message, NSError *error) {}];
269
+	[self.uut dismissOverlay:componentId commandId:@"" completion:^{} rejection:^(NSString *code, NSString *message, NSError *error) {}];
270 270
 	[self.overlayManager verify];
271 271
 }
272 272
 
@@ -276,7 +276,7 @@
276 276
 	id errorHandlerMockClass = [OCMockObject mockForClass:[RNNErrorHandler class]];
277 277
 	
278 278
 	[[errorHandlerMockClass expect] reject:[OCMArg any] withErrorCode:1010 errorDescription:[OCMArg any]];
279
-	[self.uut dismissOverlay:componentId completion:[OCMArg any] rejection:[OCMArg any]];
279
+	[self.uut dismissOverlay:componentId commandId:@"" completion:[OCMArg any] rejection:[OCMArg any]];
280 280
 	[errorHandlerMockClass verify];
281 281
 }
282 282
 
@@ -285,8 +285,8 @@
285 285
 	NSString* componentId = @"componentId";
286 286
 	OCMStub([self.store findComponentForId:componentId]).andReturn([UIViewController new]);
287 287
 	
288
-	[[self.eventEmmiter expect] sendOnNavigationCommandCompletion:@"dismissOverlay" params:[OCMArg any]];
289
-	[self.uut dismissOverlay:componentId completion:^{
288
+	[[self.eventEmmiter expect] sendOnNavigationCommandCompletion:@"dismissOverlay" commandId:[OCMArg any] params:[OCMArg any]];
289
+	[self.uut dismissOverlay:componentId commandId:@"" completion:^{
290 290
 		
291 291
 	} rejection:^(NSString *code, NSString *message, NSError *error) {}];
292 292
 	
@@ -298,7 +298,7 @@
298 298
 	OCMStub([self.controllerFactory createLayout:[OCMArg any]]).andReturn(self.vc1);
299 299
 	
300 300
 	[[self.mainWindow expect] setRootViewController:self.vc1];
301
-	[self.uut setRoot:@{} completion:^{}];
301
+	[self.uut setRoot:@{} commandId:@"" completion:^{}];
302 302
 	[self.mainWindow verify];
303 303
 }
304 304
 
@@ -307,14 +307,14 @@
307 307
 	OCMStub([self.controllerFactory createLayout:[OCMArg any]]).andReturn(self.vc1);
308 308
 	
309 309
 	[[self.store expect] removeAllComponentsFromWindow:self.mainWindow];
310
-	[self.uut setRoot:@{} completion:^{}];
310
+	[self.uut setRoot:@{} commandId:@"" completion:^{}];
311 311
 	[self.store verify];
312 312
 }
313 313
 
314 314
 - (void)testSetStackRoot_resetStackWithSingleComponent {
315 315
 	OCMStub([self.controllerFactory createChildrenLayout:[OCMArg any]]).andReturn(@[self.vc2]);
316 316
 	[self.store setReadyToReceiveCommands:true];
317
-	[self.uut setStackRoot:@"vc1" children:nil completion:^{
317
+	[self.uut setStackRoot:@"vc1" commandId:@"" children:nil completion:^{
318 318
 		
319 319
 	} rejection:^(NSString *code, NSString *message, NSError *error) {
320 320
 		
@@ -327,7 +327,7 @@
327 327
 	NSArray* newViewControllers = @[_vc1, _vc3];
328 328
 	OCMStub([self.controllerFactory createChildrenLayout:[OCMArg any]]).andReturn(newViewControllers);
329 329
 	[self.store setReadyToReceiveCommands:true];
330
-	[self.uut setStackRoot:@"vc1" children:nil completion:^{
330
+	[self.uut setStackRoot:@"vc1" commandId:@"" children:nil completion:^{
331 331
 		
332 332
 	} rejection:^(NSString *code, NSString *message, NSError *error) {
333 333
 		
@@ -344,7 +344,7 @@
344 344
 	OCMStub([self.controllerFactory createLayout:[OCMArg any]]).andReturn(mockedVC);
345 345
 	
346 346
 	[[mockedVC expect] renderTreeAndWait:YES perform:[OCMArg any]];
347
-	[self.uut setRoot:@{} completion:^{}];
347
+	[self.uut setRoot:@{} commandId:@"" completion:^{}];
348 348
 	[mockedVC verify];
349 349
 }
350 350
 
@@ -357,7 +357,7 @@
357 357
 	OCMStub([self.controllerFactory createLayout:[OCMArg any]]).andReturn(mockedVC);
358 358
 	
359 359
 	[[mockedVC expect] renderTreeAndWait:NO perform:[OCMArg any]];
360
-	[self.uut setRoot:@{} completion:^{}];
360
+	[self.uut setRoot:@{} commandId:@"" completion:^{}];
361 361
 	[mockedVC verify];
362 362
 }
363 363
 

+ 4
- 2
playground/src/screens/StaticLifecycleOverlay.js Ver fichero

@@ -31,9 +31,9 @@ class StaticLifecycleOverlay extends Component {
31 31
         events: [...this.state.events, { ...event }]
32 32
       });
33 33
     }));
34
-    this.listeners.push(Navigation.events().registerCommandCompletedListener(({ commandId }) => {
34
+    this.listeners.push(Navigation.events().registerCommandListener((commandName) => {
35 35
       this.setState({
36
-        events: [...this.state.events, { event: 'commandCompleted', commandId }]
36
+        events: [...this.state.events, { event: 'command started', commandName }]
37 37
       });
38 38
     }));
39 39
     this.listeners.push(Navigation.events().registerNavigationButtonPressedListener(({ componentId, buttonId }) => {
@@ -57,6 +57,8 @@ class StaticLifecycleOverlay extends Component {
57 57
   renderEvent(event) {
58 58
     if (event.commandId) {
59 59
       return <Text style={styles.h2}>{`${event.commandId}`}</Text>;
60
+    } else if (event.commandName) {
61
+      return <Text style={styles.h2}>{`${event.commandName}`}</Text>;
60 62
     } else if (event.componentName) {
61 63
       return <Text style={styles.h2}>{`${event.event} | ${event.componentName}`}</Text>;
62 64
     } else if (event.buttonId) {