Skip to content

Commit

Permalink
[Init] Add the executor class to RCTBridge's init method
Browse files Browse the repository at this point in the history
If you construct an RCTBridge you may want to configure the executor. However the constructor synchronously calls `setUp` and sets up the executor. Instead, let the code that constructs the bridge specify the executor class up front.

Now that RCTRootView takes a bridge in one of its initializers, it is possible to create a bridge with a custom executor and then use that to set up a root view.

Fixes #288
  • Loading branch information
ide committed Apr 3, 2015
1 parent d42ffaa commit 10610a5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Libraries/RCTTest/RCTTestRunner.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ - (void)runTest:(SEL)test module:(NSString *)moduleName initialProps:(NSDictiona
moduleProvider:^(){
return @[testModule];
}
launchOptions:nil];
launchOptions:nil
executorClass:Nil];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
moduleName:moduleName];
testModule.view = rootView;
Expand Down
3 changes: 2 additions & 1 deletion React/Base/RCTBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ extern NSString *const RCTReloadBridge;
*/
- (instancetype)initWithBundlePath:(NSString *)bundlepath
moduleProvider:(RCTBridgeModuleProviderBlock)block
launchOptions:(NSDictionary *)launchOptions NS_DESIGNATED_INITIALIZER;
launchOptions:(NSDictionary *)launchOptions
executorClass:(Class)executorClass NS_DESIGNATED_INITIALIZER;

/**
* This method is used to call functions in the JavaScript application context.
Expand Down
2 changes: 2 additions & 0 deletions React/Base/RCTBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -518,11 +518,13 @@ @implementation RCTBridge
- (instancetype)initWithBundlePath:(NSString *)bundlePath
moduleProvider:(RCTBridgeModuleProviderBlock)block
launchOptions:(NSDictionary *)launchOptions
executorClass:(Class)executorClass
{
if ((self = [super init])) {
_bundlePath = bundlePath;
_moduleProvider = block;
_launchOptions = launchOptions;
_executorClass = executorClass;
[self setUp];
[self bindKeys];
}
Expand Down
3 changes: 2 additions & 1 deletion React/Base/RCTRootView.m
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ - (instancetype)initWithBundleURL:(NSURL *)bundleURL
{
RCTBridge *bridge = [[RCTBridge alloc] initWithBundlePath:bundleURL.absoluteString
moduleProvider:nil
launchOptions:launchOptions];
launchOptions:launchOptions
executorClass:Nil];
return [self initWithBridge:bridge
moduleName:moduleName];
}
Expand Down

0 comments on commit 10610a5

Please sign in to comment.