esoftplay 0.0.136-j → 0.0.136-l
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/global.ts +12 -27
- package/mmkv.ts +1 -1
- package/modules/user/data.ts +2 -0
- package/package.json +1 -1
package/global.ts
CHANGED
|
@@ -17,31 +17,19 @@ export interface useGlobalAutoSync {
|
|
|
17
17
|
post: (item: any) => Object,
|
|
18
18
|
isSyncing?: (isSync: boolean) => void
|
|
19
19
|
}
|
|
20
|
-
interface useGlobalOptionA {
|
|
21
|
-
persistKey?: string;
|
|
22
|
-
inFastStorage?: boolean;
|
|
23
|
-
inFile?: never; // Ensures inFile is not present in useGlobalOptionA
|
|
24
|
-
listener?: (data: any) => void;
|
|
25
|
-
useAutoSync?: useGlobalAutoSync;
|
|
26
|
-
jsonBeautify?: boolean;
|
|
27
|
-
isUserData?: boolean;
|
|
28
|
-
loadOnInit?: boolean;
|
|
29
|
-
onFinish?: () => void;
|
|
30
|
-
}
|
|
31
20
|
|
|
32
|
-
interface
|
|
33
|
-
persistKey?: string
|
|
34
|
-
inFile?: boolean
|
|
35
|
-
inFastStorage?:
|
|
36
|
-
listener?: (data: any) => void
|
|
37
|
-
useAutoSync?: useGlobalAutoSync
|
|
38
|
-
jsonBeautify?: boolean
|
|
39
|
-
isUserData?: boolean
|
|
40
|
-
loadOnInit?: boolean
|
|
41
|
-
onFinish?: () => void
|
|
21
|
+
export interface useGlobalOption {
|
|
22
|
+
persistKey?: string,
|
|
23
|
+
inFile?: boolean,
|
|
24
|
+
inFastStorage?: boolean,
|
|
25
|
+
listener?: (data: any) => void,
|
|
26
|
+
useAutoSync?: useGlobalAutoSync,
|
|
27
|
+
jsonBeautify?: boolean,
|
|
28
|
+
isUserData?: boolean,
|
|
29
|
+
loadOnInit?: boolean,
|
|
30
|
+
onFinish?: () => void
|
|
42
31
|
}
|
|
43
32
|
|
|
44
|
-
export type useGlobalOption = useGlobalOptionA | useGlobalOptionB;
|
|
45
33
|
export interface useGlobalConnect<T> {
|
|
46
34
|
render: (props: T) => any,
|
|
47
35
|
}
|
|
@@ -57,10 +45,7 @@ export default function useGlobalState<T>(initValue: T, o?: useGlobalOption): us
|
|
|
57
45
|
let sync: any = undefined
|
|
58
46
|
|
|
59
47
|
if (o?.persistKey) {
|
|
60
|
-
|
|
61
|
-
STORAGE = require('esoftplay/mmkv').default
|
|
62
|
-
} else
|
|
63
|
-
STORAGE = o?.inFile ? (require('esoftplay/storage').default) : (require('@react-native-async-storage/async-storage').default)
|
|
48
|
+
STORAGE = o?.inFastStorage ? require('esoftplay/mmkv').default : (o?.inFile ? (require('esoftplay/storage').default) : (require('@react-native-async-storage/async-storage').default))
|
|
64
49
|
loaded = 0
|
|
65
50
|
if (o?.loadOnInit)
|
|
66
51
|
loadFromDisk()
|
|
@@ -182,7 +167,7 @@ export default function useGlobalState<T>(initValue: T, o?: useGlobalOption): us
|
|
|
182
167
|
set(initValue)
|
|
183
168
|
}
|
|
184
169
|
|
|
185
|
-
|
|
170
|
+
function useSelector(se: (state: T) => any): void {
|
|
186
171
|
loadFromDisk()
|
|
187
172
|
|
|
188
173
|
let [l, s] = R.useState<any>(se(value));
|
package/mmkv.ts
CHANGED
package/modules/user/data.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// noPage
|
|
2
2
|
// withObject
|
|
3
3
|
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
4
|
+
import FastStorage from 'esoftplay/mmkv';
|
|
4
5
|
import Storage from 'esoftplay/storage';
|
|
5
6
|
|
|
6
7
|
export default {
|
|
@@ -28,6 +29,7 @@ export default {
|
|
|
28
29
|
if (x) {
|
|
29
30
|
const arx = JSON.parse(x)
|
|
30
31
|
AsyncStorage.multiRemove(arx)
|
|
32
|
+
arx.forEach((ix) => { FastStorage.removeItem(ix) })
|
|
31
33
|
arx.forEach((ix) => { Storage.removeItem(ix) })
|
|
32
34
|
}
|
|
33
35
|
})
|