esoftplay 0.0.136-q → 0.0.136-s
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 +4 -2
- package/modules/user/data.ts +3 -0
- package/package.json +1 -1
package/global.ts
CHANGED
|
@@ -33,7 +33,7 @@ export interface useGlobalOption {
|
|
|
33
33
|
export interface useGlobalConnect<T> {
|
|
34
34
|
render: (props: T) => any,
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
export let userDataReset: Function[] = []
|
|
37
37
|
let timeoutFinish: NodeJS.Timeout
|
|
38
38
|
export default function useGlobalState<T>(initValue: T, o?: useGlobalOption): useGlobalReturn<T> {
|
|
39
39
|
let STORAGE: any = undefined
|
|
@@ -121,9 +121,11 @@ export default function useGlobalState<T>(initValue: T, o?: useGlobalOption): us
|
|
|
121
121
|
/* register to userData to automatically reset state and persist */
|
|
122
122
|
if (o?.isUserData) {
|
|
123
123
|
if (o?.persistKey) {
|
|
124
|
+
userDataReset.push(del)
|
|
124
125
|
const UserData = esp?.mod?.("user/data")
|
|
125
|
-
if (UserData)
|
|
126
|
+
if (UserData) {
|
|
126
127
|
UserData?.register?.(o?.persistKey)
|
|
128
|
+
}
|
|
127
129
|
}
|
|
128
130
|
}
|
|
129
131
|
|
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 { userDataReset } from 'esoftplay/global';
|
|
4
5
|
import FastStorage from 'esoftplay/mmkv';
|
|
5
6
|
import Storage from 'esoftplay/storage';
|
|
6
7
|
|
|
@@ -27,10 +28,12 @@ export default {
|
|
|
27
28
|
deleteAll(): void {
|
|
28
29
|
AsyncStorage.getItem("user_data_dependent").then((x) => {
|
|
29
30
|
if (x) {
|
|
31
|
+
userDataReset.forEach((f) => f())
|
|
30
32
|
const arx = JSON.parse(x)
|
|
31
33
|
AsyncStorage.multiRemove(arx)
|
|
32
34
|
arx.forEach((ix) => { FastStorage.removeItem(ix) })
|
|
33
35
|
arx.forEach((ix) => { Storage.removeItem(ix) })
|
|
36
|
+
AsyncStorage.removeItem("user_data_dependent")
|
|
34
37
|
}
|
|
35
38
|
})
|
|
36
39
|
}
|