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 facebook#288
  • Loading branch information
ide committed Apr 10, 2015
1 parent 099b094 commit 1456271
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 @@ -46,7 +46,8 @@ extern NSString *RCTBridgeModuleNameForClass(Class bridgeModuleClass);
*/
- (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 @@ -678,11 +678,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 @@ -79,7 +79,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 1456271

Please sign in to comment.