diff --git a/React/Base/RCTBridge+Private.h b/React/Base/RCTBridge+Private.h index 8412f1095fa..a5e8e528194 100644 --- a/React/Base/RCTBridge+Private.h +++ b/React/Base/RCTBridge+Private.h @@ -102,6 +102,11 @@ RCT_EXTERN void RCTRegisterModule(Class); */ - (void)dispatchBlock:(dispatch_block_t)block queue:(dispatch_queue_t)queue; +/** + * Call JSIExecutor::flush + */ +- (void)flush; + /** * Get the module data for a given module name. Used by UIManager to implement * the `dispatchViewManagerCommand` method. diff --git a/React/CxxBridge/RCTCxxBridge.mm b/React/CxxBridge/RCTCxxBridge.mm index e3b4ac19ff5..60c851de0c4 100644 --- a/React/CxxBridge/RCTCxxBridge.mm +++ b/React/CxxBridge/RCTCxxBridge.mm @@ -1239,6 +1239,11 @@ - (void)dispatchBlock:(dispatch_block_t)block queue:(dispatch_queue_t)queue } } +- (void)flush +{ + _reactInstance->flush(); +} + #pragma mark - RCTInvalidating - (void)invalidate diff --git a/ReactCommon/cxxreact/Instance.cpp b/ReactCommon/cxxreact/Instance.cpp index a48d5930ecf..2e4a8a2fb3f 100644 --- a/ReactCommon/cxxreact/Instance.cpp +++ b/ReactCommon/cxxreact/Instance.cpp @@ -246,6 +246,10 @@ std::shared_ptr Instance::getJSCallInvoker() { return std::static_pointer_cast(jsCallInvoker_); } +void Instance::flush() { + nativeToJsBridge_->runOnExecutorQueue([](JSExecutor *executor) { executor->flush(); }); +} + RuntimeExecutor Instance::getRuntimeExecutor() { std::weak_ptr weakNativeToJsBridge = nativeToJsBridge_; diff --git a/ReactCommon/cxxreact/Instance.h b/ReactCommon/cxxreact/Instance.h index 8b2263679a0..8527176f69f 100644 --- a/ReactCommon/cxxreact/Instance.h +++ b/ReactCommon/cxxreact/Instance.h @@ -83,6 +83,7 @@ class RN_EXPORT Instance { std::string &&method, folly::dynamic &¶ms); void callJSCallback(uint64_t callbackId, folly::dynamic &¶ms); + void flush(); // This method is experimental, and may be modified or removed. void registerBundle(uint32_t bundleId, const std::string &bundlePath);