Skip to content

Commit

Permalink
add isInspectable property
Browse files Browse the repository at this point in the history
Reviewed By: Hypuk

Differential Revision: D6578736

fbshipit-source-id: a4229c3766125ff55cff50a49893b2385f9c8a6a
  • Loading branch information
bnham authored and facebook-github-bot committed Dec 18, 2017
1 parent 3852c42 commit 15cd98b
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions React/Base/RCTBatchedBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1094,4 +1094,10 @@ - (JSContext *)jsContext
}
}

#pragma mark - Inspector

- (BOOL)isInspectable {
return NO;
}

@end
6 changes: 6 additions & 0 deletions React/Base/RCTBridge+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ RCT_EXTERN void RCTVerifyAllModulesExported(NSArray *extraModules);

@end

@interface RCTBridge (Inspector)

@property (nonatomic, readonly, getter=isInspectable) BOOL inspectable;

@end

@interface RCTBatchedBridge : RCTBridge <RCTInvalidating>

@property (nonatomic, weak, readonly) RCTBridge *parentBridge;
Expand Down
4 changes: 4 additions & 0 deletions React/CxxBridge/RCTCxxBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ - (JSGlobalContextRef)jsContextRef
return (JSGlobalContextRef)(self->_reactInstance ? self->_reactInstance->getJavaScriptContext() : nullptr);
}

- (BOOL)isInspectable {
return self->_reactInstance->isInspectable();
}

- (instancetype)initWithParentBridge:(RCTBridge *)bridge
{
RCTAssertParam(bridge);
Expand Down
4 changes: 4 additions & 0 deletions ReactCommon/cxxreact/Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ void *Instance::getJavaScriptContext() {
: nullptr;
}

bool Instance::isInspectable() {
return nativeToJsBridge_ ? nativeToJsBridge_->isInspectable() : false;
}

void Instance::callJSFunction(std::string &&module, std::string &&method,
folly::dynamic &&params) {
callback_->incrementPendingJSCalls();
Expand Down
1 change: 1 addition & 0 deletions ReactCommon/cxxreact/Instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class RN_EXPORT Instance {
void setGlobalVariable(std::string propName,
std::unique_ptr<const JSBigString> jsonValue);
void *getJavaScriptContext();
bool isInspectable();
void callJSFunction(std::string &&module, std::string &&method,
folly::dynamic &&params);
void callJSCallback(uint64_t callbackId, folly::dynamic &&params);
Expand Down
4 changes: 4 additions & 0 deletions ReactCommon/cxxreact/NativeToJsBridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ void* NativeToJsBridge::getJavaScriptContext() {
return m_executor->getJavaScriptContext();
}

bool NativeToJsBridge::isInspectable() {
return m_executor->isInspectable();
}

#ifdef WITH_JSC_MEMORY_PRESSURE
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 @@ -101,6 +101,7 @@ class NativeToJsBridge {
void registerBundle(uint32_t bundleId, const std::string& bundlePath);
void setGlobalVariable(std::string propName, std::unique_ptr<const JSBigString> jsonValue);
void* getJavaScriptContext();
bool isInspectable();

#ifdef WITH_JSC_MEMORY_PRESSURE
void handleMemoryPressure(int pressureLevel);
Expand Down

0 comments on commit 15cd98b

Please sign in to comment.