Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions ReactAndroid/src/main/java/com/facebook/react/Experiments.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.facebook.react;

import java.util.HashSet;
import java.util.Set;

public class Experiments {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add Javadoc explaining what the reason this class exist is please.


public static String HOT_MODULE_REPLACEMENT = "HOT_MODULE_REPLACEMENT";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add Javadoc with a short explanation this shows/hides the HMR menu please.


private static Set<String> enabledExperiments;

public static void enableExperiment(String experiment) {
if (enabledExperiments == null) {
enabledExperiments = new HashSet<>();
}
enabledExperiments.add(experiment);
}

public static void disableExperiment(String experiment) {
if (enabledExperiments != null) {
enabledExperiments.remove(experiment);
}
}

public static boolean isExperimentEnabled(String experiment) {
return enabledExperiments != null && enabledExperiments.contains(experiment);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

import com.facebook.common.logging.FLog;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.Experiments;
import com.facebook.react.R;
import com.facebook.react.bridge.CatalystInstance;
import com.facebook.react.bridge.DefaultNativeModuleCallExceptionHandler;
Expand Down Expand Up @@ -265,17 +266,21 @@ public void onOptionSelected() {
handleReloadJS();
}
});
options.put(
mDevSettings.isHotModuleReplacementEnabled()
? mApplicationContext.getString(R.string.catalyst_hot_module_replacement_off)
: mApplicationContext.getString(R.string.catalyst_hot_module_replacement),
new DevOptionHandler() {
@Override
public void onOptionSelected() {
mDevSettings.setHotModuleReplacementEnabled(!mDevSettings.isHotModuleReplacementEnabled());
handleReloadJS();
}
});

if (Experiments.isExperimentEnabled(Experiments.HOT_MODULE_REPLACEMENT)) {
options.put(
mDevSettings.isHotModuleReplacementEnabled()
? mApplicationContext.getString(R.string.catalyst_hot_module_replacement_off)
: mApplicationContext.getString(R.string.catalyst_hot_module_replacement),
new DevOptionHandler() {
@Override
public void onOptionSelected() {
mDevSettings.setHotModuleReplacementEnabled(!mDevSettings.isHotModuleReplacementEnabled());
handleReloadJS();
}
});
}

options.put(
mDevSettings.isReloadOnJSChangeEnabled()
? mApplicationContext.getString(R.string.catalyst_live_reload_off)
Expand Down