Skip to content

Commit

Permalink
Change API for using custom JSC
Browse files Browse the repository at this point in the history
Reviewed By: javache

Differential Revision: D3392219

fbshipit-source-id: ae372dfe9ceab7f7c2da69c731515a05eb3b020a
  • Loading branch information
alexeylang authored and Facebook Github Bot 6 committed Jun 6, 2016
1 parent 44c9cf3 commit 42a5568
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
11 changes: 5 additions & 6 deletions React/Executors/RCTJSCExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,17 @@ RCT_EXTERN NSString *const RCTJavaScriptContextCreatedNotification;
@interface RCTJSCExecutor : NSObject <RCTJavaScriptExecutor>

/**
* Sets a type of JSC library (system or custom) that's used
* to initialize RCTJSCWrapper.
* Returns whether executor uses custom JSC library.
* This value is used to initialize RCTJSCWrapper.
* @default is NO.
*/
+ (void)setUseCustomJSCLibrary:(BOOL)useCustomLibrary;
@property (nonatomic, readonly, assign) BOOL useCustomJSCLibrary;

/**
* Gets a type of JSC library (system or custom) that's used
* Inits a new executor instance with given flag that's used
* to initialize RCTJSCWrapper.
* @default is NO.
*/
+ (BOOL)useCustomJSCLibrary;
- (instancetype)initWithUseCustomJSCLibrary:(BOOL)useCustomJSCLibrary;

/**
* Create a NSError from a JSError object.
Expand Down
17 changes: 6 additions & 11 deletions React/Executors/RCTJSCExecutor.mm
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ @implementation RCTJSCExecutor
RandomAccessBundleData _randomAccessBundle;

RCTJSCWrapper *_jscWrapper;
BOOL _useCustomJSCLibrary;
}

@synthesize valid = _valid;
Expand Down Expand Up @@ -262,21 +263,15 @@ + (void)runRunLoopThread
}
}

static BOOL useCustomJSCLibrary = NO;

+ (void)setUseCustomJSCLibrary:(BOOL)useCustomLibrary
{
useCustomJSCLibrary = useCustomLibrary;
}

+ (BOOL)useCustomJSCLibrary
- (instancetype)init
{
return useCustomJSCLibrary;
return [self initWithUseCustomJSCLibrary:NO];
}

- (instancetype)init
- (instancetype)initWithUseCustomJSCLibrary:(BOOL)useCustomJSCLibrary
{
if (self = [super init]) {
_useCustomJSCLibrary = useCustomJSCLibrary;
_valid = YES;

_javaScriptThread = [[NSThread alloc] initWithTarget:[self class]
Expand Down Expand Up @@ -333,7 +328,7 @@ - (void)setUp
return;
}

strongSelf->_jscWrapper = RCTJSCWrapperCreate(useCustomJSCLibrary);
strongSelf->_jscWrapper = RCTJSCWrapperCreate(strongSelf->_useCustomJSCLibrary);
}];


Expand Down

0 comments on commit 42a5568

Please sign in to comment.