esoftplay 0.0.140-a → 0.0.140-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.
- package/bin/cli.js +1 -0
- package/global.ts +3 -2
- package/package.json +1 -1
- package/subscribe.ts +2 -6
package/bin/cli.js
CHANGED
package/global.ts
CHANGED
|
@@ -31,7 +31,8 @@ export interface useGlobalOption {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export interface useGlobalConnect<T> {
|
|
34
|
-
|
|
34
|
+
selector?: (props: T) => any,
|
|
35
|
+
render: (props: any) => any,
|
|
35
36
|
}
|
|
36
37
|
export let userDataReset: Function[] = []
|
|
37
38
|
let timeoutFinish: NodeJS.Timeout
|
|
@@ -225,7 +226,7 @@ export default function useGlobalState<T>(initValue: T, o?: useGlobalOption): us
|
|
|
225
226
|
};
|
|
226
227
|
|
|
227
228
|
function _connect(props: useGlobalConnect<T>): any {
|
|
228
|
-
const
|
|
229
|
+
const state = props.selector ? useSelector(props.selector) : useState()[0]
|
|
229
230
|
const children = props.render(state)
|
|
230
231
|
return children ? R.cloneElement(children) : null
|
|
231
232
|
}
|
package/package.json
CHANGED
package/subscribe.ts
CHANGED
|
@@ -22,10 +22,6 @@ export default function useGlobalSubscriber(defaultValue?: any): useGlobalSubscr
|
|
|
22
22
|
value = defaultValue;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
const trigger = (newValue?: any) => {
|
|
26
|
-
notify(newValue);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
25
|
function useSubscribe(func: Function) {
|
|
30
26
|
React.useLayoutEffect(() => {
|
|
31
27
|
subscribers.add(func)
|
|
@@ -35,7 +31,7 @@ export default function useGlobalSubscriber(defaultValue?: any): useGlobalSubscr
|
|
|
35
31
|
}
|
|
36
32
|
}, [])
|
|
37
33
|
|
|
38
|
-
return
|
|
34
|
+
return notify;
|
|
39
35
|
}
|
|
40
36
|
|
|
41
37
|
function notify(newValue?: any) {
|
|
@@ -51,6 +47,6 @@ export default function useGlobalSubscriber(defaultValue?: any): useGlobalSubscr
|
|
|
51
47
|
getValue,
|
|
52
48
|
useSubscribe,
|
|
53
49
|
reset,
|
|
54
|
-
trigger
|
|
50
|
+
trigger: notify
|
|
55
51
|
};
|
|
56
52
|
}
|