Browse Source

Fixes command completion event commandId (#4766)

* Fixes command completion event commandId

* Fix e2e
Yogev Ben David 5 years ago
parent
commit
0e29a03a40
No account linked to committer's email address

+ 3
- 3
e2e/StaticLifecycleEvents.test.js View File

17
     await expect(elementByLabel('componentDidDisappear | EventsScreen')).toBeVisible();
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
     await expect(elementByLabel('Static Lifecycle Events Overlay')).toBeVisible();
21
     await expect(elementByLabel('Static Lifecycle Events Overlay')).toBeVisible();
22
     await expect(elementByLabel('componentDidAppear | EventsOverlay')).toBeVisible();
22
     await expect(elementByLabel('componentDidAppear | EventsOverlay')).toBeVisible();
23
     await elementById(TestIDs.PUSH_BTN).tap();
23
     await elementById(TestIDs.PUSH_BTN).tap();
26
     await expect(elementByLabel('pop')).toBeVisible();
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
     await elementById(TestIDs.MODAL_BTN).tap();
30
     await elementById(TestIDs.MODAL_BTN).tap();
31
     await expect(elementByLabel('showModal')).toBeVisible();
31
     await expect(elementByLabel('showModal')).toBeVisible();
32
     await elementById(TestIDs.DISMISS_MODAL_BTN).tap();
32
     await elementById(TestIDs.DISMISS_MODAL_BTN).tap();
33
     await expect(elementByLabel('dismissModal')).toBeVisible();
33
     await expect(elementByLabel('dismissModal')).toBeVisible();
34
   });
34
   });
35
 
35
 
36
-  it(':ios: unmounts when dismissed', async () => {
36
+  it('unmounts when dismissed', async () => {
37
     await elementById(TestIDs.PUSH_BTN).tap();
37
     await elementById(TestIDs.PUSH_BTN).tap();
38
     await expect(elementByLabel('Static Lifecycle Events Overlay')).toBeVisible();
38
     await expect(elementByLabel('Static Lifecycle Events Overlay')).toBeVisible();
39
     await elementById(TestIDs.DISMISS_BTN).tap();
39
     await elementById(TestIDs.DISMISS_BTN).tap();

+ 11
- 11
lib/ios/RNNBridgeModule.m View File

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

+ 11
- 11
lib/ios/RNNCommandsHandler.h View File

11
 
11
 
12
 - (instancetype)initWithStore:(RNNStore*)store controllerFactory:(RNNControllerFactory*)controllerFactory eventEmitter:(RNNEventEmitter *)eventEmitter stackManager:(RNNNavigationStackManager *)stackManager modalManager:(RNNModalManager *)modalManager overlayManager:(RNNOverlayManager *)overlayManager mainWindow:(UIWindow *)mainWindow;
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
 - (void)mergeOptions:(NSString*)componentId options:(NSDictionary*)options completion:(RNNTransitionCompletionBlock)completion;
16
 - (void)mergeOptions:(NSString*)componentId options:(NSDictionary*)options completion:(RNNTransitionCompletionBlock)completion;
17
 
17
 
18
 - (void)setDefaultOptions:(NSDictionary*)options completion:(RNNTransitionCompletionBlock)completion;
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
 @end
40
 @end

+ 23
- 23
lib/ios/RNNCommandsHandler.m View File

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

+ 9
- 9
lib/ios/RNNEventEmitter.h View File

6
 
6
 
7
 @interface RNNEventEmitter : RCTEventEmitter <RCTBridgeModule>
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
 - (void)sendModalsDismissedEvent:(NSString *)componentId numberOfModalsDismissed:(NSNumber *)modalsDismissed;
27
 - (void)sendModalsDismissedEvent:(NSString *)componentId numberOfModalsDismissed:(NSNumber *)modalsDismissed;
28
 
28
 

+ 3
- 2
lib/ios/RNNEventEmitter.m View File

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
 	[self send:CommandCompleted body:@{
74
 	[self send:CommandCompleted body:@{
75
-									   @"commandId":commandName,
75
+									   @"commandId":commandId,
76
+									   @"commandName":commandName,
76
 									   @"params": params,
77
 									   @"params": params,
77
 									   @"completionTime": [RNNUtils getCurrentTimestamp]
78
 									   @"completionTime": [RNNUtils getCurrentTimestamp]
78
 									   }];
79
 									   }];

+ 21
- 21
lib/ios/ReactNativeNavigationTests/RNNCommandsHandlerTest.m View File

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

+ 4
- 2
playground/src/screens/StaticLifecycleOverlay.js View File

31
         events: [...this.state.events, { ...event }]
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
       this.setState({
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
     this.listeners.push(Navigation.events().registerNavigationButtonPressedListener(({ componentId, buttonId }) => {
39
     this.listeners.push(Navigation.events().registerNavigationButtonPressedListener(({ componentId, buttonId }) => {
57
   renderEvent(event) {
57
   renderEvent(event) {
58
     if (event.commandId) {
58
     if (event.commandId) {
59
       return <Text style={styles.h2}>{`${event.commandId}`}</Text>;
59
       return <Text style={styles.h2}>{`${event.commandId}`}</Text>;
60
+    } else if (event.commandName) {
61
+      return <Text style={styles.h2}>{`${event.commandName}`}</Text>;
60
     } else if (event.componentName) {
62
     } else if (event.componentName) {
61
       return <Text style={styles.h2}>{`${event.event} | ${event.componentName}`}</Text>;
63
       return <Text style={styles.h2}>{`${event.event} | ${event.componentName}`}</Text>;
62
     } else if (event.buttonId) {
64
     } else if (event.buttonId) {