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

The following are top voted examples for showing how to use com.facebook.react.bridge.JavaScriptExecutor. 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: ReactNativeSignatureExample   File: ReactInstanceManagerImpl.java   Source Code and License 6 votes vote down vote up
private void recreateReactContextInBackground(
    JavaScriptExecutor.Factory jsExecutorFactory,
    JSBundleLoader jsBundleLoader) {
  UiThreadUtil.assertOnUiThread();

  ReactContextInitParams initParams =
      new ReactContextInitParams(jsExecutorFactory, jsBundleLoader);
  if (mReactContextInitAsyncTask == null) {
    // No background task to create react context is currently running, create and execute one.
    mReactContextInitAsyncTask = new ReactContextInitAsyncTask();
    mReactContextInitAsyncTask.execute(initParams);
  } else {
    // Background task is currently running, queue up most recent init params to recreate context
    // once task completes.
    mPendingReactContextInitParams = initParams;
  }
}
 
Example 2
Project: react-native-ibeacon-android   File: ReactInstanceManagerImpl.java   Source Code and License 6 votes vote down vote up
private void recreateReactContextInBackground(
    JavaScriptExecutor.Factory jsExecutorFactory,
    JSBundleLoader jsBundleLoader) {
  UiThreadUtil.assertOnUiThread();

  ReactContextInitParams initParams =
      new ReactContextInitParams(jsExecutorFactory, jsBundleLoader);
  if (mReactContextInitAsyncTask == null) {
    // No background task to create react context is currently running, create and execute one.
    mReactContextInitAsyncTask = new ReactContextInitAsyncTask();
    mReactContextInitAsyncTask.execute(initParams);
  } else {
    // Background task is currently running, queue up most recent init params to recreate context
    // once task completes.
    mPendingReactContextInitParams = initParams;
  }
}
 
Example 3
Project: react-native-box-loaders   File: ReactInstanceManagerImpl.java   Source Code and License 6 votes vote down vote up
private void recreateReactContextInBackground(
    JavaScriptExecutor.Factory jsExecutorFactory,
    JSBundleLoader jsBundleLoader) {
  UiThreadUtil.assertOnUiThread();

  ReactContextInitParams initParams =
      new ReactContextInitParams(jsExecutorFactory, jsBundleLoader);
  if (mReactContextInitAsyncTask == null) {
    // No background task to create react context is currently running, create and execute one.
    mReactContextInitAsyncTask = new ReactContextInitAsyncTask();
    mReactContextInitAsyncTask.execute(initParams);
  } else {
    // Background task is currently running, queue up most recent init params to recreate context
    // once task completes.
    mPendingReactContextInitParams = initParams;
  }
}
 
Example 4
Project: ReactNativeSignatureExample   File: ReactInstanceManagerImpl.java   Source Code and License 5 votes vote down vote up
@Override
protected Result<ReactApplicationContext> doInBackground(ReactContextInitParams... params) {
  Assertions.assertCondition(params != null && params.length > 0 && params[0] != null);
  try {
    JavaScriptExecutor jsExecutor =
        params[0].getJsExecutorFactory().create(
          mJSCConfig == null ? new WritableNativeMap() : mJSCConfig.getConfigMap());
    return Result.of(createReactContext(jsExecutor, params[0].getJsBundleLoader()));
  } catch (Exception e) {
    // Pass exception to onPostExecute() so it can be handled on the main thread
    return Result.of(e);
  }
}
 
Example 5
Project: react-native-ibeacon-android   File: ReactInstanceManagerImpl.java   Source Code and License 5 votes vote down vote up
@Override
protected Result<ReactApplicationContext> doInBackground(ReactContextInitParams... params) {
  Assertions.assertCondition(params != null && params.length > 0 && params[0] != null);
  try {
    JavaScriptExecutor jsExecutor =
        params[0].getJsExecutorFactory().create(
          mJSCConfig == null ? new WritableNativeMap() : mJSCConfig.getConfigMap());
    return Result.of(createReactContext(jsExecutor, params[0].getJsBundleLoader()));
  } catch (Exception e) {
    // Pass exception to onPostExecute() so it can be handled on the main thread
    return Result.of(e);
  }
}
 
Example 6
Project: react-native-box-loaders   File: ReactInstanceManagerImpl.java   Source Code and License 5 votes vote down vote up
@Override
protected Result<ReactApplicationContext> doInBackground(ReactContextInitParams... params) {
  Assertions.assertCondition(params != null && params.length > 0 && params[0] != null);
  try {
    JavaScriptExecutor jsExecutor =
        params[0].getJsExecutorFactory().create(
          mJSCConfig == null ? new WritableNativeMap() : mJSCConfig.getConfigMap());
    return Result.of(createReactContext(jsExecutor, params[0].getJsBundleLoader()));
  } catch (Exception e) {
    // Pass exception to onPostExecute() so it can be handled on the main thread
    return Result.of(e);
  }
}
 
Example 7
Project: ReactNativeSignatureExample   File: ReactInstanceManagerImpl.java   Source Code and License 4 votes vote down vote up
public ReactContextInitParams(
    JavaScriptExecutor.Factory jsExecutorFactory,
    JSBundleLoader jsBundleLoader) {
  mJsExecutorFactory = Assertions.assertNotNull(jsExecutorFactory);
  mJsBundleLoader = Assertions.assertNotNull(jsBundleLoader);
}
 
Example 8
Project: ReactNativeSignatureExample   File: ReactInstanceManagerImpl.java   Source Code and License 4 votes vote down vote up
public JavaScriptExecutor.Factory getJsExecutorFactory() {
  return mJsExecutorFactory;
}
 
Example 9
Project: react-native-ibeacon-android   File: ReactInstanceManagerImpl.java   Source Code and License 4 votes vote down vote up
public ReactContextInitParams(
    JavaScriptExecutor.Factory jsExecutorFactory,
    JSBundleLoader jsBundleLoader) {
  mJsExecutorFactory = Assertions.assertNotNull(jsExecutorFactory);
  mJsBundleLoader = Assertions.assertNotNull(jsBundleLoader);
}
 
Example 10
Project: react-native-ibeacon-android   File: ReactInstanceManagerImpl.java   Source Code and License 4 votes vote down vote up
public JavaScriptExecutor.Factory getJsExecutorFactory() {
  return mJsExecutorFactory;
}
 
Example 11
Project: react-native-box-loaders   File: ReactInstanceManagerImpl.java   Source Code and License 4 votes vote down vote up
public ReactContextInitParams(
    JavaScriptExecutor.Factory jsExecutorFactory,
    JSBundleLoader jsBundleLoader) {
  mJsExecutorFactory = Assertions.assertNotNull(jsExecutorFactory);
  mJsBundleLoader = Assertions.assertNotNull(jsBundleLoader);
}
 
Example 12
Project: react-native-box-loaders   File: ReactInstanceManagerImpl.java   Source Code and License 4 votes vote down vote up
public JavaScriptExecutor.Factory getJsExecutorFactory() {
  return mJsExecutorFactory;
}