Initial commit
This commit is contained in:
26
storage/index.js
Normal file
26
storage/index.js
Normal file
@@ -0,0 +1,26 @@
|
||||
// storage.js
|
||||
import AsyncStorage from '@react-native-async-storage/async-storage';
|
||||
|
||||
const Storage = {
|
||||
setItemAsync(key, value) {
|
||||
return AsyncStorage.setItem(key, JSON.stringify(value || {}));
|
||||
},
|
||||
|
||||
getItemAsync(key) {
|
||||
return new Promise(resolve=>{
|
||||
AsyncStorage.getItem(key).then(value=>{
|
||||
resolve(value ? JSON.parse(value) : null)
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
removeItemAsync(key) {
|
||||
return AsyncStorage.removeItem(key)
|
||||
},
|
||||
|
||||
clearAllAsync() {
|
||||
return AsyncStorage.clear();
|
||||
}
|
||||
};
|
||||
|
||||
export default Storage;
|
||||
Reference in New Issue
Block a user