Refactor preComputeConstantsForViewManager to avoid loading UIManagerModule in Fabric

Summary:
This method refactors the preComputeConstantsForViewManager to avoid loading UIManagerModule when using  Fabric + Static View configs

changelog: [internal] internal

Reviewed By: shergin

Differential Revision: D25468182

fbshipit-source-id: e95b0e7d013e832792fb77fc0b6e5705d7f04868
This commit is contained in:
David Vacca
2020-12-29 15:06:15 -08:00
committed by Facebook GitHub Bot
parent 4c734d1e8d
commit b3defc8872
4 changed files with 29 additions and 10 deletions
@@ -294,14 +294,16 @@ public class UIManagerModule extends ReactContextBaseJavaModule
* Helper method to pre-compute the constants for a view manager. This method ensures that we
* don't block for getting the constants for view managers during TTI
*
* @deprecated this method will not be available in FabricUIManager class.
* @deprecated this method will be removed in the future
* @param viewManagerNames {@link List<String>} names of ViewManagers
*/
@Deprecated
public void preComputeConstantsForViewManager(List<String> viewManagerNames) {
// TODO T81145457 - Implement pre-initialization of ViewManagers in Fabric Android
@Override
public void preInitializeViewManagers(List<String> viewManagerNames) {
if (ReactFeatureFlags.enableExperimentalStaticViewConfigs) {
preInitializeViewManagers(viewManagerNames);
for (String viewManagerName : viewManagerNames) {
mUIImplementation.resolveViewManager(viewManagerName);
}
// When Static view configs are enabled it is not necessary to pre-compute the constants for
// viewManagers, although the pre-initialization of viewManager objects is still necessary
// for performance reasons.
@@ -326,12 +328,6 @@ public class UIManagerModule extends ReactContextBaseJavaModule
mViewManagerConstantsCache = Collections.unmodifiableMap(constantsMap);
}
private void preInitializeViewManagers(List<String> viewManagerNames) {
for (String viewManagerName : viewManagerNames) {
mUIImplementation.resolveViewManager(viewManagerName);
}
}
@ReactMethod(isBlockingSynchronousMethod = true)
public @Nullable WritableMap getConstantsForViewManager(@Nullable String viewManagerName) {
if (mViewManagerConstantsCache != null