stash the Source URL when loading a script.

Reviewed By: javache

Differential Revision: D4437195

fbshipit-source-id: 14698fc81bbe24cab81668bfb54578fc434abc58
This commit is contained in:
Ashok Menon
2017-01-20 11:50:20 -08:00
committed by Facebook Github Bot
parent cec787563a
commit 2ade5f3781
5 changed files with 61 additions and 36 deletions

View File

@@ -26,22 +26,11 @@ import com.facebook.react.module.annotations.ReactModule;
public class SourceCodeModule extends BaseJavaModule {
private final ReactContext mReactContext;
private @Nullable String mSourceUrl;
public SourceCodeModule(ReactContext reactContext) {
mReactContext = reactContext;
}
@Override
public void initialize() {
super.initialize();
mSourceUrl =
Assertions.assertNotNull(
mReactContext.getCatalystInstance().getSourceURL(),
"No source URL loaded, have you initialised the instance?");
}
@Override
public String getName() {
return "RCTSourceCode";
@@ -50,7 +39,13 @@ public class SourceCodeModule extends BaseJavaModule {
@Override
public @Nullable Map<String, Object> getConstants() {
HashMap<String, Object> constants = new HashMap<>();
constants.put("scriptURL", mSourceUrl);
String sourceURL =
Assertions.assertNotNull(
mReactContext.getCatalystInstance().getSourceURL(),
"No source URL loaded, have you initialised the instance?");
constants.put("scriptURL", sourceURL);
return constants;
}
}