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 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 useGlobalOptionB {
33
- persistKey?: string;
34
- inFile?: boolean;
35
- inFastStorage?: never; // Ensures inFastStorage is not present in useGlobalOptionB
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
- if (o?.inFastStorage == true) {
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
- async function useSelector(se: (state: T) => any): void {
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
@@ -9,7 +9,7 @@ const FastStorage = {
9
9
  setItem(key: string, value: string) {
10
10
  storage.set(key, value)
11
11
  },
12
- async removeItem(key: string) {
12
+ removeItem(key: string) {
13
13
  storage.delete(key)
14
14
  },
15
15
  clear(): void {
@@ -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
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esoftplay",
3
- "version": "0.0.136-j",
3
+ "version": "0.0.136-l",
4
4
  "description": "embedding data from esoftplay framework (web based) into mobile app",
5
5
  "main": "cache/index.js",
6
6
  "types": "../../index.d.ts",