Skip to content

Instantly share code, notes, and snippets.

@lrlineroa
Last active February 24, 2020 15:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lrlineroa/dbf273d8ba4aa0c3306775ea48bbfb83 to your computer and use it in GitHub Desktop.
Save lrlineroa/dbf273d8ba4aa0c3306775ea48bbfb83 to your computer and use it in GitHub Desktop.
import AsyncStorage from '@react-native-community/async-storage';
class AppAsyncStorage {
static storeData = async (key, value) => {
try {
await AsyncStorage.setItem(key, value);
} catch (error) {
console.log("error storing" + error)
}
};
static retrieveData = async (key) => {
try {
let value = await AsyncStorage.getItem(key);
return value;
} catch (error) {
console.log("error at fetching")
}
}
static removeItem = async (key) => {
try {
await AsyncStorage.removeItem(key);
return true;
}
catch (exception) {
console.log(exception)
return false;
}
}
static clearData = async () => {
try {
await AsyncStorage.clear();
} catch (error) {
console.log(error)
}
}
}
export default AppAsyncStorage;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment