Allow Flipper module instances to be created by applications (#786)

Summary:
This allows using the flipper RN module with TurboModules instead of using FlipperPackage.

## Changelog

[react-native-flipper] Allow Flipper module instances to be created by applications
Pull Request resolved: https://github.com/facebook/flipper/pull/786

Test Plan:
An instance of the Flipper module can now be created like this when using TurboModules:

```java
  Override
  public NativeModule getModule(String name, ReactApplicationContext reactContext) {
    switch (name) {
      ...
      case FlipperModule.NAME:
        return new FlipperModule(FlipperReactNativeJavaScriptPluginManager.getInstance(), reactContext);
      ...
    }
  }
```

Tested that it builds

Reviewed By: mweststrate

Differential Revision: D19812912

Pulled By: passy

fbshipit-source-id: 401b3e4552ea0cdb7444a2cf5d170c408edab4db
This commit is contained in:
Janic Duplessis
2020-02-10 05:52:11 -08:00
committed by Facebook Github Bot
parent 63c8a3a417
commit 912bfed0f8
2 changed files with 3 additions and 3 deletions

View File

@@ -30,7 +30,7 @@ public class FlipperModule extends ReactContextBaseJavaModule {
private final FlipperReactNativeJavaScriptPluginManager mManager;
FlipperModule(
public FlipperModule(
FlipperReactNativeJavaScriptPluginManager manager, ReactApplicationContext reactContext) {
super(reactContext);
mManager = manager;

View File

@@ -30,10 +30,10 @@ import org.json.JSONTokener;
* <p>Note that this manager is not bound to a specific FlipperModule instance, as that might be
* swapped in and out over time.
*/
final class FlipperReactNativeJavaScriptPluginManager {
public final class FlipperReactNativeJavaScriptPluginManager {
private static FlipperReactNativeJavaScriptPluginManager sInstance;
static synchronized FlipperReactNativeJavaScriptPluginManager getInstance() {
public static synchronized FlipperReactNativeJavaScriptPluginManager getInstance() {
if (sInstance == null) {
sInstance = new FlipperReactNativeJavaScriptPluginManager();
}