esoftplay 0.0.176 → 0.0.177

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.
@@ -4,6 +4,7 @@ import NetInfo from '@react-native-community/netinfo';
4
4
  import { LibComponent } from 'esoftplay/cache/lib/component/import';
5
5
  import esp from 'esoftplay/esp';
6
6
  import useGlobalState, { useGlobalReturn } from 'esoftplay/global';
7
+ import useGlobalSubscriber from 'esoftplay/subscribe';
7
8
  import { Animated, Text } from "react-native";
8
9
 
9
10
  export interface LibNet_statusProps {
@@ -13,7 +14,17 @@ export interface LibNet_statusState {
13
14
  zeroHeight: any
14
15
  }
15
16
 
16
- const state = useGlobalState({
17
+ export interface status {
18
+ isOnline: boolean,
19
+ isInternetReachable: boolean
20
+ }
21
+
22
+ const state = useGlobalState<status>({
23
+ isOnline: true,
24
+ isInternetReachable: true
25
+ })
26
+
27
+ export const subscriber = useGlobalSubscriber<status>({
17
28
  isOnline: true,
18
29
  isInternetReachable: true
19
30
  })
@@ -27,10 +38,10 @@ class net_status extends LibComponent<LibNet_statusProps, LibNet_statusState> {
27
38
 
28
39
  /** Klik [disini](https://github.com/dev-esoftplay/mobile-docs/blob/main/modules/lib/net_status.md#setOnline) untuk melihat dokumentasi*/
29
40
  static setOnline(isOnline: boolean, isInternetReachable: boolean): void {
41
+ subscriber.trigger({ isOnline, isInternetReachable })
30
42
  state.set({ isOnline: isOnline, isInternetReachable: isInternetReachable })
31
43
  }
32
44
 
33
- timeout
34
45
  unsubscribe: any
35
46
  constructor(props: LibNet_statusProps) {
36
47
  super(props)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esoftplay",
3
- "version": "0.0.176",
3
+ "version": "0.0.177",
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",
package/subscribe.ts CHANGED
@@ -3,14 +3,14 @@
3
3
  import React from 'react';
4
4
  import { InteractionManager } from 'react-native';
5
5
 
6
- export interface useGlobalSubscriberReturn {
6
+ export interface useGlobalSubscriberReturn<T> {
7
7
  getValue: () => any,
8
8
  reset: () => void,
9
- useSubscribe: Function,
10
- trigger: (newValue?: any) => void
9
+ useSubscribe: (func: (value: T) => void) => (newValue?: any) => void,
10
+ trigger: (newValue?: T) => void
11
11
  }
12
12
  /** Klik [disini](https://github.com/dev-esoftplay/mobile-docs/blob/subscribe.md) untuk melihat dokumentasi*/
13
- export default function useGlobalSubscriber(defaultValue?: any): useGlobalSubscriberReturn {
13
+ export default function useGlobalSubscriber<T>(defaultValue?: any): useGlobalSubscriberReturn<T> {
14
14
  const subscribers = new Set<Function>();
15
15
  let value = defaultValue;
16
16
 
@@ -22,7 +22,7 @@ export default function useGlobalSubscriber(defaultValue?: any): useGlobalSubscr
22
22
  value = defaultValue;
23
23
  }
24
24
 
25
- function useSubscribe(func: Function) {
25
+ function useSubscribe(func: (value: T) => void) {
26
26
  React.useLayoutEffect(() => {
27
27
  subscribers.add(func)
28
28
  return () => {