mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-29 22:41:56 +08:00
add a way to enable / disable lazy native modules
Reviewed By: lexs Differential Revision: D3849947 fbshipit-source-id: 0a4a1cd5b9f165269a53b69de46c9cc1939d9d08
This commit is contained in:
committed by
Facebook Github Bot 6
parent
82c8c97898
commit
a4916b8c98
@@ -234,6 +234,7 @@ public abstract class ReactInstanceManager {
|
||||
protected @Nullable Activity mCurrentActivity;
|
||||
protected @Nullable DefaultHardwareBackBtnHandler mDefaultHardwareBackBtnHandler;
|
||||
protected @Nullable RedBoxHandler mRedBoxHandler;
|
||||
protected boolean mLazyNativeModulesEnabled;
|
||||
|
||||
protected Builder() {
|
||||
}
|
||||
@@ -366,6 +367,11 @@ public abstract class ReactInstanceManager {
|
||||
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,16 +384,16 @@ public abstract class ReactInstanceManager {
|
||||
*/
|
||||
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.
|
||||
@@ -395,20 +401,21 @@ public abstract class ReactInstanceManager {
|
||||
}
|
||||
|
||||
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 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE;
|
||||
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 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE;
|
||||
UIImplementationProvider uiImplementationProvider,
|
||||
NativeModuleCallExceptionHandler nativeModuleCallExceptionHandler,
|
||||
JSCConfig jscConfig,
|
||||
@Nullable RedBoxHandler redBoxHandler) {
|
||||
@Nullable RedBoxHandler redBoxHandler,
|
||||
boolean lazyNativeModulesEnabled) {
|
||||
|
||||
initializeSoLoaderIfNecessary(applicationContext);
|
||||
|
||||
@@ -316,6 +318,7 @@ import static com.facebook.systrace.Systrace.TRACE_TAG_REACT_JAVA_BRIDGE;
|
||||
mMemoryPressureRouter = new MemoryPressureRouter(applicationContext);
|
||||
mNativeModuleCallExceptionHandler = nativeModuleCallExceptionHandler;
|
||||
mJSCConfig = jscConfig;
|
||||
mLazyNativeModulesEnabled = lazyNativeModulesEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user