allow installing extra JS binding via the bridge

Reviewed By: mdvacca

Differential Revision: D6957397

fbshipit-source-id: 172905861fbb1c9ed45149e33b406c28ad616cd7
This commit is contained in:
Kevin Gozali 2018-02-13 22:26:37 -08:00 committed by Facebook Github Bot
parent 4761d5a83e
commit e165d0dcf0
2 changed files with 20 additions and 0 deletions

View File

@ -515,6 +515,8 @@ struct RCTInstanceCallback : public InstanceCallback {
std::make_unique<JSBigStdString>("true"));
}
#endif
[self installExtraJSBinding];
}
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
@ -609,6 +611,16 @@ struct RCTInstanceCallback : public InstanceCallback {
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
}
- (void)installExtraJSBinding
{
if ([self.delegate conformsToProtocol:@protocol(RCTCxxBridgeDelegate)]) {
id<RCTCxxBridgeDelegate> cxxDelegate = (id<RCTCxxBridgeDelegate>) self.delegate;
if ([cxxDelegate respondsToSelector:@selector(installExtraJSBinding:)]) {
[cxxDelegate installExtraJSBinding:self.jsContextRef];
}
}
}
- (void)_initModules:(NSArray<id<RCTBridgeModule>> *)modules
withDispatchGroup:(dispatch_group_t)dispatchGroup
lazilyDiscovered:(BOOL)lazilyDiscovered

View File

@ -10,6 +10,7 @@
#include <memory>
#import <React/RCTBridgeDelegate.h>
#import <jschelpers/JavaScriptCore.h>
namespace facebook {
namespace react {
@ -32,4 +33,11 @@ class JSExecutorFactory;
*/
- (std::unique_ptr<facebook::react::JSExecutorFactory>)jsExecutorFactoryForBridge:(RCTBridge *)bridge;
@optional
/**
* Experimental: Perform installation of extra JS binding on the given JS context, as appropriate.
*/
- (void)installExtraJSBinding:(JSGlobalContextRef)jsContextRef;
@end