-
Notifications
You must be signed in to change notification settings - Fork 4
/
DataStore.js
47 lines (39 loc) · 899 Bytes
/
DataStore.js
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
43
44
45
46
47
import Storage from 'react-native-storage';
import { AsyncStorage } from 'react-native';
let _willAsked;
const storage = new Storage({
size: 1000,
storageBackend: AsyncStorage,
defaultExpires: null,
// cache data in the memory. default is true.
enableCache: true,
sync: {}
});
export default class DataStore {
static DATA_STORE_RATE_KEY = 'rated';
static async initRate() {
await storage.load({
key: this.DATA_STORE_RATE_KEY,
}).then((res) => {
// found data goes to then()
_willAsked = res;
return res;
}).catch((err) => {
console.log(err.message);
});
}
static async getRated() {
return await _willAsked;
}
static setRated() {
_willAsked = false;
this.persist_r();
}
static persist_r() {
storage.save({
key: this.DATA_STORE_RATE_KEY,
data: _willAsked,
expires: null,
});
}
}