-
Notifications
You must be signed in to change notification settings - Fork 27
/
RNUserDefaultsIOS.js
47 lines (41 loc) · 1.35 KB
/
RNUserDefaultsIOS.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
'use strict';
var { NativeModules } = require('react-native');
var Promise = require('bluebird'); // jshint ignore:line
var UserDefaults = NativeModules.RNUserDefaultsIOS;
var _setObjectForKey = Promise.promisify(UserDefaults.setObjectForKey);
var _setBoolForKey = Promise.promisify(UserDefaults.setBoolForKey);
var _arrayForKey = Promise.promisify(UserDefaults.arrayForKey);
var _stringForKey = Promise.promisify(UserDefaults.stringForKey);
var _objectForKey = Promise.promisify(UserDefaults.objectForKey);
var _boolForKey = Promise.promisify(UserDefaults.boolForKey);
var _removeItemForKey = Promise.promisify(UserDefaults.removeObjectForKey);
var UserDefaults = {
setArrayForKey(array, key) {
return _setObjectForKey(array, key);
},
setStringForKey(string, key) {
return _setObjectForKey(string, key);
},
setObjectForKey(object, key) {
return _setObjectForKey(object, key);
},
setBoolForKey(bool, key) {
return _setBoolForKey(bool, key);
},
arrayForKey(key) {
return _arrayForKey(key);
},
stringForKey(key) {
return _stringForKey(key);
},
objectForKey(key) {
return _objectForKey(key);
},
boolForKey(key) {
return _boolForKey(key);
},
removeItemForKey(key) {
return _removeItemForKey(key);
}
};
module.exports = UserDefaults;