Skip to content

Commit 4c6c3ca

Browse files
committed
Merge pull request #5 from yale/master
Add a getAll method to get entire environment.plist
2 parents 62d4ffa + bb36731 commit 4c6c3ca

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

RNEnvironmentManagerIOS/RNEnvironmentManagerIOS.m

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,22 @@ @implementation RNEnvironmentManagerIOS
1111
if ([env objectForKey:name]) {
1212
callback(@[[NSNull null], env[name]]);
1313
} else {
14-
callback(@[[NSNull null], [NSNull null]]);
14+
callback(@[[NSNull null], [NSNull null]]);
1515
}
1616
}
1717
@catch (NSException *exception) {
1818
callback(@[exception.reason, [NSNull null]]);
1919
}
2020
}
2121

22-
@end
22+
RCT_EXPORT_METHOD(getAll:(RCTResponseSenderBlock)callback) {
23+
@try {
24+
NSDictionary *env = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"environment" ofType:@"plist"]];
25+
callback(@[[NSNull null], env]);
26+
}
27+
@catch (NSException *exception) {
28+
callback(@[exception.reason, [NSNull null]]);
29+
}
30+
}
31+
32+
@end

index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,17 @@ module.exports = {
1212
}
1313
});
1414
});
15+
},
16+
17+
getAll() {
18+
return new Promise((resolve, reject) => {
19+
RNEnvironmentManagerIOS.getAll((err, res) => {
20+
if (err) {
21+
reject(err);
22+
} else {
23+
resolve(res);
24+
}
25+
});
26+
});
1527
}
1628
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-native-env",
3-
"version": "0.0.4",
3+
"version": "0.0.5",
44
"description": "Environment manager for react native",
55
"main": "index.js",
66
"author": "@joeferraro",

0 commit comments

Comments
 (0)