esoftplay 0.0.129-j → 0.0.129-k
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/package.json +1 -1
- package/subscribe.ts +9 -4
package/package.json
CHANGED
package/subscribe.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// useLibs
|
|
2
2
|
|
|
3
3
|
import React from 'react';
|
|
4
|
+
import { InteractionManager } from 'react-native';
|
|
4
5
|
|
|
5
6
|
export interface useGlobalSubscriberReturn {
|
|
6
7
|
getValue: () => any,
|
|
@@ -24,7 +25,7 @@ export default function useGlobalSubscriber(defaultValue?: any): useGlobalSubscr
|
|
|
24
25
|
const trigger = (newValue?: any) => {
|
|
25
26
|
notify(newValue);
|
|
26
27
|
}
|
|
27
|
-
|
|
28
|
+
|
|
28
29
|
function useSubscribe(func: Function) {
|
|
29
30
|
React.useLayoutEffect(() => {
|
|
30
31
|
subscribers.add(func)
|
|
@@ -33,13 +34,17 @@ export default function useGlobalSubscriber(defaultValue?: any): useGlobalSubscr
|
|
|
33
34
|
if (subscribers.size == 0) reset()
|
|
34
35
|
}
|
|
35
36
|
}, [])
|
|
36
|
-
|
|
37
|
+
|
|
37
38
|
return trigger;
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
+
|
|
40
41
|
function notify(newValue?: any) {
|
|
41
42
|
value = newValue;
|
|
42
|
-
subscribers.forEach((fun: Function) =>
|
|
43
|
+
subscribers.forEach((fun: Function) => {
|
|
44
|
+
InteractionManager.runAfterInteractions(() => {
|
|
45
|
+
fun?.(newValue)
|
|
46
|
+
})
|
|
47
|
+
});
|
|
43
48
|
}
|
|
44
49
|
|
|
45
50
|
return {
|