Introduce mobile config flag to load classes for View Managers

Reviewed By: kathryngray

Differential Revision: D6148468

fbshipit-source-id: d0f919f63922dae4b0720f22fa70ab4a7f67b48a
This commit is contained in:
Dmitry Zakharov
2017-10-26 08:40:10 -07:00
committed by Facebook Github Bot
parent 55f75dfd65
commit f0fb720eaa
10 changed files with 269 additions and 211 deletions
@@ -9,13 +9,11 @@
package com.facebook.react.bridge;
import com.facebook.react.common.build.ReactBuildConfig;
import java.lang.reflect.Constructor;
import javax.annotation.Nullable;
import javax.inject.Provider;
import java.lang.reflect.Constructor;
import com.facebook.react.common.build.ReactBuildConfig;
/**
* A specification for a native module. This exists so that we don't have to pay the cost
* for creation until/if the module is used.
@@ -27,7 +25,7 @@ public class ModuleSpec {
private static final Class[] EMPTY_SIGNATURE = {};
private static final Class[] CONTEXT_SIGNATURE = { ReactApplicationContext.class };
private final Class<? extends NativeModule> mType;
private final @Nullable Class<? extends NativeModule> mType;
private final Provider<? extends NativeModule> mProvider;
/**
@@ -64,12 +62,22 @@ public class ModuleSpec {
});
}
public ModuleSpec(Class<? extends NativeModule> type, Provider<? extends NativeModule> provider) {
public static ModuleSpec viewManagerSpec(Provider<? extends NativeModule> provider) {
return new ModuleSpec(null, provider);
}
public static ModuleSpec nativeModuleSpec(
Class<? extends NativeModule> type, Provider<? extends NativeModule> provider) {
return new ModuleSpec(type, provider);
}
private ModuleSpec(
@Nullable Class<? extends NativeModule> type, Provider<? extends NativeModule> provider) {
mType = type;
mProvider = provider;
}
public Class<? extends NativeModule> getType() {
public @Nullable Class<? extends NativeModule> getType() {
return mType;
}