Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit b5b2788

Browse files
author
Will Anderson
committed
Simplify reload bundle function
1 parent c9f9279 commit b5b2788

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

HybridMobileDeploy.m

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
#import "HybridMobileDeploy.h"
22

3+
#import "RCTBridgeModule.h"
34
#import "RCTRootView.h"
45
#import "RCTUtils.h"
56

67
@implementation HybridMobileDeploy
78

89
RCT_EXPORT_MODULE()
910

11+
RCTBridge * _bridge;
12+
13+
@synthesize bridge = _bridge;
14+
1015
+ (NSString *) getBundleFolderPath
1116
{
1217
NSString* home = NSHomeDirectory();
@@ -38,16 +43,11 @@ + (NSURL *) getBundleUrl
3843
}
3944
}
4045

41-
+ (void) loadBundle:(NSString*)rootComponent
46+
- (void) reloadBundle
4247
{
4348
dispatch_async(dispatch_get_main_queue(), ^{
44-
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:[self getBundleUrl]
45-
moduleName:rootComponent
46-
launchOptions:nil];
47-
48-
UIViewController *rootViewController = [[UIViewController alloc] init];
49-
rootViewController.view = rootView;
50-
[UIApplication sharedApplication].delegate.window.rootViewController = rootViewController;
49+
self.bridge.bundleURL = [HybridMobileDeploy getBundleUrl];
50+
[self.bridge reload];
5151
});
5252
}
5353

@@ -85,7 +85,7 @@ + (void) loadBundle:(NSString*)rootComponent
8585
// TODO send file path
8686
callback(@[RCTMakeError(@"Error saving file", err, [[NSDictionary alloc] initWithObjectsAndKeys:[HybridMobileDeploy getBundlePath],@"bundlePath", nil])]);
8787
} else {
88-
[HybridMobileDeploy loadBundle:[HybridMobileDeployConfig getRootComponent]];
88+
[self reloadBundle];
8989
callback(@[[NSNull null]]);
9090
}
9191
});

0 commit comments

Comments
 (0)