esoftplay 0.0.181 → 0.0.184

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 +12 -7
  2. package/package.json +1 -1
package/global.ts CHANGED
@@ -14,6 +14,7 @@ export interface useGlobalReturn<T> {
14
14
  reset: () => void,
15
15
  listen: (cb: (value: T) => void) => () => void
16
16
  sync: () => () => void,
17
+ useAutoSyncOnNetworkChanges: () => void,
17
18
  connect: (props: useGlobalConnect<T>) => any,
18
19
  useSelector: (selector: (state: T) => any) => any;
19
20
  }
@@ -111,11 +112,6 @@ export default function useGlobalState<T>(initValue: T, o?: useGlobalOption): us
111
112
  }), () => {
112
113
  o?.useAutoSync?.isSyncing?.(false)
113
114
  })
114
- esp.mod("lib/net_status").subscriber.useSubscribe(({ isInternetReachable, isOnline }) => {
115
- if (isInternetReachable && isOnline) {
116
- _sync()
117
- }
118
- })
119
115
  }
120
116
 
121
117
 
@@ -194,7 +190,7 @@ export default function useGlobalState<T>(initValue: T, o?: useGlobalOption): us
194
190
  }
195
191
 
196
192
  if (o?.useAutoSync && taskSync && Array.isArray(newValue)) {
197
- taskSync[0](newValue.filter((item: any) => item.synced != 1));
193
+ _sync()
198
194
  }
199
195
 
200
196
  listener.forEach((fun) => fun(newValue)); // Directly call the listener functions
@@ -229,6 +225,15 @@ export default function useGlobalState<T>(initValue: T, o?: useGlobalOption): us
229
225
  return l;
230
226
  }
231
227
 
228
+ function useAutoSyncOnNetworkChanges() {
229
+ esp.mod("lib/net_status").subscriber.useSubscribe(({ isInternetReachable, isOnline }) => {
230
+ if (isInternetReachable && isOnline) {
231
+ _sync()
232
+ }
233
+ })
234
+
235
+ }
236
+
232
237
  function get(param?: string, ...params: string[]): any {
233
238
  loadFromDisk()
234
239
  let out: any = value;
@@ -264,5 +269,5 @@ export default function useGlobalState<T>(initValue: T, o?: useGlobalOption): us
264
269
  return children ? R.cloneElement(children) : null
265
270
  }
266
271
 
267
- return { useState, get, set, useSelector, reset: del, connect: _connect, sync: _sync, listen: listen };
272
+ return { useState, get, set, useSelector, reset: del, connect: _connect, sync: _sync, listen: listen, useAutoSyncOnNetworkChanges };
268
273
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esoftplay",
3
- "version": "0.0.181",
3
+ "version": "0.0.184",
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",