boxons/components/shared/business/AsyncStorage.ts

22 lines
543 B
TypeScript
Raw Permalink Normal View History

import AsyncStorage from '@react-native-async-storage/async-storage';
export const saveUserSettings = async (key: string, value: string) => {
try {
await AsyncStorage.setItem(key, value);
} catch (e) {
throw new Error('Failed to load the data from AsyncStorage');
}
};
export const loadUserSettings = async (key: string) => {
try {
const value = await AsyncStorage.getItem(key);
if (value !== null) {
return value;
}
} catch (e) {
throw new Error('Failed to load the data from AsyncStorage');
}
};