Java Code Examples for com.facebook.react.bridge.JavaScriptModule

The following are top voted examples for showing how to use com.facebook.react.bridge.JavaScriptModule. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: RNLearn_Project1   File: CoreModulesPackage.java   View source code 6 votes vote down vote up
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
  List<Class<? extends JavaScriptModule>> jsModules = new ArrayList<>(Arrays.asList(
      DeviceEventManagerModule.RCTDeviceEventEmitter.class,
      JSTimersExecution.class,
      RCTEventEmitter.class,
      RCTNativeAppEventEmitter.class,
      AppRegistry.class,
      com.facebook.react.bridge.Systrace.class,
      HMRClient.class));

  if (ReactBuildConfig.DEBUG) {
    jsModules.add(DebugComponentOwnershipModule.RCTDebugComponentOwnership.class);
    jsModules.add(JSCHeapCapture.HeapCapture.class);
    jsModules.add(JSCSamplingProfiler.SamplingProfiler.class);
  }

  return jsModules;
}
 
Example 2
Project: RNLearn_Project1   File: ReactInstanceManager.java   View source code 6 votes vote down vote up
private void processPackage(
  ReactPackage reactPackage,
  NativeModuleRegistryBuilder nativeModuleRegistryBuilder,
  JavaScriptModuleRegistry.Builder jsModulesBuilder) {
  SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "processPackage")
    .arg("className", reactPackage.getClass().getSimpleName())
    .flush();
  if (reactPackage instanceof ReactPackageLogger) {
    ((ReactPackageLogger) reactPackage).startProcessPackage();
  }
  nativeModuleRegistryBuilder.processPackage(reactPackage);

  for (Class<? extends JavaScriptModule> jsModuleClass : reactPackage.createJSModules()) {
    jsModulesBuilder.add(jsModuleClass);
  }
  if (reactPackage instanceof ReactPackageLogger) {
    ((ReactPackageLogger) reactPackage).endProcessPackage();
  }
  Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
}
 
Example 3
Project: RNLearn_Project1   File: ReactInstanceManager.java   View source code 6 votes vote down vote up
private void processPackage(
  ReactPackage reactPackage,
  NativeModuleRegistryBuilder nativeModuleRegistryBuilder,
  JavaScriptModuleRegistry.Builder jsModulesBuilder) {
  SystraceMessage.beginSection(TRACE_TAG_REACT_JAVA_BRIDGE, "processPackage")
    .arg("className", reactPackage.getClass().getSimpleName())
    .flush();
  if (reactPackage instanceof ReactPackageLogger) {
    ((ReactPackageLogger) reactPackage).startProcessPackage();
  }
  nativeModuleRegistryBuilder.processPackage(reactPackage);

  for (Class<? extends JavaScriptModule> jsModuleClass : reactPackage.createJSModules()) {
    jsModulesBuilder.add(jsModuleClass);
  }
  if (reactPackage instanceof ReactPackageLogger) {
    ((ReactPackageLogger) reactPackage).endProcessPackage();
  }
  Systrace.endSection(TRACE_TAG_REACT_JAVA_BRIDGE);
}
 
Example 4
Project: RNLearn_Project1   File: CompositeReactPackageTest.java   View source code 5 votes vote down vote up
@Test
public void testThatCompositeReturnsASumOfJSModules() {
  // Given
  CompositeReactPackage composite = new CompositeReactPackage(packageNo1, packageNo2);

  Class<? extends JavaScriptModule> moduleNo1 = mock(JavaScriptModuleNo1.class).getClass();
  Class<? extends JavaScriptModule> moduleNo2 = mock(JavaScriptModuleNo2.class).getClass();
  Class<? extends JavaScriptModule> moduleNo3 = mock(JavaScriptModuleNo3.class).getClass();

  List<Class<? extends JavaScriptModule>> l1 = new ArrayList<>();
  l1.add(moduleNo1);
  when(packageNo1.createJSModules()).thenReturn(l1);

  List<Class<? extends JavaScriptModule>> l2 = new ArrayList<>();
  l2.add(moduleNo2);
  l2.add(moduleNo3);
  when(packageNo2.createJSModules()).thenReturn(l2);

  // When
  List<Class<? extends JavaScriptModule>> compositeModules = composite.createJSModules();

  // Then

  // wrapping lists into sets to be order-independent
  List<Class<? extends JavaScriptModule>> l3 = new ArrayList<>();
  l3.add(moduleNo1);
  l3.add(moduleNo2);
  l3.add(moduleNo3);
  Set<Class<? extends JavaScriptModule>> expected = new HashSet<>(l3);
  Set<Class<? extends JavaScriptModule>> actual = new HashSet<>(compositeModules);

  assertEquals(expected, actual);
}
 
Example 5
Project: RNLearn_Project1   File: CompositeReactPackage.java   View source code 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
  final Set<Class<? extends JavaScriptModule>> moduleSet = new HashSet<>();
  for (ReactPackage reactPackage: mChildReactPackages) {
    for (Class<? extends JavaScriptModule> jsModule: reactPackage.createJSModules()) {
      moduleSet.add(jsModule);
    }
  }
  return new ArrayList(moduleSet);
}
 
Example 6
Project: RNLearn_Project1   File: CompositeReactPackageTest.java   View source code 5 votes vote down vote up
@Test
public void testThatCompositeReturnsASumOfJSModules() {
  // Given
  CompositeReactPackage composite = new CompositeReactPackage(packageNo1, packageNo2);

  Class<? extends JavaScriptModule> moduleNo1 = mock(JavaScriptModuleNo1.class).getClass();
  Class<? extends JavaScriptModule> moduleNo2 = mock(JavaScriptModuleNo2.class).getClass();
  Class<? extends JavaScriptModule> moduleNo3 = mock(JavaScriptModuleNo3.class).getClass();

  List<Class<? extends JavaScriptModule>> l1 = new ArrayList<>();
  l1.add(moduleNo1);
  when(packageNo1.createJSModules()).thenReturn(l1);

  List<Class<? extends JavaScriptModule>> l2 = new ArrayList<>();
  l2.add(moduleNo2);
  l2.add(moduleNo3);
  when(packageNo2.createJSModules()).thenReturn(l2);

  // When
  List<Class<? extends JavaScriptModule>> compositeModules = composite.createJSModules();

  // Then

  // wrapping lists into sets to be order-independent
  List<Class<? extends JavaScriptModule>> l3 = new ArrayList<>();
  l3.add(moduleNo1);
  l3.add(moduleNo2);
  l3.add(moduleNo3);
  Set<Class<? extends JavaScriptModule>> expected = new HashSet<>(l3);
  Set<Class<? extends JavaScriptModule>> actual = new HashSet<>(compositeModules);

  assertEquals(expected, actual);
}
 
Example 7
Project: react-native-taptargetview   File: RNTapTargetViewPackage.java   View source code 4 votes vote down vote up
public List<Class<? extends JavaScriptModule>> createJSModules() {
  return Collections.emptyList();
}
 
Example 8
Project: react-native-videoplayer   File: ReactVideoPackage.java   View source code 4 votes vote down vote up
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
    return Collections.emptyList();
}
 
Example 9
Project: react-native-image-intent   File: ImageIntentPackage.java   View source code 4 votes vote down vote up
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
    return Collections.emptyList();
}
 
Example 10
Project: RNLearn_Project1   File: MainReactPackage.java   View source code 4 votes vote down vote up
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
  return Collections.emptyList();
}
 
Example 11
Project: react-native-webrtc   File: WebRTCModulePackage.java   View source code 4 votes vote down vote up
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
    return Collections.emptyList();
}
 
Example 12
Project: react-native-pgp   File: Package.java   View source code 4 votes vote down vote up
public List<Class<? extends JavaScriptModule>> createJSModules() {
    return Collections.emptyList();
}
 
Example 13
Project: RNLearn_Project1   File: InstanceSpecForTestPackage.java   View source code 4 votes vote down vote up
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
  return mSpecForTest.getExtraJSModulesForTest();
}
 
Example 14
Project: react-native-alarm-notification   File: ANPackage.java   View source code 4 votes vote down vote up
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
    return Collections.emptyList();
}
 
Example 15
Project: react-native-dominant-color   File: RNDominantColorPackage.java   View source code 4 votes vote down vote up
public List<Class<? extends JavaScriptModule>> createJSModules() {
  return Collections.emptyList();
}
 
Example 16
Project: react-native-mail-compose   File: RNMailComposePackage.java   View source code 4 votes vote down vote up
public List<Class<? extends JavaScriptModule>> createJSModules() {
  return Collections.emptyList();
}
 
Example 17
Project: react-native-download-manager   File: DownloadFilePackage.java   View source code 4 votes vote down vote up
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
    return Collections.emptyList();
}
 
Example 18
Project: react-native-camera-android-simple   File: CameraPackage.java   View source code 4 votes vote down vote up
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
    return Collections.emptyList();
}
 
Example 19
Project: RNLearn_Project1   File: ReactPackage.java   View source code 4 votes vote down vote up
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
  return Collections.emptyList();
}
 
Example 20
Project: react-native-mssql   File: MSSQLPackage.java   View source code 4 votes vote down vote up
public List<Class<? extends JavaScriptModule>> createJSModules() {
    return Collections.emptyList();
}
 
Example 21
Project: react-native-cloudinary   File: RNCloudinaryPackage.java   View source code 4 votes vote down vote up
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
  return Collections.emptyList();
}
 
Example 22
Project: react-native-system-setting   File: SystemSettingPackage.java   View source code 4 votes vote down vote up
public List<Class<? extends JavaScriptModule>> createJSModules() {
    return Collections.emptyList();
}
 
Example 23
Project: react-native-message-compose   File: RNMessageComposePackage.java   View source code 4 votes vote down vote up
public List<Class<? extends JavaScriptModule>> createJSModules() {
  return Collections.emptyList();
}
 
Example 24
Project: react-native-double-date-picker   File: DoubleDatePickerPackage.java   View source code 4 votes vote down vote up
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
    return Collections.emptyList();
}
 
Example 25
Project: react-native-andorid-shadow   File: RNReactNativeAndoridShadowPackage.java   View source code 4 votes vote down vote up
public List<Class<? extends JavaScriptModule>> createJSModules() {
  return Collections.emptyList();
}
 
Example 26
Project: react-native-android-drawables   File: DrawablesPackage.java   View source code 4 votes vote down vote up
public List<Class<? extends JavaScriptModule>> createJSModules()
{
	return Collections.emptyList();
}
 
Example 27
Project: react-native-connectivity-status   File: RNConnectivityStatusPackage.java   View source code 4 votes vote down vote up
public List<Class<? extends JavaScriptModule>> createJSModules() {
  return Collections.emptyList();
}
 
Example 28
Project: react-native-background-task   File: BackgroundTaskPackage.java   View source code 4 votes vote down vote up
public List<Class<? extends JavaScriptModule>> createJSModules() {
    return Collections.emptyList();
}
 
Example 29
Project: react-native-android-circular-reveal   File: ReactAndroidCircularRevealPackage.java   View source code 4 votes vote down vote up
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
  return Collections.emptyList();
}
 
Example 30
Project: react-native-sketch-view   File: RNSketchViewPackage.java   View source code 4 votes vote down vote up
public List<Class<? extends JavaScriptModule>> createJSModules() {
  return Collections.emptyList();
}
 
Example 31
Project: react-native-android-speech-recognizer   File: RNAndroidSpeechRecognizerPackage.java   View source code 4 votes vote down vote up
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
  return Collections.emptyList();
}
 
Example 32
Project: react-native-udesk   File: UdeskPackage.java   View source code 4 votes vote down vote up
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
    return Collections.emptyList();
}
 
Example 33
Project: react-native-android-library-humaniq-api   File: Package.java   View source code 4 votes vote down vote up
@Override public List<Class<? extends JavaScriptModule>> createJSModules() {
  return Collections.emptyList();
}
 
Example 34
Project: RNLearn_Project1   File: CatalystInstanceImpl.java   View source code 4 votes vote down vote up
@Override
public <T extends JavaScriptModule> T getJSModule(ExecutorToken executorToken, Class<T> jsInterface) {
  return Assertions.assertNotNull(mJSModuleRegistry)
      .getJavaScriptModule(this, executorToken, jsInterface);
}
 
Example 35
Project: react-native-hour-format   File: RNHourFormatPackage.java   View source code 4 votes vote down vote up
public List<Class<? extends JavaScriptModule>> createJSModules() {
  return Collections.emptyList();
}
 
Example 36
Project: react-native-blue-manager   File: BleManagerPackage.java   View source code 4 votes vote down vote up
@Override
public List<Class<? extends JavaScriptModule>> createJSModules() {
	return new ArrayList<>();
}
 
Example 37
Project: react-native-get-sms-android   File: SmsPackage.java   View source code 4 votes vote down vote up
public List<Class<? extends JavaScriptModule>> createJSModules() {
    return Collections.emptyList();
}
 
Example 38
Project: react-native-openxc   File: RNOpenXCPackage.java   View source code 4 votes vote down vote up
public List<Class<? extends JavaScriptModule>> createJSModules() {
    return Collections.emptyList();
}
 
Example 39
Project: react-native-pili-player   File: PiliPackage.java   View source code 4 votes vote down vote up
public List<Class<? extends JavaScriptModule>> createJSModules() {
    return Collections.emptyList();
}
 
Example 40
Project: RNLearn_Project1   File: CatalystInstanceImpl.java   View source code 4 votes vote down vote up
@Override
public <T extends JavaScriptModule> T getJSModule(ExecutorToken executorToken, Class<T> jsInterface) {
  return Assertions.assertNotNull(mJSModuleRegistry)
      .getJavaScriptModule(this, executorToken, jsInterface);
}