2015-01-30 01:10:49 +00:00
|
|
|
// Copyright 2004-present Facebook. All Rights Reserved.
|
|
|
|
|
|
|
|
#import "RCTExport.h"
|
|
|
|
#import "RCTInvalidating.h"
|
|
|
|
#import "RCTJavaScriptExecutor.h"
|
|
|
|
|
|
|
|
@protocol RCTNativeModule;
|
|
|
|
|
2015-02-04 00:02:36 +00:00
|
|
|
@class RCTEventDispatcher;
|
2015-02-04 00:12:07 +00:00
|
|
|
@class RCTRootView;
|
2015-01-30 01:10:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Utilities for constructing common response objects. When sending a
|
|
|
|
* systemError back to JS, it's important to describe whether or not it was a
|
|
|
|
* system error, or API usage error. System errors should never happen and are
|
|
|
|
* therefore logged using `RCTLogError()`. API usage errors are expected if the
|
|
|
|
* API is misused and will therefore not be logged using `RCTLogError()`. The JS
|
|
|
|
* application code is expected to handle them. Regardless of type, each error
|
|
|
|
* should be logged at most once.
|
|
|
|
*/
|
|
|
|
static inline NSDictionary *RCTSystemErrorObject(NSString *msg)
|
|
|
|
{
|
|
|
|
return @{@"systemError": msg ?: @""};
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline NSDictionary *RCTAPIErrorObject(NSString *msg)
|
|
|
|
{
|
|
|
|
return @{@"apiError": msg ?: @""};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Async batched bridge used to communicate with `RCTJavaScriptAppEngine`.
|
|
|
|
*/
|
|
|
|
@interface RCTBridge : NSObject <RCTInvalidating>
|
|
|
|
|
2015-02-04 00:15:20 +00:00
|
|
|
- (instancetype)initWithJavaScriptExecutor:(id<RCTJavaScriptExecutor>)javaScriptExecutor;
|
2015-01-30 01:10:49 +00:00
|
|
|
|
2015-02-04 00:15:20 +00:00
|
|
|
- (void)enqueueJSCall:(NSString *)moduleDotMethod args:(NSArray *)args;
|
2015-01-30 01:10:49 +00:00
|
|
|
- (void)enqueueApplicationScript:(NSString *)script url:(NSURL *)url onComplete:(RCTJavaScriptCompleteBlock)onComplete;
|
|
|
|
|
2015-02-04 00:02:36 +00:00
|
|
|
@property (nonatomic, readonly) RCTEventDispatcher *eventDispatcher;
|
2015-02-04 00:12:07 +00:00
|
|
|
@property (nonatomic, readonly) dispatch_queue_t shadowQueue;
|
2015-01-30 01:10:49 +00:00
|
|
|
|
|
|
|
// For use in implementing delegates, which may need to queue responses.
|
|
|
|
- (RCTResponseSenderBlock)createResponseSenderBlock:(NSInteger)callbackID;
|
|
|
|
|
2015-02-04 00:12:07 +00:00
|
|
|
- (void)registerRootView:(RCTRootView *)rootView;
|
|
|
|
|
2015-01-30 01:10:49 +00:00
|
|
|
/**
|
|
|
|
* Global logging function will print to both xcode and js debugger consoles.
|
|
|
|
*
|
|
|
|
* NOTE: Use via RCTLog* macros defined in RCTLog.h
|
|
|
|
* TODO (#5906496): should log function be exposed here, or could it be a module?
|
|
|
|
*/
|
|
|
|
+ (void)log:(NSArray *)objects level:(NSString *)level;
|
|
|
|
|
|
|
|
+ (BOOL)hasValidJSExecutor;
|
|
|
|
|
|
|
|
@end
|