|
@@ -17,8 +17,11 @@
|
17
|
17
|
@implementation ReactNativeNavigation {
|
18
|
18
|
NSURL* _jsCodeLocation;
|
19
|
19
|
NSDictionary* _launchOptions;
|
20
|
|
- RNNStore* _store;
|
21
|
20
|
RCTBridge* _bridge;
|
|
21
|
+
|
|
22
|
+ RNNStore* _store;
|
|
23
|
+
|
|
24
|
+ RNNCommandsHandler* _commandsHandler;
|
22
|
25
|
}
|
23
|
26
|
|
24
|
27
|
# pragma mark - public API
|
|
@@ -67,8 +70,8 @@
|
67
|
70
|
|
68
|
71
|
id<RNNRootViewCreator> rootViewCreator = [[RNNReactRootViewCreator alloc] initWithBridge:bridge];
|
69
|
72
|
RNNControllerFactory *controllerFactory = [[RNNControllerFactory alloc] initWithRootViewCreator:rootViewCreator store:_store eventEmitter:eventEmitter];
|
70
|
|
- RNNCommandsHandler *commandsHandler = [[RNNCommandsHandler alloc] initWithStore:_store controllerFactory:controllerFactory];
|
71
|
|
- RNNBridgeModule *bridgeModule = [[RNNBridgeModule alloc] initWithCommandsHandler:commandsHandler];
|
|
73
|
+ _commandsHandler = [[RNNCommandsHandler alloc] initWithStore:_store controllerFactory:controllerFactory];
|
|
74
|
+ RNNBridgeModule *bridgeModule = [[RNNBridgeModule alloc] initWithCommandsHandler:_commandsHandler];
|
72
|
75
|
|
73
|
76
|
return @[bridgeModule,eventEmitter];
|
74
|
77
|
}
|
|
@@ -76,7 +79,7 @@
|
76
|
79
|
# pragma mark - js events
|
77
|
80
|
|
78
|
81
|
-(void)onJavaScriptWillLoad {
|
79
|
|
- [self resetRootViewControllerOnlyOnJSDevReload];
|
|
82
|
+ [self releaseBeforeJSReload];
|
80
|
83
|
[_store clean];
|
81
|
84
|
}
|
82
|
85
|
|
|
@@ -102,16 +105,25 @@
|
102
|
105
|
object:nil];
|
103
|
106
|
}
|
104
|
107
|
|
105
|
|
--(void)resetRootViewControllerOnlyOnJSDevReload {
|
|
108
|
+-(void)releaseBeforeJSReload {
|
106
|
109
|
#ifdef DEBUG
|
107
|
|
-
|
108
|
|
- if(![UIApplication.sharedApplication.delegate.window.rootViewController isKindOfClass:[RNNSplashScreen class]]) {
|
109
|
|
- UIApplication.sharedApplication.delegate.window.rootViewController = nil;
|
110
|
|
- }
|
111
|
|
-
|
|
110
|
+// if(![UIApplication.sharedApplication.delegate.window.rootViewController isKindOfClass:[RNNSplashScreen class]]) {
|
|
111
|
+// [self releaseBeforeJsReload:UIApplication.sharedApplication.delegate.window.rootViewController];
|
|
112
|
+// }
|
112
|
113
|
#endif
|
113
|
114
|
}
|
114
|
115
|
|
115
|
|
-
|
|
116
|
+//-(void)releaseBeforeJsReload:(UIViewController*)vc {
|
|
117
|
+// if(!vc) return;
|
|
118
|
+//
|
|
119
|
+// for (UIViewController* child in vc.childViewControllers) {
|
|
120
|
+// [self releaseBeforeJsReload:child];
|
|
121
|
+// }
|
|
122
|
+// [self releaseBeforeJsReload:vc.presentedViewController];
|
|
123
|
+//
|
|
124
|
+// [NSNotificationCenter.defaultCenter removeObserver:vc];
|
|
125
|
+// [NSNotificationCenter.defaultCenter removeObserver:vc.view];
|
|
126
|
+// vc.view = nil;
|
|
127
|
+//}
|
116
|
128
|
|
117
|
129
|
@end
|