You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
754 B
29 lines
754 B
import { Card } from "../models/Card";
|
|
import AsyncStorage from "@react-native-async-storage/async-storage";
|
|
|
|
|
|
export default class StorageHeart {
|
|
|
|
static async getItem(key: string): Promise<any> {
|
|
try {
|
|
const value = await AsyncStorage.getItem(key);
|
|
console.log("load")
|
|
if (value !== null) {
|
|
return JSON.parse(value);
|
|
}
|
|
} catch (e) {
|
|
console.error(`AsyncStorage getItem error: ${e}`);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
static async setItem(key: string, value: any): Promise<void> {
|
|
try {
|
|
await AsyncStorage.setItem(key, JSON.stringify(value));
|
|
console.log("save")
|
|
} catch (e) {
|
|
console.error(`AsyncStorage setItem error: ${e}`);
|
|
}
|
|
}
|
|
}
|