Permalink
Browse files

Fix timers not firing when running in JS debugger

Reviewed By: mhorowitz

Differential Revision: D5227125

fbshipit-source-id: 3dadb3f2e2fd088853537c09cc019d7be6319444
  • Loading branch information...
javache authored and facebook-github-bot committed Jun 13, 2017
1 parent 96d3be1 commit 64825389dfb4e01d5b30cd63b0b41937a9bb431d
Showing with 14 additions and 7 deletions.
  1. +14 −7 React/CxxBridge/RCTObjcExecutor.mm
@@ -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,26 +33,31 @@
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) {
m_errorBlock(error);
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 @@ virtual void stopProfiler(const std::string &titleString,
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 @@ virtual void stopProfiler(const std::string &titleString,
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));
}
}

0 comments on commit 6482538

Please sign in to comment.