Conforms to RCTBridgeModule
RCTInvalidating
Declared in RCTJavaScriptExecutor.h

Overview

Abstracts away a JavaScript execution context - we may be running code in a web view (for debugging purposes), or may be running code in a JSContext.

Tasks

Instance Methods

executeApplicationScript:sourceURL:onComplete:

- (void)executeApplicationScript:(NSString *)script sourceURL:(NSURL *)sourceURL onComplete:(RCTJavaScriptCompleteBlock)onComplete
Discussion

Runs an application script, and notifies of the script load being complete via onComplete.

Declared In

RCTJavaScriptExecutor.h

executeAsyncBlockOnJavaScriptQueue:

- (void)executeAsyncBlockOnJavaScriptQueue:(dispatch_block_t)block
Discussion

Special case for Timers + ContextExecutor - instead of the default if jsthread then call else dispatch call on jsthread ensure the call is made async on the jsthread

Declared In

RCTJavaScriptExecutor.h

executeBlockOnJavaScriptQueue:

- (void)executeBlockOnJavaScriptQueue:(dispatch_block_t)block
Discussion

Enqueue a block to run in the executors JS thread. Fallback to dispatch_async on the main queue if the executor doesn’t own a thread.

Declared In

RCTJavaScriptExecutor.h

executeJSCall:method:arguments:context:callback:

- (void)executeJSCall:(NSString *)name method:(NSString *)method arguments:(NSArray *)arguments context:(NSNumber *)executorID callback:(RCTJavaScriptCallback)onComplete
Discussion

Executes given method with arguments on JS thread and calls the given callback with JSValue and JSContext as a result of the JS module call.

Declared In

RCTJavaScriptExecutor.h

injectJSONText:asGlobalObjectNamed:callback:

- (void)injectJSONText:(NSString *)script asGlobalObjectNamed:(NSString *)objectName callback:(RCTJavaScriptCompleteBlock)onComplete

setUp

- (void)setUp
Discussion

Used to set up the executor after the bridge has been fully initialized. Do any expensive setup in this method instead of -init.

Declared In

RCTJavaScriptExecutor.h