Java Code Examples for com.facebook.react.bridge.queue.ReactQueueConfigurationSpec

The following are top voted examples for showing how to use com.facebook.react.bridge.queue.ReactQueueConfigurationSpec. 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: ReactTestHelper.java   View source code 6 votes vote down vote up
/**
 * @return a CatalystInstance mock that has a default working ReactQueueConfiguration.
 */
public static CatalystInstance createMockCatalystInstance() {
  ReactQueueConfigurationSpec spec = ReactQueueConfigurationSpec.builder()
      .setJSQueueThreadSpec(MessageQueueThreadSpec.mainThreadSpec())
      .setNativeModulesQueueThreadSpec(MessageQueueThreadSpec.mainThreadSpec())
      .build();
  ReactQueueConfiguration ReactQueueConfiguration = ReactQueueConfigurationImpl.create(
      spec,
      new QueueThreadExceptionHandler() {
        @Override
        public void handleException(Exception e) {
          throw new RuntimeException(e);
        }
      });

  CatalystInstance reactInstance = mock(CatalystInstance.class);
  when(reactInstance.getReactQueueConfiguration()).thenReturn(ReactQueueConfiguration);
  when(reactInstance.getNativeModule(UIManagerModule.class))
      .thenReturn(mock(UIManagerModule.class));

  return reactInstance;
}
 
Example 2
Project: RNLearn_Project1   File: ReactTestHelper.java   View source code 6 votes vote down vote up
/**
 * @return a CatalystInstance mock that has a default working ReactQueueConfiguration.
 */
public static CatalystInstance createMockCatalystInstance() {
  ReactQueueConfigurationSpec spec = ReactQueueConfigurationSpec.builder()
      .setJSQueueThreadSpec(MessageQueueThreadSpec.mainThreadSpec())
      .setNativeModulesQueueThreadSpec(MessageQueueThreadSpec.mainThreadSpec())
      .build();
  ReactQueueConfiguration ReactQueueConfiguration = ReactQueueConfigurationImpl.create(
      spec,
      new QueueThreadExceptionHandler() {
        @Override
        public void handleException(Exception e) {
          throw new RuntimeException(e);
        }
      });

  CatalystInstance reactInstance = mock(CatalystInstance.class);
  when(reactInstance.getReactQueueConfiguration()).thenReturn(ReactQueueConfiguration);
  when(reactInstance.getNativeModule(UIManagerModule.class))
      .thenReturn(mock(UIManagerModule.class));

  return reactInstance;
}
 
Example 3
Project: ReactNativeSignatureExample   File: ReactTestHelper.java   View source code 6 votes vote down vote up
@Override
public CatalystInstance build() {
  return new CatalystInstanceImpl.Builder()
    .setReactQueueConfigurationSpec(ReactQueueConfigurationSpec.createDefault())
    .setJSExecutor(new JSCJavaScriptExecutor(new WritableNativeMap()))
    .setRegistry(mNativeModuleRegistryBuilder.build())
    .setJSModulesConfig(mJSModulesConfigBuilder.build())
    .setJSBundleLoader(JSBundleLoader.createFileLoader(
                         mContext,
                         "assets://AndroidTestBundle.js"))
    .setNativeModuleCallExceptionHandler(
      new NativeModuleCallExceptionHandler() {
          @Override
          public void handleException(Exception e) {
            throw new RuntimeException(e);
          }
      })
    .build();
}
 
Example 4
Project: ReactNativeSignatureExample   File: ReactTestHelper.java   View source code 6 votes vote down vote up
/**
 * @return a CatalystInstance mock that has a default working ReactQueueConfiguration.
 */
public static CatalystInstance createMockCatalystInstance() {
  ReactQueueConfigurationSpec spec = ReactQueueConfigurationSpec.builder()
      .setJSQueueThreadSpec(MessageQueueThreadSpec.mainThreadSpec())
      .setNativeModulesQueueThreadSpec(MessageQueueThreadSpec.mainThreadSpec())
      .build();
  ReactQueueConfiguration ReactQueueConfiguration = ReactQueueConfigurationImpl.create(
      spec,
      new QueueThreadExceptionHandler() {
        @Override
        public void handleException(Exception e) {
          throw new RuntimeException(e);
        }
      });

  CatalystInstance reactInstance = mock(CatalystInstance.class);
  when(reactInstance.getReactQueueConfiguration()).thenReturn(ReactQueueConfiguration);
  when(reactInstance.getNativeModule(UIManagerModule.class))
      .thenReturn(mock(UIManagerModule.class));

  return reactInstance;
}
 
Example 5
Project: react-native-ibeacon-android   File: ReactTestHelper.java   View source code 6 votes vote down vote up
@Override
public CatalystInstance build() {
  return new CatalystInstanceImpl.Builder()
    .setReactQueueConfigurationSpec(ReactQueueConfigurationSpec.createDefault())
    .setJSExecutor(new JSCJavaScriptExecutor(new WritableNativeMap()))
    .setRegistry(mNativeModuleRegistryBuilder.build())
    .setJSModulesConfig(mJSModulesConfigBuilder.build())
    .setJSBundleLoader(JSBundleLoader.createFileLoader(
                         mContext,
                         "assets://AndroidTestBundle.js"))
    .setNativeModuleCallExceptionHandler(
      new NativeModuleCallExceptionHandler() {
          @Override
          public void handleException(Exception e) {
            throw new RuntimeException(e);
          }
      })
    .build();
}
 
Example 6
Project: react-native-ibeacon-android   File: ReactTestHelper.java   View source code 6 votes vote down vote up
/**
 * @return a CatalystInstance mock that has a default working ReactQueueConfiguration.
 */
public static CatalystInstance createMockCatalystInstance() {
  ReactQueueConfigurationSpec spec = ReactQueueConfigurationSpec.builder()
      .setJSQueueThreadSpec(MessageQueueThreadSpec.mainThreadSpec())
      .setNativeModulesQueueThreadSpec(MessageQueueThreadSpec.mainThreadSpec())
      .build();
  ReactQueueConfiguration ReactQueueConfiguration = ReactQueueConfigurationImpl.create(
      spec,
      new QueueThreadExceptionHandler() {
        @Override
        public void handleException(Exception e) {
          throw new RuntimeException(e);
        }
      });

  CatalystInstance reactInstance = mock(CatalystInstance.class);
  when(reactInstance.getReactQueueConfiguration()).thenReturn(ReactQueueConfiguration);
  when(reactInstance.getNativeModule(UIManagerModule.class))
      .thenReturn(mock(UIManagerModule.class));

  return reactInstance;
}
 
Example 7
Project: react-native-box-loaders   File: ReactTestHelper.java   View source code 6 votes vote down vote up
@Override
public CatalystInstance build() {
  return new CatalystInstanceImpl.Builder()
    .setReactQueueConfigurationSpec(ReactQueueConfigurationSpec.createDefault())
    .setJSExecutor(new JSCJavaScriptExecutor(new WritableNativeMap()))
    .setRegistry(mNativeModuleRegistryBuilder.build())
    .setJSModulesConfig(mJSModulesConfigBuilder.build())
    .setJSBundleLoader(JSBundleLoader.createFileLoader(
                         mContext,
                         "assets://AndroidTestBundle.js"))
    .setNativeModuleCallExceptionHandler(
      new NativeModuleCallExceptionHandler() {
          @Override
          public void handleException(Exception e) {
            throw new RuntimeException(e);
          }
      })
    .build();
}
 
Example 8
Project: react-native-box-loaders   File: ReactTestHelper.java   View source code 6 votes vote down vote up
/**
 * @return a CatalystInstance mock that has a default working ReactQueueConfiguration.
 */
public static CatalystInstance createMockCatalystInstance() {
  ReactQueueConfigurationSpec spec = ReactQueueConfigurationSpec.builder()
      .setJSQueueThreadSpec(MessageQueueThreadSpec.mainThreadSpec())
      .setNativeModulesQueueThreadSpec(MessageQueueThreadSpec.mainThreadSpec())
      .build();
  ReactQueueConfiguration ReactQueueConfiguration = ReactQueueConfigurationImpl.create(
      spec,
      new QueueThreadExceptionHandler() {
        @Override
        public void handleException(Exception e) {
          throw new RuntimeException(e);
        }
      });

  CatalystInstance reactInstance = mock(CatalystInstance.class);
  when(reactInstance.getReactQueueConfiguration()).thenReturn(ReactQueueConfiguration);
  when(reactInstance.getNativeModule(UIManagerModule.class))
      .thenReturn(mock(UIManagerModule.class));

  return reactInstance;
}
 
Example 9
Project: Ironman   File: ReactTestHelper.java   View source code 6 votes vote down vote up
/**
 * @return a CatalystInstance mock that has a default working ReactQueueConfiguration.
 */
public static CatalystInstance createMockCatalystInstance() {
  ReactQueueConfigurationSpec spec = ReactQueueConfigurationSpec.builder()
      .setJSQueueThreadSpec(MessageQueueThreadSpec.mainThreadSpec())
      .setNativeModulesQueueThreadSpec(MessageQueueThreadSpec.mainThreadSpec())
      .build();
  ReactQueueConfiguration ReactQueueConfiguration = ReactQueueConfigurationImpl.create(
      spec,
      new QueueThreadExceptionHandler() {
        @Override
        public void handleException(Exception e) {
          throw new RuntimeException(e);
        }
      });

  CatalystInstance reactInstance = mock(CatalystInstance.class);
  when(reactInstance.getReactQueueConfiguration()).thenReturn(ReactQueueConfiguration);
  when(reactInstance.getNativeModule(UIManagerModule.class))
      .thenReturn(mock(UIManagerModule.class));

  return reactInstance;
}
 
Example 10
Project: RNLearn_Project1   File: CatalystInstanceImpl.java   View source code 5 votes vote down vote up
private CatalystInstanceImpl(
    final ReactQueueConfigurationSpec ReactQueueConfigurationSpec,
    final JavaScriptExecutor jsExecutor,
    final NativeModuleRegistry registry,
    final JavaScriptModuleRegistry jsModuleRegistry,
    final JSBundleLoader jsBundleLoader,
    NativeModuleCallExceptionHandler nativeModuleCallExceptionHandler) {
  FLog.d(ReactConstants.TAG, "Initializing React Xplat Bridge.");
  mHybridData = initHybrid();

  mReactQueueConfiguration = ReactQueueConfigurationImpl.create(
      ReactQueueConfigurationSpec,
      new NativeExceptionHandler());
  mBridgeIdleListeners = new CopyOnWriteArrayList<>();
  mJavaRegistry = registry;
  mJSModuleRegistry = jsModuleRegistry;
  mJSBundleLoader = jsBundleLoader;
  mNativeModuleCallExceptionHandler = nativeModuleCallExceptionHandler;
  mNativeModulesQueueThread = mReactQueueConfiguration.getNativeModulesQueueThread();
  mTraceListener = new JSProfilerTraceListener(this);

  FLog.d(ReactConstants.TAG, "Initializing React Xplat Bridge before initializeBridge");
  initializeBridge(
    new BridgeCallback(this),
    jsExecutor,
    mReactQueueConfiguration.getJSQueueThread(),
    mNativeModulesQueueThread,
    mJavaRegistry.getJavaModules(this),
    mJavaRegistry.getCxxModules());
  FLog.d(ReactConstants.TAG, "Initializing React Xplat Bridge after initializeBridge");
  mMainExecutorToken = getMainExecutorToken();
}
 
Example 11
Project: RNLearn_Project1   File: CatalystInstanceImpl.java   View source code 5 votes vote down vote up
private CatalystInstanceImpl(
    final ReactQueueConfigurationSpec ReactQueueConfigurationSpec,
    final JavaScriptExecutor jsExecutor,
    final NativeModuleRegistry registry,
    final JavaScriptModuleRegistry jsModuleRegistry,
    final JSBundleLoader jsBundleLoader,
    NativeModuleCallExceptionHandler nativeModuleCallExceptionHandler) {
  FLog.w(ReactConstants.TAG, "Initializing React Xplat Bridge.");
  mHybridData = initHybrid();

  mReactQueueConfiguration = ReactQueueConfigurationImpl.create(
      ReactQueueConfigurationSpec,
      new NativeExceptionHandler());
  mBridgeIdleListeners = new CopyOnWriteArrayList<>();
  mJavaRegistry = registry;
  mJSModuleRegistry = jsModuleRegistry;
  mJSBundleLoader = jsBundleLoader;
  mNativeModuleCallExceptionHandler = nativeModuleCallExceptionHandler;
  mNativeModulesQueueThread = mReactQueueConfiguration.getNativeModulesQueueThread();
  mTraceListener = new JSProfilerTraceListener(this);

  FLog.w(ReactConstants.TAG, "Initializing React Xplat Bridge before initializeBridge");
  initializeBridge(
    new BridgeCallback(this),
    jsExecutor,
    mReactQueueConfiguration.getJSQueueThread(),
    mNativeModulesQueueThread,
    mJavaRegistry.getJavaModules(this),
    mJavaRegistry.getCxxModules());
  FLog.w(ReactConstants.TAG, "Initializing React Xplat Bridge after initializeBridge");
  mMainExecutorToken = getMainExecutorToken();
}
 
Example 12
Project: ReactNativeSignatureExample   File: CatalystInstanceImpl.java   View source code 5 votes vote down vote up
private CatalystInstanceImpl(
    final ReactQueueConfigurationSpec ReactQueueConfigurationSpec,
    final JavaScriptExecutor jsExecutor,
    final NativeModuleRegistry registry,
    final JavaScriptModulesConfig jsModulesConfig,
    final JSBundleLoader jsBundleLoader,
    NativeModuleCallExceptionHandler nativeModuleCallExceptionHandler) {
  FLog.d(ReactConstants.TAG, "Initializing React Bridge.");
  mReactQueueConfiguration = ReactQueueConfigurationImpl.create(
      ReactQueueConfigurationSpec,
      new NativeExceptionHandler());
  mBridgeIdleListeners = new CopyOnWriteArrayList<>();
  mJavaRegistry = registry;
  mJSModuleRegistry = new JavaScriptModuleRegistry(CatalystInstanceImpl.this, jsModulesConfig);
  mJSBundleLoader = jsBundleLoader;
  mNativeModuleCallExceptionHandler = nativeModuleCallExceptionHandler;
  mTraceListener = new JSProfilerTraceListener();

  try {
    mBridge = mReactQueueConfiguration.getJSQueueThread().callOnQueue(
        new Callable<ReactBridge>() {
          @Override
          public ReactBridge call() throws Exception {
            Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "initializeBridge");
            try {
              return initializeBridge(jsExecutor, jsModulesConfig);
            } finally {
              Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
            }
          }
        }).get();
  } catch (Exception t) {
    throw new RuntimeException("Failed to initialize bridge", t);
  }
}
 
Example 13
Project: react-native-ibeacon-android   File: CatalystInstanceImpl.java   View source code 5 votes vote down vote up
private CatalystInstanceImpl(
    final ReactQueueConfigurationSpec ReactQueueConfigurationSpec,
    final JavaScriptExecutor jsExecutor,
    final NativeModuleRegistry registry,
    final JavaScriptModulesConfig jsModulesConfig,
    final JSBundleLoader jsBundleLoader,
    NativeModuleCallExceptionHandler nativeModuleCallExceptionHandler) {
  FLog.d(ReactConstants.TAG, "Initializing React Bridge.");
  mReactQueueConfiguration = ReactQueueConfigurationImpl.create(
      ReactQueueConfigurationSpec,
      new NativeExceptionHandler());
  mBridgeIdleListeners = new CopyOnWriteArrayList<>();
  mJavaRegistry = registry;
  mJSModuleRegistry = new JavaScriptModuleRegistry(CatalystInstanceImpl.this, jsModulesConfig);
  mJSBundleLoader = jsBundleLoader;
  mNativeModuleCallExceptionHandler = nativeModuleCallExceptionHandler;
  mTraceListener = new JSProfilerTraceListener();

  try {
    mBridge = mReactQueueConfiguration.getJSQueueThread().callOnQueue(
        new Callable<ReactBridge>() {
          @Override
          public ReactBridge call() throws Exception {
            Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "initializeBridge");
            try {
              return initializeBridge(jsExecutor, jsModulesConfig);
            } finally {
              Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
            }
          }
        }).get();
  } catch (Exception t) {
    throw new RuntimeException("Failed to initialize bridge", t);
  }
}
 
Example 14
Project: react-native-box-loaders   File: CatalystInstanceImpl.java   View source code 5 votes vote down vote up
private CatalystInstanceImpl(
    final ReactQueueConfigurationSpec ReactQueueConfigurationSpec,
    final JavaScriptExecutor jsExecutor,
    final NativeModuleRegistry registry,
    final JavaScriptModulesConfig jsModulesConfig,
    final JSBundleLoader jsBundleLoader,
    NativeModuleCallExceptionHandler nativeModuleCallExceptionHandler) {
  FLog.d(ReactConstants.TAG, "Initializing React Bridge.");
  mReactQueueConfiguration = ReactQueueConfigurationImpl.create(
      ReactQueueConfigurationSpec,
      new NativeExceptionHandler());
  mBridgeIdleListeners = new CopyOnWriteArrayList<>();
  mJavaRegistry = registry;
  mJSModuleRegistry = new JavaScriptModuleRegistry(CatalystInstanceImpl.this, jsModulesConfig);
  mJSBundleLoader = jsBundleLoader;
  mNativeModuleCallExceptionHandler = nativeModuleCallExceptionHandler;
  mTraceListener = new JSProfilerTraceListener();

  try {
    mBridge = mReactQueueConfiguration.getJSQueueThread().callOnQueue(
        new Callable<ReactBridge>() {
          @Override
          public ReactBridge call() throws Exception {
            Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "initializeBridge");
            try {
              return initializeBridge(jsExecutor, jsModulesConfig);
            } finally {
              Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
            }
          }
        }).get();
  } catch (Exception t) {
    throw new RuntimeException("Failed to initialize bridge", t);
  }
}
 
Example 15
Project: Ironman   File: CatalystInstanceImpl.java   View source code 5 votes vote down vote up
private CatalystInstanceImpl(
    final ReactQueueConfigurationSpec ReactQueueConfigurationSpec,
    final JavaScriptExecutor jsExecutor,
    final NativeModuleRegistry registry,
    final JavaScriptModuleRegistry jsModuleRegistry,
    final JSBundleLoader jsBundleLoader,
    NativeModuleCallExceptionHandler nativeModuleCallExceptionHandler) {
  FLog.d(ReactConstants.TAG, "Initializing React Xplat Bridge.");
  mHybridData = initHybrid();

  mReactQueueConfiguration = ReactQueueConfigurationImpl.create(
      ReactQueueConfigurationSpec,
      new NativeExceptionHandler());
  mBridgeIdleListeners = new CopyOnWriteArrayList<>();
  mJavaRegistry = registry;
  mJSModuleRegistry = jsModuleRegistry;
  mJSBundleLoader = jsBundleLoader;
  mNativeModuleCallExceptionHandler = nativeModuleCallExceptionHandler;
  mTraceListener = new JSProfilerTraceListener(this);

  initializeBridge(
    new BridgeCallback(this),
    jsExecutor,
    mReactQueueConfiguration.getJSQueueThread(),
    mReactQueueConfiguration.getNativeModulesQueueThread(),
    mJavaRegistry.getModuleRegistryHolder(this));
  mMainExecutorToken = getMainExecutorToken();
}
 
Example 16
Project: RNLearn_Project1   File: CatalystInstanceImpl.java   View source code 4 votes vote down vote up
public Builder setReactQueueConfigurationSpec(
    ReactQueueConfigurationSpec ReactQueueConfigurationSpec) {
  mReactQueueConfigurationSpec = ReactQueueConfigurationSpec;
  return this;
}
 
Example 17
Project: RNLearn_Project1   File: CatalystInstanceImpl.java   View source code 4 votes vote down vote up
public Builder setReactQueueConfigurationSpec(
    ReactQueueConfigurationSpec ReactQueueConfigurationSpec) {
  mReactQueueConfigurationSpec = ReactQueueConfigurationSpec;
  return this;
}
 
Example 18
Project: ReactNativeSignatureExample   File: CatalystInstanceImpl.java   View source code 4 votes vote down vote up
public Builder setReactQueueConfigurationSpec(
    ReactQueueConfigurationSpec ReactQueueConfigurationSpec) {
  mReactQueueConfigurationSpec = ReactQueueConfigurationSpec;
  return this;
}
 
Example 19
Project: react-native-ibeacon-android   File: CatalystInstanceImpl.java   View source code 4 votes vote down vote up
public Builder setReactQueueConfigurationSpec(
    ReactQueueConfigurationSpec ReactQueueConfigurationSpec) {
  mReactQueueConfigurationSpec = ReactQueueConfigurationSpec;
  return this;
}
 
Example 20
Project: react-native-box-loaders   File: CatalystInstanceImpl.java   View source code 4 votes vote down vote up
public Builder setReactQueueConfigurationSpec(
    ReactQueueConfigurationSpec ReactQueueConfigurationSpec) {
  mReactQueueConfigurationSpec = ReactQueueConfigurationSpec;
  return this;
}
 
Example 21
Project: Ironman   File: CatalystInstanceImpl.java   View source code 4 votes vote down vote up
public Builder setReactQueueConfigurationSpec(
    ReactQueueConfigurationSpec ReactQueueConfigurationSpec) {
  mReactQueueConfigurationSpec = ReactQueueConfigurationSpec;
  return this;
}