Skip to content

Commit 19a4a7d

Browse files
Dan Zimmermanfacebook-github-bot
Dan Zimmerman
authored andcommitted
Remove callFunctionSync experimental APIs
Reviewed By: michalgr Differential Revision: D6124038 fbshipit-source-id: 219afe30783da92cf10f800dc35e64823b61cf4b
1 parent 860fcd4 commit 19a4a7d

File tree

7 files changed

+0
-144
lines changed

7 files changed

+0
-144
lines changed

React/Base/RCTBridge.h

-16
Original file line numberDiff line numberDiff line change
@@ -120,22 +120,6 @@ RCT_EXTERN NSString *RCTBridgeModuleNameForClass(Class bridgeModuleClass);
120120
- (void)enqueueJSCall:(NSString *)moduleDotMethod args:(NSArray *)args;
121121
- (void)enqueueJSCall:(NSString *)module method:(NSString *)method args:(NSArray *)args completion:(dispatch_block_t)completion;
122122

123-
/**
124-
* This method is used to call functions in the JavaScript application context
125-
* synchronously. This is intended for use by applications which do their own
126-
* thread management and are careful to manage multi-threaded access to the JSVM.
127-
* See also -[RCTBridgeDelgate shouldBridgeLoadJavaScriptSynchronously], which
128-
* may be needed to ensure that any requires JS code is loaded before this method
129-
* is called. If the underlying executor is not JSC, this will return nil. Safe
130-
* to call from any thread.
131-
*
132-
* @experimental
133-
*/
134-
- (JSValue *)callFunctionOnModule:(NSString *)module
135-
method:(NSString *)method
136-
arguments:(NSArray *)arguments
137-
error:(NSError **)error;
138-
139123
/**
140124
* This method registers the file path of an additional JS segment by its ID.
141125
*

React/Base/RCTBridge.m

-8
Original file line numberDiff line numberDiff line change
@@ -364,14 +364,6 @@ - (void)enqueueCallback:(NSNumber *)cbID args:(NSArray *)args
364364
[self.batchedBridge enqueueCallback:cbID args:args];
365365
}
366366

367-
- (JSValue *)callFunctionOnModule:(NSString *)module
368-
method:(NSString *)method
369-
arguments:(NSArray *)arguments
370-
error:(NSError **)error
371-
{
372-
return [self.batchedBridge callFunctionOnModule:module method:method arguments:arguments error:error];
373-
}
374-
375367
- (void)registerSegmentWithId:(NSUInteger)segmentId path:(NSString *)path
376368
{
377369
[self.batchedBridge registerSegmentWithId:segmentId path:path];

React/CxxBridge/RCTCxxBridge.mm

-47
Original file line numberDiff line numberDiff line change
@@ -1183,53 +1183,6 @@ - (void)executeApplicationScript:(NSData *)script
11831183
}];
11841184
}
11851185

1186-
- (JSValue *)callFunctionOnModule:(NSString *)module
1187-
method:(NSString *)method
1188-
arguments:(NSArray *)arguments
1189-
error:(NSError **)error
1190-
{
1191-
if (!_reactInstance) {
1192-
if (error) {
1193-
*error = RCTErrorWithMessage(
1194-
@"callFunctionOnModule was called on uninitialized bridge");
1195-
}
1196-
return nil;
1197-
} else if (self.executorClass) {
1198-
if (error) {
1199-
*error = RCTErrorWithMessage(
1200-
@"callFunctionOnModule can only be used with JSC executor");
1201-
}
1202-
return nil;
1203-
} else if (!self.valid) {
1204-
if (error) {
1205-
*error = RCTErrorWithMessage(
1206-
@"Bridge is no longer valid");
1207-
}
1208-
return nil;
1209-
} else if (self.loading) {
1210-
if (error) {
1211-
*error = RCTErrorWithMessage(
1212-
@"Bridge is still loading");
1213-
}
1214-
return nil;
1215-
}
1216-
1217-
RCT_PROFILE_BEGIN_EVENT(0, @"callFunctionOnModule", (@{ @"module": module, @"method": method }));
1218-
__block JSValue *ret = nil;
1219-
NSError *errorObj = tryAndReturnError(^{
1220-
Value result = self->_reactInstance->callFunctionSync([module UTF8String], [method UTF8String], (id)arguments);
1221-
JSContext *context = contextForGlobalContextRef(JSC_JSContextGetGlobalContext(result.context()));
1222-
ret = [JSC_JSValue(result.context()) valueWithJSValueRef:result inContext:context];
1223-
});
1224-
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"js_call");
1225-
1226-
if (error) {
1227-
*error = errorObj;
1228-
}
1229-
1230-
return ret;
1231-
}
1232-
12331186
- (void)registerSegmentWithId:(NSUInteger)segmentId path:(NSString *)path
12341187
{
12351188
if (_reactInstance) {

ReactCommon/cxxreact/Instance.h

-9
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,6 @@ class RN_EXPORT Instance {
6363
// This method is experimental, and may be modified or removed.
6464
void registerBundle(uint32_t bundleId, const std::string& bundlePath);
6565

66-
// This method is experimental, and may be modified or removed.
67-
template <typename T>
68-
Value callFunctionSync(const std::string &module, const std::string &method,
69-
T &&args) {
70-
CHECK(nativeToJsBridge_);
71-
return nativeToJsBridge_->callFunctionSync(module, method,
72-
std::forward<T>(args));
73-
}
74-
7566
const ModuleRegistry &getModuleRegistry() const;
7667
ModuleRegistry &getModuleRegistry();
7768

ReactCommon/cxxreact/JSCExecutor.cpp

-24
Original file line numberDiff line numberDiff line change
@@ -581,30 +581,6 @@ namespace facebook {
581581
callNativeModules(std::move(result));
582582
}
583583

584-
Value JSCExecutor::callFunctionSyncWithValue(
585-
const std::string& module, const std::string& method, Value args) {
586-
SystraceSection s("JSCExecutor::callFunction");
587-
Object result = [&] {
588-
JSContextLock lock(m_context);
589-
if (!m_callFunctionReturnResultAndFlushedQueueJS) {
590-
bindBridge();
591-
}
592-
return m_callFunctionReturnResultAndFlushedQueueJS->callAsFunction({
593-
Value(m_context, String::createExpectingAscii(m_context, module)),
594-
Value(m_context, String::createExpectingAscii(m_context, method)),
595-
std::move(args),
596-
}).asObject();
597-
}();
598-
599-
Value length = result.getProperty("length");
600-
601-
if (!length.isNumber() || length.asInteger() != 2) {
602-
std::runtime_error("Return value of a callFunction must be an array of size 2");
603-
}
604-
callNativeModules(result.getPropertyAtIndex(1));
605-
return result.getPropertyAtIndex(0);
606-
}
607-
608584
void JSCExecutor::setGlobalVariable(std::string propName, std::unique_ptr<const JSBigString> jsonValue) {
609585
try {
610586
SystraceSection s("JSCExecutor::setGlobalVariable", "propName", propName);

ReactCommon/cxxreact/JSCExecutor.h

-11
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,6 @@ class RN_EXPORT JSCExecutor : public JSExecutor, public PrivateDataBase {
7979
const double callbackId,
8080
const folly::dynamic& arguments) override;
8181

82-
template <typename T>
83-
Value callFunctionSync(
84-
const std::string& module, const std::string& method, T&& args) {
85-
return callFunctionSyncWithValue(
86-
module, method, JSCValueEncoder<typename std::decay<T>::type>::toJSCValue(
87-
m_context, std::forward<T>(args)));
88-
}
89-
9082
virtual void setGlobalVariable(
9183
std::string propName,
9284
std::unique_ptr<const JSBigString> jsonValue) override;
@@ -123,9 +115,6 @@ class RN_EXPORT JSCExecutor : public JSExecutor, public PrivateDataBase {
123115

124116
void initOnJSVMThread() throw(JSException);
125117
static bool isNetworkInspected(const std::string &owner, const std::string &app, const std::string &device);
126-
// This method is experimental, and may be modified or removed.
127-
Value callFunctionSyncWithValue(
128-
const std::string& module, const std::string& method, Value value);
129118
void terminateOnJSVMThread();
130119
void bindBridge() throw(JSException);
131120
void callNativeModules(Value&&);

ReactCommon/cxxreact/NativeToJsBridge.h

-29
Original file line numberDiff line numberDiff line change
@@ -55,35 +55,6 @@ class NativeToJsBridge {
5555
*/
5656
void invokeCallback(double callbackId, folly::dynamic&& args);
5757

58-
/**
59-
* Executes a JS method on the given executor synchronously, returning its
60-
* return value. JSException will be thrown if JS throws an exception;
61-
* another standard exception may be thrown for C++ bridge failures, or if
62-
* the executor is not capable of synchronous calls.
63-
*
64-
* This method is experimental, and may be modified or removed.
65-
*
66-
* loadApplicationScriptSync() must be called and finished executing
67-
* before callFunctionSync().
68-
*/
69-
template <typename T>
70-
Value callFunctionSync(const std::string& module, const std::string& method, T&& args) {
71-
if (*m_destroyed) {
72-
throw std::logic_error(
73-
folly::to<std::string>("Synchronous call to ", module, ".", method,
74-
" after bridge is destroyed"));
75-
}
76-
77-
JSCExecutor *jscExecutor = dynamic_cast<JSCExecutor*>(m_executor.get());
78-
if (!jscExecutor) {
79-
throw std::invalid_argument(
80-
folly::to<std::string>("Executor type ", typeid(m_executor.get()).name(),
81-
" does not support synchronous calls"));
82-
}
83-
84-
return jscExecutor->callFunctionSync(module, method, std::forward<T>(args));
85-
}
86-
8758
/**
8859
* Starts the JS application. If bundleRegistry is non-null, then it is
8960
* used to fetch JavaScript modules as individual scripts.

0 commit comments

Comments
 (0)