Android: Use enum type for looking up JSIModule's

Summary:
To avoid unnecessary class loads, and better modularity, let's use string keys (enum) to access JSIModule's. For now all JSIModule's are all known inside the core infra (only FabricUIManager and TurboModuleManager right now), so let's keep it simple and explicitly list them out.

The only problem here is we lose some form of type safety...

Reviewed By: JoshuaGross

Differential Revision: D15872777

fbshipit-source-id: 9c2de7ef1e88ef3a6dff5888d644f9d8963af2a3
This commit is contained in:
Kevin Gozali
2019-06-18 16:22:17 -07:00
committed by Facebook Github Bot
parent 0d971f97d5
commit 2df90738d5
7 changed files with 32 additions and 13 deletions
@@ -23,6 +23,7 @@ import com.facebook.react.bridge.JSIModule;
import com.facebook.react.bridge.JSIModulePackage;
import com.facebook.react.bridge.JSIModuleProvider;
import com.facebook.react.bridge.JSIModuleSpec;
import com.facebook.react.bridge.JSIModuleType;
import com.facebook.react.bridge.JavaScriptContextHolder;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContext;
@@ -239,8 +240,8 @@ public class ReactAppTestActivity extends FragmentActivity
return Arrays.<JSIModuleSpec>asList(
new JSIModuleSpec() {
@Override
public Class<? extends JSIModule> getJSIModuleClass() {
return UIManager.class;
public JSIModuleType getJSIModuleType() {
return JSIModuleType.UIManager;
}
@Override