esoftplay 0.0.129-b → 0.0.129-c

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.
Files changed (2) hide show
  1. package/global.ts +30 -32
  2. package/package.json +1 -1
package/global.ts CHANGED
@@ -57,30 +57,32 @@ export default function useGlobalState<T>(initValue: T, o?: useGlobalOption): us
57
57
 
58
58
 
59
59
  function loadFromDisk() {
60
- loaded = 1
61
- let persistKey = o?.persistKey
62
- STORAGE.getItem(persistKey).then((p: any) => {
63
- if (p) {
64
- if (persistKey != '__globalReady')
65
- if (p != undefined && typeof p == 'string' && (p.startsWith("{") || p.startsWith("[")))
66
- try { set(JSON.parse(p)) } catch (error) { }
67
- else {
68
- if (p == "true" || p == "false") {
69
- try { /* @ts-ignore */ set(eval(p)) } catch (error) { }
70
- } else if (isNaN(p)) {
71
- try { /* @ts-ignore */ set(p) } catch (error) { }
72
- } else {
73
- try { /* @ts-ignore */ set(eval(p)) } catch (error) { }
60
+ if (loaded == 0) {
61
+ loaded = 1
62
+ let persistKey = o?.persistKey
63
+ STORAGE.getItem(persistKey).then((p: any) => {
64
+ if (p) {
65
+ if (persistKey != '__globalReady')
66
+ if (p != undefined && typeof p == 'string' && (p.startsWith("{") || p.startsWith("[")))
67
+ try { set(JSON.parse(p)) } catch (error) { }
68
+ else {
69
+ if (p == "true" || p == "false") {
70
+ try { /* @ts-ignore */ set(eval(p)) } catch (error) { }
71
+ } else if (isNaN(p)) {
72
+ try { /* @ts-ignore */ set(p) } catch (error) { }
73
+ } else {
74
+ try { /* @ts-ignore */ set(eval(p)) } catch (error) { }
75
+ }
74
76
  }
75
- }
76
- }
77
- if (o?.onFinish) {
78
- clearTimeout(timeoutFinish)
79
- timeoutFinish = setTimeout(() => {
80
- o.onFinish?.()
81
- }, 50);
82
- }
83
- })
77
+ }
78
+ if (o?.onFinish) {
79
+ clearTimeout(timeoutFinish)
80
+ timeoutFinish = setTimeout(() => {
81
+ o.onFinish?.()
82
+ }, 50);
83
+ }
84
+ })
85
+ }
84
86
  }
85
87
 
86
88
 
@@ -126,9 +128,8 @@ export default function useGlobalState<T>(initValue: T, o?: useGlobalOption): us
126
128
  }
127
129
 
128
130
  function useSelector(se: (state: T) => any): void {
129
- if (loaded == 0) {
130
- loadFromDisk()
131
- }
131
+ loadFromDisk()
132
+
132
133
  let [l, s] = R.useState<any>(se(value));
133
134
 
134
135
  let sl = R.useCallback(
@@ -154,9 +155,7 @@ export default function useGlobalState<T>(initValue: T, o?: useGlobalOption): us
154
155
  }
155
156
 
156
157
  function get(param?: string, ...params: string[]): any {
157
- if (loaded == 0) {
158
- loadFromDisk()
159
- }
158
+ loadFromDisk()
160
159
  let out: any = value;
161
160
  if (param) {
162
161
  const _params = [param, ...params]
@@ -171,9 +170,8 @@ export default function useGlobalState<T>(initValue: T, o?: useGlobalOption): us
171
170
 
172
171
 
173
172
  function useState(): [T, (newState: T) => void, () => T] {
174
- if (loaded == 0) {
175
- loadFromDisk()
176
- }
173
+ loadFromDisk()
174
+
177
175
  let [l, s] = R.useState<T>(value);
178
176
 
179
177
  let sl = R.useCallback((ns: T) => { s(ns) }, []);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esoftplay",
3
- "version": "0.0.129-b",
3
+ "version": "0.0.129-c",
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",