mirror of
https://github.com/status-im/react-native.git
synced 2025-01-12 18:44:25 +00:00
Eagerly create FBMarketplaceNativeModule [2/N]
Summary: The full idea for eagerly creating Native Modules is articulated here https://fb.quip.com/vWcLAup3a6kR TLDR: 1) Move lazy native module work from the mqt_js thread to the background thread which processes packages. This also moves it from post-network to pre-network. 2) For a quick test, decide which modules to eagerly create with a QE flag. 3) Eagerly create the modules by opting-out of the ReactModuleInfo pipeline which was built for lazy native modules. Reviewed By: achen1 Differential Revision: D9503934 fbshipit-source-id: 0cd8337ad294cd0f8be692fecbf4292d204f3ec4
This commit is contained in:
parent
e8c7cb1c04
commit
58409be6b4
@ -96,6 +96,14 @@ public abstract class LazyReactPackage implements ReactPackage {
|
||||
return modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list of native modules which should be eagerly initialized.
|
||||
*/
|
||||
public List<String> getEagerNativeModules() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param reactContext react application context that can be used to create View Managers.
|
||||
* @return list of module specs that can create the View Managers.
|
||||
|
@ -45,6 +45,7 @@ public class NativeModuleRegistryBuilder {
|
||||
if (reactPackage instanceof LazyReactPackage) {
|
||||
LazyReactPackage lazyReactPackage = (LazyReactPackage) reactPackage;
|
||||
List<ModuleSpec> moduleSpecs = lazyReactPackage.getNativeModules(mReactApplicationContext);
|
||||
List<String> eagerNativeModules = lazyReactPackage.getEagerNativeModules();
|
||||
Map<String, ReactModuleInfo> reactModuleInfoMap =
|
||||
lazyReactPackage.getReactModuleInfoProvider().getReactModuleInfos();
|
||||
|
||||
@ -52,7 +53,7 @@ public class NativeModuleRegistryBuilder {
|
||||
String className = moduleSpec.getClassName();
|
||||
ReactModuleInfo reactModuleInfo = reactModuleInfoMap.get(className);
|
||||
ModuleHolder moduleHolder;
|
||||
if (reactModuleInfo == null) {
|
||||
if (reactModuleInfo == null || eagerNativeModules.contains(className)) {
|
||||
NativeModule module;
|
||||
ReactMarker.logMarker(
|
||||
ReactMarkerConstants.CREATE_MODULE_START,
|
||||
|
Loading…
x
Reference in New Issue
Block a user