Replaced CTLSettings with RCTBundleURLProvider internally

Reviewed By: javache

Differential Revision: D3398803

fbshipit-source-id: 1c5610a1e59f3fad4c57b0b280559f2ff2acf05a
This commit is contained in:
Nathan Azaria 2016-06-09 07:01:42 -07:00 committed by Facebook Github Bot 3
parent be09cccb1f
commit 5ef3b47ede
2 changed files with 24 additions and 1 deletions

View File

@ -18,6 +18,11 @@ extern NSString *const RCTBundleURLProviderUpdatedNotification;
*/ */
- (void)setDefaults; - (void)setDefaults;
/**
* Reset every settings to default.
*/
- (void)resetToDefaults;
/** /**
* Returns the jsBundleURL for a given bundle entrypoint and * Returns the jsBundleURL for a given bundle entrypoint and
* the fallback offline JS bundle if the packager is not running. * the fallback offline JS bundle if the packager is not running.
@ -25,6 +30,11 @@ extern NSString *const RCTBundleURLProviderUpdatedNotification;
- (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot - (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot
fallbackResource:(NSString *)resourceName; fallbackResource:(NSString *)resourceName;
/**
* Returns the URL of the packager server.
*/
- (NSURL *)packagerServerURL;
/** /**
* The IP address or hostname of the packager. * The IP address or hostname of the packager.
*/ */

View File

@ -47,6 +47,14 @@ static NSString *const kDefaultPort = @"8081";
[self settingsUpdated]; [self settingsUpdated];
} }
- (void)resetToDefaults
{
for (NSString *key in [[self defaults] allKeys]) {
[[NSUserDefaults standardUserDefaults] removeObjectForKey:key];
}
[self setDefaults];
}
- (BOOL)isPackagerRunning:(NSString *)host - (BOOL)isPackagerRunning:(NSString *)host
{ {
if (RCT_DEV) { if (RCT_DEV) {
@ -75,7 +83,6 @@ static NSString *serverRootWithHost(NSString *host)
return nil; return nil;
} }
- (NSString *)packagerServerRoot - (NSString *)packagerServerRoot
{ {
NSString *location = [self jsLocation]; NSString *location = [self jsLocation];
@ -91,6 +98,12 @@ static NSString *serverRootWithHost(NSString *host)
} }
} }
- (NSURL *)packagerServerURL
{
NSString *root = [self packagerServerRoot];
return root ? [NSURL URLWithString:root] : nil;
}
- (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot fallbackResource:(NSString *)resourceName - (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot fallbackResource:(NSString *)resourceName
{ {
resourceName = resourceName ?: @"main"; resourceName = resourceName ?: @"main";