-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAsyncStorage.js
More file actions
42 lines (33 loc) · 939 Bytes
/
AsyncStorage.js
File metadata and controls
42 lines (33 loc) · 939 Bytes
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
import { AsyncStorage as ReactNativeAsyncStorage } from 'react-native';
const AsyncStorage = {
getObjectWithIdentifier: (identifier) => {
const promise = new Promise(async (resolve, reject) => {
try {
const object = await ReactNativeAsyncStorage.getItem(identifier);
resolve(object);
} catch (error) {
reject();
}
});
return promise;
},
removeObjectWithIdentifier: async (identifier) => {
try {
await ReactNativeAsyncStorage.removeItem(identifier);
} catch (error) {
// Do nothing
}
},
setObjectWithIdentifier: async (object, identifier) => {
try {
await ReactNativeAsyncStorage.setItem(identifier, object);
} catch (error) {
// Do nothing
}
},
};
/* Export ==================================================================== */
module.exports = AsyncStorage;
module.exports.details = {
title: 'AsyncStorage',
};