@lowentry/react-redux 1.3.1 → 1.4.2
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/LeRed.js +36 -9
- package/README.md +1 -1
- package/package.json +1 -1
package/LeRed.js
CHANGED
|
@@ -781,27 +781,54 @@ export const LeRed = (() =>
|
|
|
781
781
|
{
|
|
782
782
|
return LeRed.useEffect(() =>
|
|
783
783
|
{
|
|
784
|
-
|
|
784
|
+
const run = () =>
|
|
785
|
+
{
|
|
786
|
+
callable();
|
|
787
|
+
};
|
|
788
|
+
|
|
789
|
+
if(typeof window !== 'undefined')
|
|
790
|
+
{
|
|
791
|
+
window.addEventListener('beforeunload', run, {capture:true});
|
|
792
|
+
}
|
|
793
|
+
return () =>
|
|
794
|
+
{
|
|
795
|
+
if(typeof window !== 'undefined')
|
|
796
|
+
{
|
|
797
|
+
window.removeEventListener('beforeunload', run, {capture:true});
|
|
798
|
+
}
|
|
799
|
+
run();
|
|
800
|
+
};
|
|
801
|
+
}, [comparingValues, equalsComparator]);
|
|
802
|
+
};
|
|
803
|
+
|
|
804
|
+
LeRed.useEffectPageFocusLost = (callable, comparingValues, equalsComparator) =>
|
|
805
|
+
{
|
|
806
|
+
const events = ['pagehide', 'freeze', 'blur', 'visibilitychange'];
|
|
807
|
+
return LeRed.useEffect(() =>
|
|
808
|
+
{
|
|
809
|
+
if((typeof window === 'undefined'))
|
|
810
|
+
{
|
|
811
|
+
return;
|
|
812
|
+
}
|
|
785
813
|
|
|
786
814
|
const run = () =>
|
|
787
815
|
{
|
|
788
|
-
if(
|
|
816
|
+
if(typeof document === 'undefined')
|
|
789
817
|
{
|
|
790
818
|
return;
|
|
791
819
|
}
|
|
792
|
-
|
|
793
|
-
if(typeof window !== 'undefined')
|
|
820
|
+
if((document.visibilityState !== 'hidden') && document.hasFocus())
|
|
794
821
|
{
|
|
795
|
-
|
|
822
|
+
return;
|
|
796
823
|
}
|
|
797
824
|
callable();
|
|
798
825
|
};
|
|
799
826
|
|
|
800
|
-
|
|
827
|
+
events.forEach(type => window.addEventListener(type, run, {capture:true}));
|
|
828
|
+
return () =>
|
|
801
829
|
{
|
|
802
|
-
window.
|
|
803
|
-
}
|
|
804
|
-
return run;
|
|
830
|
+
events.forEach(type => window.removeEventListener(type, run, {capture:true}));
|
|
831
|
+
};
|
|
805
832
|
}, [comparingValues, equalsComparator]);
|
|
806
833
|
};
|
|
807
834
|
|
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ Simplifies the use of Redux in your React project.
|
|
|
5
5
|
|
|
6
6
|
## Description
|
|
7
7
|
|
|
8
|
-
This plugin
|
|
8
|
+
This plugin adds utility functions to make it easier to use React and Redux in your project.
|
|
9
9
|
|
|
10
10
|
For example, some of the things it does is:
|
|
11
11
|
|