Fix timers not firing when running in JS debugger
Reviewed By: mhorowitz Differential Revision: D5227125 fbshipit-source-id: 3dadb3f2e2fd088853537c09cc019d7be6319444
This commit is contained in:
parent
96d3be18bf
commit
64825389df
|
@ -16,6 +16,7 @@
|
|||
#import <React/RCTProfile.h>
|
||||
#import <React/RCTUtils.h>
|
||||
#import <cxxreact/Executor.h>
|
||||
#import <cxxreact/MessageQueueThread.h>
|
||||
#import <cxxreact/ModuleRegistry.h>
|
||||
#import <folly/json.h>
|
||||
|
||||
|
@ -32,11 +33,14 @@ public:
|
|||
|
||||
class RCTObjcExecutor : public JSExecutor {
|
||||
public:
|
||||
RCTObjcExecutor(id<RCTJavaScriptExecutor> jse, RCTJavaScriptCompleteBlock errorBlock,
|
||||
std::shared_ptr<facebook::react::ExecutorDelegate> delegate)
|
||||
RCTObjcExecutor(id<RCTJavaScriptExecutor> jse,
|
||||
RCTJavaScriptCompleteBlock errorBlock,
|
||||
std::shared_ptr<MessageQueueThread> jsThread,
|
||||
std::shared_ptr<ExecutorDelegate> delegate)
|
||||
: m_jse(jse)
|
||||
, m_errorBlock(errorBlock)
|
||||
, m_delegate(delegate)
|
||||
, m_jsThread(std::move(jsThread))
|
||||
, m_delegate(std::move(delegate))
|
||||
{
|
||||
m_jsCallback = ^(id json, NSError *error) {
|
||||
if (error) {
|
||||
|
@ -44,14 +48,16 @@ public:
|
|||
return;
|
||||
}
|
||||
|
||||
m_delegate->callNativeModules(*this, [RCTConvert folly_dynamic:json], true);
|
||||
m_jsThread->runOnQueue([this, json]{
|
||||
m_delegate->callNativeModules(*this, [RCTConvert folly_dynamic:json], true);
|
||||
});
|
||||
};
|
||||
|
||||
// Synchronously initialize the executor
|
||||
[jse setUp];
|
||||
|
||||
folly::dynamic nativeModuleConfig = folly::dynamic::array;
|
||||
auto moduleRegistry = delegate->getModuleRegistry();
|
||||
auto moduleRegistry = m_delegate->getModuleRegistry();
|
||||
for (const auto &name : moduleRegistry->moduleNames()) {
|
||||
auto config = moduleRegistry->getConfig(name);
|
||||
nativeModuleConfig.push_back(config ? config->config : nullptr);
|
||||
|
@ -120,7 +126,8 @@ public:
|
|||
private:
|
||||
id<RCTJavaScriptExecutor> m_jse;
|
||||
RCTJavaScriptCompleteBlock m_errorBlock;
|
||||
std::shared_ptr<facebook::react::ExecutorDelegate> m_delegate;
|
||||
std::shared_ptr<ExecutorDelegate> m_delegate;
|
||||
std::shared_ptr<MessageQueueThread> m_jsThread;
|
||||
RCTJavaScriptCallback m_jsCallback;
|
||||
};
|
||||
|
||||
|
@ -135,7 +142,7 @@ std::unique_ptr<JSExecutor> RCTObjcExecutorFactory::createJSExecutor(
|
|||
std::shared_ptr<ExecutorDelegate> delegate,
|
||||
std::shared_ptr<MessageQueueThread> jsQueue) {
|
||||
return std::unique_ptr<JSExecutor>(
|
||||
new RCTObjcExecutor(m_jse, m_errorBlock, delegate));
|
||||
new RCTObjcExecutor(m_jse, m_errorBlock, jsQueue, delegate));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue