コード例 #1
0
ファイル: Bridge.cpp プロジェクト: 12527133/ios122
 void executeJSCall(
     const std::string& moduleName,
     const std::string& methodName,
     const std::vector<folly::dynamic>& arguments) {
   auto returnedJSON = m_jsExecutor->executeJSCall(moduleName, methodName, arguments);
   m_callback(parseMethodCalls(returnedJSON), true /* = isEndOfBatch */);
 }
コード例 #2
0
ファイル: Bridge.cpp プロジェクト: 12527133/ios122
 JSThreadState(const RefPtr<JSExecutorFactory>& jsExecutorFactory, Bridge::Callback&& callback) :
   m_callback(callback)
 {
   m_jsExecutor = jsExecutorFactory->createJSExecutor([this, callback] (std::string queueJSON) {
     m_callback(parseMethodCalls(queueJSON), false /* = isEndOfBatch */);
   });
 }
コード例 #3
0
  void callNativeModules(
      JSExecutor& executor, folly::dynamic&& calls, bool isEndOfBatch) override {

    CHECK(m_registry || calls.empty()) <<
      "native module calls cannot be completed with no native modules";
    m_batchHadNativeModuleCalls = m_batchHadNativeModuleCalls || !calls.empty();

    // An exception anywhere in here stops processing of the batch.  This
    // was the behavior of the Android bridge, and since exception handling
    // terminates the whole bridge, there's not much point in continuing.
    for (auto& call : parseMethodCalls(std::move(calls))) {
      m_registry->callNativeMethod(call.moduleId, call.methodId, std::move(call.arguments), call.callId);
    }
    if (isEndOfBatch) {
      // onBatchComplete will be called on the native (module) queue, but
      // decrementPendingJSCalls will be called sync. Be aware that the bridge may still
      // be processing native calls when the birdge idle signaler fires.
      if (m_batchHadNativeModuleCalls) {
        m_callback->onBatchComplete();
        m_batchHadNativeModuleCalls = false;
      }
      m_callback->decrementPendingJSCalls();
    }
  }
コード例 #4
0
ファイル: Bridge.cpp プロジェクト: PanJs/react-native
 void invokeCallback(const double callbackId, const folly::dynamic& arguments) {
   auto returnedJSON = m_jsExecutor->invokeCallback(callbackId, arguments);
   m_callback(parseMethodCalls(returnedJSON), true /* = isEndOfBatch */);
 }
コード例 #5
0
ファイル: Bridge.cpp プロジェクト: PanJs/react-native
 void callFunction(const double moduleId, const double methodId, const folly::dynamic& arguments) {
   auto returnedJSON = m_jsExecutor->callFunction(moduleId, methodId, arguments);
   m_callback(parseMethodCalls(returnedJSON), true /* = isEndOfBatch */);
 }
コード例 #6
0
ファイル: Bridge.cpp プロジェクト: PanJs/react-native
 void flush() {
   auto returnedJSON = m_jsExecutor->flush();
   m_callback(parseMethodCalls(returnedJSON), true /* = isEndOfBatch */);
 }