Pipe platform and bundleEntry through WebSocket connection

Reviewed By: vjeux

Differential Revision: D2793572

fb-gh-sync-id: 6ce2467b8d528d1a91c1b4fc51741f2502674022
This commit is contained in:
Martín Bigio
2015-12-29 18:24:06 -08:00
committed by facebook-github-bot-8
parent dd8e1f91d8
commit 5f850fbede
3 changed files with 41 additions and 18 deletions

View File

@@ -90,6 +90,7 @@ RCT_NOT_IMPLEMENTED(-(instancetype)init)
{
RCTJavaScriptContext *_context;
NSThread *_javaScriptThread;
NSURL *_bundleURL;
}
@synthesize valid = _valid;
@@ -145,22 +146,22 @@ static void RCTInstallJSCProfiler(RCTBridge *bridge, JSContextRef context)
}
}
static BOOL isHotLoadingEnabled()
{
NSString *enabledQS = [[RCTBundleURLProcessor sharedProcessor] getQueryStringValue:@"hot"];
return (enabledQS != nil && [enabledQS isEqualToString:@"true"]) ? YES : NO;
}
static void RCTInstallHotLoading(RCTBridge *bridge, RCTJSCExecutor *executor)
{
[bridge.devMenu addItem:[RCTDevMenuItem toggleItemWithKey:RCTHotLoadingEnabledDefaultsKey title:@"Enable Hot Loading" selectedTitle:@"Disable Hot Loading" handler:^(BOOL enabledOnCurrentBundle) {
[executor executeBlockOnJavaScriptQueue:^{
NSString *enabledQS = [[RCTBundleURLProcessor sharedProcessor] getQueryStringValue:@"hot"];
BOOL enabledOnConfig = (enabledQS != nil && [enabledQS isEqualToString:@"true"]) ? YES : NO;
BOOL enabledOnConfig = isHotLoadingEnabled();
// reload bundle when user change Hot Loading setting
if (enabledOnConfig != enabledOnCurrentBundle) {
[[RCTBundleURLProcessor sharedProcessor] setQueryStringValue:enabledOnCurrentBundle ? @"true" : @"false" forAttribute:@"hot"];
[bridge reload];
}
if (enabledOnCurrentBundle) {
[bridge enqueueJSCall:@"HMRClient.enable" args:@[@YES]];
}
}];
}]];
}
@@ -534,6 +535,13 @@ static void RCTInstallHotLoading(RCTBridge *bridge, RCTJSCExecutor *executor)
onComplete(error);
}
}), 0, @"js_call", (@{ @"url": sourceURL.absoluteString }))];
#if RCT_DEV
if (isHotLoadingEnabled()) {
// strip initial slash
[_bridge enqueueJSCall:@"HMRClient.enable" args:@[@"ios", [sourceURL.path substringFromIndex: 1]]];
}
#endif
}
- (void)executeBlockOnJavaScriptQueue:(dispatch_block_t)block