Fix isBatchActive of RCTCxxBridge (#22785)

Summary:
Seems we lost handler of `isBatchActive` from [RCTBatchedBridge a86171a](a86171a482/React/Base/RCTBatchedBridge.m) to [RCTCxxBridge 5bc7e39](b774820dc2 (diff-a2a67635fffd7b690d14dc17ae563a71)).

Changelog:
----------

[iOS] [fixed] - Fix isBatchActive of RCTCxxBridge
Pull Request resolved: https://github.com/facebook/react-native/pull/22785

Reviewed By: mhorowitz

Differential Revision: D13731897

Pulled By: cpojer

fbshipit-source-id: 8d6b85bcea8fe8997a93b4e1ac8b8007422ca20e
This commit is contained in:
zhongwuzw 2019-01-21 00:24:48 -08:00 committed by Facebook Github Bot
parent be51dbc214
commit d55558e138
5 changed files with 15 additions and 2 deletions

View File

@ -152,7 +152,6 @@ struct RCTInstanceCallback : public InstanceCallback {
@implementation RCTCxxBridge
{
BOOL _wasBatchActive;
BOOL _didInvalidate;
BOOL _moduleRegistryCreated;
@ -1348,7 +1347,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR
- (BOOL)isBatchActive
{
return _wasBatchActive;
return _reactInstance ? _reactInstance->isBatchActive() : NO;
}
- (void *)runtime

View File

@ -149,6 +149,10 @@ void *Instance::getJavaScriptContext() {
bool Instance::isInspectable() {
return nativeToJsBridge_ ? nativeToJsBridge_->isInspectable() : false;
}
bool Instance::isBatchActive() {
return nativeToJsBridge_ ? nativeToJsBridge_->isBatchActive() : false;
}
void Instance::callJSFunction(std::string &&module, std::string &&method,
folly::dynamic &&params) {

View File

@ -58,6 +58,7 @@ public:
std::unique_ptr<const JSBigString> jsonValue);
void *getJavaScriptContext();
bool isInspectable();
bool isBatchActive();
void callJSFunction(std::string &&module, std::string &&method,
folly::dynamic &&params);
void callJSCallback(uint64_t callbackId, folly::dynamic &&params);

View File

@ -37,6 +37,10 @@ public:
std::shared_ptr<ModuleRegistry> getModuleRegistry() override {
return m_registry;
}
bool isBatchActive() {
return m_batchHadNativeModuleCalls;
}
void callNativeModules(
JSExecutor& executor, folly::dynamic&& calls, bool isEndOfBatch) override {
@ -222,6 +226,10 @@ void* NativeToJsBridge::getJavaScriptContext() {
bool NativeToJsBridge::isInspectable() {
return m_executor->isInspectable();
}
bool NativeToJsBridge::isBatchActive() {
return m_delegate->isBatchActive();
}
void NativeToJsBridge::handleMemoryPressure(int pressureLevel) {
runOnExecutorQueue([=] (JSExecutor* executor) {

View File

@ -75,6 +75,7 @@ public:
void setGlobalVariable(std::string propName, std::unique_ptr<const JSBigString> jsonValue);
void* getJavaScriptContext();
bool isInspectable();
bool isBatchActive();
void handleMemoryPressure(int pressureLevel);