mirror of
https://github.com/status-im/react-native.git
synced 2025-01-27 17:54:48 +00:00
Construct ModuleHolder from ReactModuleInfo
Reviewed By: AaaChiuuu Differential Revision: D4883331 fbshipit-source-id: c901051d0aa5993142104126bbec5d76bd605e0b
This commit is contained in:
parent
035f076594
commit
54d8d10a6b
@ -69,13 +69,7 @@ public class NativeModuleRegistryBuilder {
|
||||
ReactMarker.logMarker(ReactMarkerConstants.CREATE_MODULE_END);
|
||||
moduleHolder = new ModuleHolder(module);
|
||||
} else {
|
||||
moduleHolder = new ModuleHolder(
|
||||
reactModuleInfo.name(),
|
||||
reactModuleInfo.canOverrideExistingModule(),
|
||||
reactModuleInfo.supportsWebWorkers(),
|
||||
reactModuleInfo.needsEagerInit(),
|
||||
reactModuleInfo.hasConstants(),
|
||||
moduleSpec.getProvider());
|
||||
moduleHolder = new ModuleHolder(reactModuleInfo, moduleSpec.getProvider());
|
||||
}
|
||||
|
||||
String name = moduleHolder.getName();
|
||||
|
@ -9,6 +9,7 @@ import com.facebook.proguard.annotations.DoNotStrip;
|
||||
import com.facebook.react.bridge.NativeModule;
|
||||
import com.facebook.react.bridge.ReactMarker;
|
||||
import com.facebook.react.bridge.ReactMarkerConstants;
|
||||
import com.facebook.react.module.model.ReactModuleInfo;
|
||||
import com.facebook.systrace.Systrace;
|
||||
import com.facebook.systrace.SystraceMessage;
|
||||
|
||||
@ -37,19 +38,13 @@ public class ModuleHolder {
|
||||
private @Nullable NativeModule mModule;
|
||||
private boolean mInitializeNeeded;
|
||||
|
||||
public ModuleHolder(
|
||||
String name,
|
||||
boolean canOverrideExistingModule,
|
||||
boolean supportsWebWorkers,
|
||||
boolean needsEagerInit,
|
||||
boolean hasConstants,
|
||||
Provider<? extends NativeModule> provider) {
|
||||
mName = name;
|
||||
mCanOverrideExistingModule = canOverrideExistingModule;
|
||||
mSupportsWebWorkers = supportsWebWorkers;
|
||||
mHasConstants = hasConstants;
|
||||
public ModuleHolder(ReactModuleInfo moduleInfo, Provider<? extends NativeModule> provider) {
|
||||
mName = moduleInfo.name();
|
||||
mCanOverrideExistingModule = moduleInfo.canOverrideExistingModule();
|
||||
mSupportsWebWorkers = moduleInfo.supportsWebWorkers();
|
||||
mHasConstants = moduleInfo.hasConstants();
|
||||
mProvider = provider;
|
||||
if (needsEagerInit) {
|
||||
if (moduleInfo.needsEagerInit()) {
|
||||
mModule = create();
|
||||
}
|
||||
}
|
||||
|
@ -48,19 +48,7 @@ public class BaseJavaModuleTest {
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
ModuleHolder moduleHolder = new ModuleHolder("MethodsModule",
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
new Provider<MethodsModule>() {
|
||||
MethodsModule mModule;
|
||||
@Override
|
||||
public MethodsModule get() {
|
||||
mModule = new MethodsModule();
|
||||
return mModule;
|
||||
}
|
||||
});
|
||||
ModuleHolder moduleHolder = new ModuleHolder(new MethodsModule());
|
||||
mWrapper = new JavaModuleWrapper(null, MethodsModule.class, moduleHolder);
|
||||
mMethods = mWrapper.getMethodDescriptors();
|
||||
PowerMockito.mockStatic(SoLoader.class);
|
||||
|
Loading…
x
Reference in New Issue
Block a user