Permalink
Browse files

add a way to enable / disable lazy native modules

Reviewed By: lexs

Differential Revision: D3849947

fbshipit-source-id: 0a4a1cd5b9f165269a53b69de46c9cc1939d9d08
  • Loading branch information...
1 parent 82c8c97 commit a4916b8c98085e37a2cdfb130d1089daba697702 @AaaChiuuu AaaChiuuu committed with Facebook Github Bot 6 Sep 13, 2016
@@ -234,6 +234,7 @@ public static Builder builder() {
protected @Nullable Activity mCurrentActivity;
protected @Nullable DefaultHardwareBackBtnHandler mDefaultHardwareBackBtnHandler;
protected @Nullable RedBoxHandler mRedBoxHandler;
+ protected boolean mLazyNativeModulesEnabled;
protected Builder() {
}
@@ -366,6 +367,11 @@ public Builder setRedBoxHandler(@Nullable RedBoxHandler redBoxHandler) {
return this;
}
+ public Builder setLazyNativeModulesEnabled(boolean lazyNativeModulesEnabled) {
+ mLazyNativeModulesEnabled = lazyNativeModulesEnabled;
+ return this;
+ }
+
/**
* Instantiates a new {@link ReactInstanceManagerImpl}.
* Before calling {@code build}, the following must be called:
@@ -378,37 +384,38 @@ public Builder setRedBoxHandler(@Nullable RedBoxHandler redBoxHandler) {
*/
public ReactInstanceManager build() {
Assertions.assertNotNull(
- mApplication,
- "Application property has not been set with this builder");
+ mApplication,
+ "Application property has not been set with this builder");
Assertions.assertCondition(
- mUseDeveloperSupport || mJSBundleAssetUrl != null || mJSBundleLoader != null,
- "JS Bundle File or Asset URL has to be provided when dev support is disabled");
+ mUseDeveloperSupport || mJSBundleAssetUrl != null || mJSBundleLoader != null,
+ "JS Bundle File or Asset URL has to be provided when dev support is disabled");
Assertions.assertCondition(
- mJSMainModuleName != null || mJSBundleAssetUrl != null || mJSBundleLoader != null,
- "Either MainModuleName or JS Bundle File needs to be provided");
+ mJSMainModuleName != null || mJSBundleAssetUrl != null || mJSBundleLoader != null,
+ "Either MainModuleName or JS Bundle File needs to be provided");
if (mUIImplementationProvider == null) {
// create default UIImplementationProvider if the provided one is null.
mUIImplementationProvider = new UIImplementationProvider();
}
return new XReactInstanceManagerImpl(
- mApplication,
- mCurrentActivity,
- mDefaultHardwareBackBtnHandler,
- (mJSBundleLoader == null && mJSBundleAssetUrl != null) ?
- JSBundleLoader.createAssetLoader(mApplication, mJSBundleAssetUrl) : mJSBundleLoader,
- mJSMainModuleName,
- mPackages,
- mUseDeveloperSupport,
- mBridgeIdleDebugListener,
- Assertions.assertNotNull(mInitialLifecycleState, "Initial lifecycle state was not set"),
- mUIImplementationProvider,
- mNativeModuleCallExceptionHandler,
- mJSCConfig,
- mRedBoxHandler);
+ mApplication,
+ mCurrentActivity,
+ mDefaultHardwareBackBtnHandler,
+ (mJSBundleLoader == null && mJSBundleAssetUrl != null) ?
+ JSBundleLoader.createAssetLoader(mApplication, mJSBundleAssetUrl) : mJSBundleLoader,
+ mJSMainModuleName,
+ mPackages,
+ mUseDeveloperSupport,
+ mBridgeIdleDebugListener,
+ Assertions.assertNotNull(mInitialLifecycleState, "Initial lifecycle state was not set"),
+ mUIImplementationProvider,
+ mNativeModuleCallExceptionHandler,
+ mJSCConfig,
+ mRedBoxHandler,
+ mLazyNativeModulesEnabled);
}
}
}
@@ -132,6 +132,7 @@
private final MemoryPressureRouter mMemoryPressureRouter;
private final @Nullable NativeModuleCallExceptionHandler mNativeModuleCallExceptionHandler;
private final JSCConfig mJSCConfig;
+ private final boolean mLazyNativeModulesEnabled;
private final ReactInstanceDevCommandsHandler mDevInterface =
new ReactInstanceDevCommandsHandler() {
@@ -289,7 +290,8 @@ public T get() throws Exception {
UIImplementationProvider uiImplementationProvider,
NativeModuleCallExceptionHandler nativeModuleCallExceptionHandler,
JSCConfig jscConfig,
- @Nullable RedBoxHandler redBoxHandler) {
+ @Nullable RedBoxHandler redBoxHandler,
+ boolean lazyNativeModulesEnabled) {
initializeSoLoaderIfNecessary(applicationContext);
@@ -316,6 +318,7 @@ public T get() throws Exception {
mMemoryPressureRouter = new MemoryPressureRouter(applicationContext);
mNativeModuleCallExceptionHandler = nativeModuleCallExceptionHandler;
mJSCConfig = jscConfig;
+ mLazyNativeModulesEnabled = lazyNativeModulesEnabled;
}
@Override

0 comments on commit a4916b8

Please sign in to comment.