diff --git a/React/Base/RCTBridge.h b/React/Base/RCTBridge.h index 7db16baea37735..11d453343e236a 100644 --- a/React/Base/RCTBridge.h +++ b/React/Base/RCTBridge.h @@ -120,22 +120,6 @@ RCT_EXTERN NSString *RCTBridgeModuleNameForClass(Class bridgeModuleClass); - (void)enqueueJSCall:(NSString *)moduleDotMethod args:(NSArray *)args; - (void)enqueueJSCall:(NSString *)module method:(NSString *)method args:(NSArray *)args completion:(dispatch_block_t)completion; -/** - * This method is used to call functions in the JavaScript application context - * synchronously. This is intended for use by applications which do their own - * thread management and are careful to manage multi-threaded access to the JSVM. - * See also -[RCTBridgeDelgate shouldBridgeLoadJavaScriptSynchronously], which - * may be needed to ensure that any requires JS code is loaded before this method - * is called. If the underlying executor is not JSC, this will return nil. Safe - * to call from any thread. - * - * @experimental - */ -- (JSValue *)callFunctionOnModule:(NSString *)module - method:(NSString *)method - arguments:(NSArray *)arguments - error:(NSError **)error; - /** * This method registers the file path of an additional JS segment by its ID. * diff --git a/React/Base/RCTBridge.m b/React/Base/RCTBridge.m index a84a966e361810..7250a0ea3f9bfb 100644 --- a/React/Base/RCTBridge.m +++ b/React/Base/RCTBridge.m @@ -364,14 +364,6 @@ - (void)enqueueCallback:(NSNumber *)cbID args:(NSArray *)args [self.batchedBridge enqueueCallback:cbID args:args]; } -- (JSValue *)callFunctionOnModule:(NSString *)module - method:(NSString *)method - arguments:(NSArray *)arguments - error:(NSError **)error -{ - return [self.batchedBridge callFunctionOnModule:module method:method arguments:arguments error:error]; -} - - (void)registerSegmentWithId:(NSUInteger)segmentId path:(NSString *)path { [self.batchedBridge registerSegmentWithId:segmentId path:path]; diff --git a/React/CxxBridge/RCTCxxBridge.mm b/React/CxxBridge/RCTCxxBridge.mm index 1da12b8a217e3a..50dc3fb8dba18b 100644 --- a/React/CxxBridge/RCTCxxBridge.mm +++ b/React/CxxBridge/RCTCxxBridge.mm @@ -1183,53 +1183,6 @@ - (void)executeApplicationScript:(NSData *)script }]; } -- (JSValue *)callFunctionOnModule:(NSString *)module - method:(NSString *)method - arguments:(NSArray *)arguments - error:(NSError **)error -{ - if (!_reactInstance) { - if (error) { - *error = RCTErrorWithMessage( - @"callFunctionOnModule was called on uninitialized bridge"); - } - return nil; - } else if (self.executorClass) { - if (error) { - *error = RCTErrorWithMessage( - @"callFunctionOnModule can only be used with JSC executor"); - } - return nil; - } else if (!self.valid) { - if (error) { - *error = RCTErrorWithMessage( - @"Bridge is no longer valid"); - } - return nil; - } else if (self.loading) { - if (error) { - *error = RCTErrorWithMessage( - @"Bridge is still loading"); - } - return nil; - } - - RCT_PROFILE_BEGIN_EVENT(0, @"callFunctionOnModule", (@{ @"module": module, @"method": method })); - __block JSValue *ret = nil; - NSError *errorObj = tryAndReturnError(^{ - Value result = self->_reactInstance->callFunctionSync([module UTF8String], [method UTF8String], (id)arguments); - JSContext *context = contextForGlobalContextRef(JSC_JSContextGetGlobalContext(result.context())); - ret = [JSC_JSValue(result.context()) valueWithJSValueRef:result inContext:context]; - }); - RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"js_call"); - - if (error) { - *error = errorObj; - } - - return ret; -} - - (void)registerSegmentWithId:(NSUInteger)segmentId path:(NSString *)path { if (_reactInstance) { diff --git a/ReactCommon/cxxreact/Instance.h b/ReactCommon/cxxreact/Instance.h index bcd0bea395acb3..e35ce4bbe2ac3e 100644 --- a/ReactCommon/cxxreact/Instance.h +++ b/ReactCommon/cxxreact/Instance.h @@ -63,15 +63,6 @@ class RN_EXPORT Instance { // This method is experimental, and may be modified or removed. void registerBundle(uint32_t bundleId, const std::string& bundlePath); - // This method is experimental, and may be modified or removed. - template - Value callFunctionSync(const std::string &module, const std::string &method, - T &&args) { - CHECK(nativeToJsBridge_); - return nativeToJsBridge_->callFunctionSync(module, method, - std::forward(args)); - } - const ModuleRegistry &getModuleRegistry() const; ModuleRegistry &getModuleRegistry(); diff --git a/ReactCommon/cxxreact/JSCExecutor.cpp b/ReactCommon/cxxreact/JSCExecutor.cpp index 01c8c96de19560..81e71eddbaa5e9 100644 --- a/ReactCommon/cxxreact/JSCExecutor.cpp +++ b/ReactCommon/cxxreact/JSCExecutor.cpp @@ -581,30 +581,6 @@ namespace facebook { callNativeModules(std::move(result)); } - Value JSCExecutor::callFunctionSyncWithValue( - const std::string& module, const std::string& method, Value args) { - SystraceSection s("JSCExecutor::callFunction"); - Object result = [&] { - JSContextLock lock(m_context); - if (!m_callFunctionReturnResultAndFlushedQueueJS) { - bindBridge(); - } - return m_callFunctionReturnResultAndFlushedQueueJS->callAsFunction({ - Value(m_context, String::createExpectingAscii(m_context, module)), - Value(m_context, String::createExpectingAscii(m_context, method)), - std::move(args), - }).asObject(); - }(); - - Value length = result.getProperty("length"); - - if (!length.isNumber() || length.asInteger() != 2) { - std::runtime_error("Return value of a callFunction must be an array of size 2"); - } - callNativeModules(result.getPropertyAtIndex(1)); - return result.getPropertyAtIndex(0); - } - void JSCExecutor::setGlobalVariable(std::string propName, std::unique_ptr jsonValue) { try { SystraceSection s("JSCExecutor::setGlobalVariable", "propName", propName); diff --git a/ReactCommon/cxxreact/JSCExecutor.h b/ReactCommon/cxxreact/JSCExecutor.h index 258697af5c9587..5acc967722e5ca 100644 --- a/ReactCommon/cxxreact/JSCExecutor.h +++ b/ReactCommon/cxxreact/JSCExecutor.h @@ -79,14 +79,6 @@ class RN_EXPORT JSCExecutor : public JSExecutor, public PrivateDataBase { const double callbackId, const folly::dynamic& arguments) override; - template - Value callFunctionSync( - const std::string& module, const std::string& method, T&& args) { - return callFunctionSyncWithValue( - module, method, JSCValueEncoder::type>::toJSCValue( - m_context, std::forward(args))); - } - virtual void setGlobalVariable( std::string propName, std::unique_ptr jsonValue) override; @@ -123,9 +115,6 @@ class RN_EXPORT JSCExecutor : public JSExecutor, public PrivateDataBase { void initOnJSVMThread() throw(JSException); static bool isNetworkInspected(const std::string &owner, const std::string &app, const std::string &device); - // This method is experimental, and may be modified or removed. - Value callFunctionSyncWithValue( - const std::string& module, const std::string& method, Value value); void terminateOnJSVMThread(); void bindBridge() throw(JSException); void callNativeModules(Value&&); diff --git a/ReactCommon/cxxreact/NativeToJsBridge.h b/ReactCommon/cxxreact/NativeToJsBridge.h index 586766e387bdab..78d960a08a4529 100644 --- a/ReactCommon/cxxreact/NativeToJsBridge.h +++ b/ReactCommon/cxxreact/NativeToJsBridge.h @@ -55,35 +55,6 @@ class NativeToJsBridge { */ void invokeCallback(double callbackId, folly::dynamic&& args); - /** - * Executes a JS method on the given executor synchronously, returning its - * return value. JSException will be thrown if JS throws an exception; - * another standard exception may be thrown for C++ bridge failures, or if - * the executor is not capable of synchronous calls. - * - * This method is experimental, and may be modified or removed. - * - * loadApplicationScriptSync() must be called and finished executing - * before callFunctionSync(). - */ - template - Value callFunctionSync(const std::string& module, const std::string& method, T&& args) { - if (*m_destroyed) { - throw std::logic_error( - folly::to("Synchronous call to ", module, ".", method, - " after bridge is destroyed")); - } - - JSCExecutor *jscExecutor = dynamic_cast(m_executor.get()); - if (!jscExecutor) { - throw std::invalid_argument( - folly::to("Executor type ", typeid(m_executor.get()).name(), - " does not support synchronous calls")); - } - - return jscExecutor->callFunctionSync(module, method, std::forward(args)); - } - /** * Starts the JS application. If bundleRegistry is non-null, then it is * used to fetch JavaScript modules as individual scripts.