Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions React/CxxBridge/RCTCxxBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ void onBatchComplete() override {

@implementation RCTCxxBridge
{
BOOL _wasBatchActive;
BOOL _didInvalidate;
BOOL _moduleRegistryCreated;

Expand Down Expand Up @@ -1360,7 +1359,7 @@ - (void)stopProfiling:(void (^)(NSData *))callback

- (BOOL)isBatchActive
{
return _wasBatchActive;
return _reactInstance ? _reactInstance->isBatchActive() : NO;
}

- (void *)runtime
Expand Down
4 changes: 4 additions & 0 deletions ReactCommon/cxxreact/Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions ReactCommon/cxxreact/Instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class RN_EXPORT Instance {
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);
Expand Down
8 changes: 8 additions & 0 deletions ReactCommon/cxxreact/NativeToJsBridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ class JsToNativeBridge : public react::ExecutorDelegate {
std::shared_ptr<ModuleRegistry> getModuleRegistry() override {
return m_registry;
}

bool isBatchActive() {
return m_batchHadNativeModuleCalls;
}

void callNativeModules(
JSExecutor& executor, folly::dynamic&& calls, bool isEndOfBatch) override {
Expand Down Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions ReactCommon/cxxreact/NativeToJsBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class NativeToJsBridge {
void setGlobalVariable(std::string propName, std::unique_ptr<const JSBigString> jsonValue);
void* getJavaScriptContext();
bool isInspectable();
bool isBatchActive();

void handleMemoryPressure(int pressureLevel);

Expand Down