Permalink
Browse files

Adopt new split segments registration approach on iOS

Differential Revision: D6284479

fbshipit-source-id: d0d7e8c6a6ce4ecab63739149be69f25df7fbe6f
  • Loading branch information...
fromcelticpark authored and facebook-github-bot committed Nov 9, 2017
1 parent cff0d8e commit 681278947eb4039a1d7a65f1edfeef25ae055a4f
Showing with 20 additions and 13 deletions.
  1. +7 −0 React/Base/RCTBridge.h
  2. +5 −0 React/Base/RCTBridge.m
  3. +0 −7 React/Base/RCTBridgeDelegate.h
  4. +8 −6 React/CxxBridge/RCTCxxBridge.mm
@@ -138,6 +138,13 @@ RCT_EXTERN NSString *RCTBridgeModuleNameForClass(Class bridgeModuleClass);
arguments:(NSArray *)arguments
error:(NSError **)error;
/**
* This method registers the file path of an additional JS segment by its ID.
*
* @experimental
*/
- (void)registerSegmentWithId:(NSUInteger)segmentId path:(NSString *)path;
/**
* Retrieve a bridge module instance by name or class. Note that modules are
* lazily instantiated, so calling these methods for the first time with a given
@@ -398,6 +398,11 @@ - (JSValue *)callFunctionOnModule:(NSString *)module
return [self.batchedBridge callFunctionOnModule:module method:method arguments:arguments error:error];
}
- (void)registerSegmentWithId:(NSUInteger)segmentId path:(NSString *)path
{
[self.batchedBridge registerSegmentWithId:segmentId path:path];
}
@end
@implementation RCTBridge (JavaScriptCore)
@@ -94,11 +94,4 @@
- (void)loadSourceForBridge:(RCTBridge *)bridge
withBlock:(RCTSourceLoadBlock)loadCallback;
/**
* Specifies the path to folder where additional bundles are located
*
* @experimental
*/
- (NSURL *)jsSegmentsDirectory;
@end
@@ -1148,12 +1148,7 @@ - (void)executeApplicationScript:(NSData *)script
[self->_performanceLogger markStopForTag:RCTPLRAMBundleLoad];
[self->_performanceLogger setValue:scriptStr->size() forTag:RCTPLRAMStartupCodeSize];
if (self->_reactInstance) {
NSString *jsSegmentsDirectory = [self.delegate respondsToSelector:@selector(jsSegmentsDirectory)]
? [[self.delegate jsSegmentsDirectory].path stringByAppendingString:@"/"]
: nil;
auto registry = jsSegmentsDirectory != nil
? RAMBundleRegistry::multipleBundlesRegistry(std::move(ramBundle), JSIndexedRAMBundle::buildFactory())
: RAMBundleRegistry::singleBundleRegistry(std::move(ramBundle));
auto registry = RAMBundleRegistry::multipleBundlesRegistry(std::move(ramBundle), JSIndexedRAMBundle::buildFactory());
self->_reactInstance->loadRAMBundle(std::move(registry), std::move(scriptStr),
sourceUrlStr.UTF8String, !async);
}
@@ -1214,6 +1209,13 @@ - (JSValue *)callFunctionOnModule:(NSString *)module
return ret;
}
- (void)registerSegmentWithId:(NSUInteger)segmentId path:(NSString *)path
{
if (_reactInstance) {
_reactInstance->registerBundle(static_cast<uint32_t>(segmentId), path.UTF8String);
}
}
#pragma mark - Payload Processing
- (void)partialBatchDidFlush

0 comments on commit 6812789

Please sign in to comment.