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 @implementation RCTCxxBridge
{ {
BOOL _wasBatchActive;
BOOL _didInvalidate; BOOL _didInvalidate;
BOOL _moduleRegistryCreated; BOOL _moduleRegistryCreated;
@ -1348,7 +1347,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR
- (BOOL)isBatchActive - (BOOL)isBatchActive
{ {
return _wasBatchActive; return _reactInstance ? _reactInstance->isBatchActive() : NO;
} }
- (void *)runtime - (void *)runtime

View File

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

View File

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

View File

@ -38,6 +38,10 @@ public:
return m_registry; return m_registry;
} }
bool isBatchActive() {
return m_batchHadNativeModuleCalls;
}
void callNativeModules( void callNativeModules(
JSExecutor& executor, folly::dynamic&& calls, bool isEndOfBatch) override { JSExecutor& executor, folly::dynamic&& calls, bool isEndOfBatch) override {
@ -223,6 +227,10 @@ bool NativeToJsBridge::isInspectable() {
return m_executor->isInspectable(); return m_executor->isInspectable();
} }
bool NativeToJsBridge::isBatchActive() {
return m_delegate->isBatchActive();
}
void NativeToJsBridge::handleMemoryPressure(int pressureLevel) { void NativeToJsBridge::handleMemoryPressure(int pressureLevel) {
runOnExecutorQueue([=] (JSExecutor* executor) { runOnExecutorQueue([=] (JSExecutor* executor) {
executor->handleMemoryPressure(pressureLevel); executor->handleMemoryPressure(pressureLevel);

View File

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