[ReactNative] Allow JS know its URL

This commit is contained in:
Alex Kotliarskyi 2015-04-20 14:04:53 -07:00
parent 0e8bc08d3f
commit 2434512847
2 changed files with 14 additions and 0 deletions

View File

@ -88,6 +88,11 @@ static const char *__rct_import_##module##_##method##__ = #module"."#method;
url:(NSURL *)url
onComplete:(RCTJavaScriptCompleteBlock)onComplete;
/**
* URL of the script that was loaded into the bridge.
*/
@property (nonatomic, copy, readonly) NSURL *bundleURL;
@property (nonatomic, strong) Class executorClass;
/**

View File

@ -10,12 +10,15 @@
#import "RCTSourceCode.h"
#import "RCTAssert.h"
#import "RCTBridge.h"
#import "RCTUtils.h"
@implementation RCTSourceCode
RCT_EXPORT_MODULE()
@synthesize bridge = _bridge;
RCT_EXPORT_METHOD(getScriptText:(RCTResponseSenderBlock)successCallback
failureCallback:(RCTResponseSenderBlock)failureCallback)
{
@ -26,4 +29,10 @@ RCT_EXPORT_METHOD(getScriptText:(RCTResponseSenderBlock)successCallback
}
}
- (NSDictionary *)constantsToExport
{
NSString *URL = [self.bridge.bundleURL absoluteString] ?: @"";
return @{@"scriptURL": URL};
}
@end