@axa-fr/slimfaas-planet-saver 0.41.1-pr.1607 → 0.41.1-pr.1608
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/README.md +10 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -29,21 +29,22 @@ import { SlimFaasPlanetSaver } from '@axa-fr/slimfaas-planet-saver';
|
|
|
29
29
|
|
|
30
30
|
const PlanetSaver = ({ children, baseUrl, fetch, noActivityTimeout=60000, behavior={} }) => {
|
|
31
31
|
const [isFirstStart, setIsFirstStart] = useState(true);
|
|
32
|
-
const
|
|
32
|
+
const instanceRef = useRef(null);
|
|
33
33
|
|
|
34
34
|
useEffect(() => {
|
|
35
35
|
if (!baseUrl) return;
|
|
36
36
|
|
|
37
|
-
if (
|
|
37
|
+
if (instanceRef.current) return;
|
|
38
38
|
|
|
39
39
|
const instance = new SlimFaasPlanetSaver(baseUrl, {
|
|
40
40
|
interval: 2000,
|
|
41
41
|
fetch,
|
|
42
42
|
behavior,
|
|
43
43
|
updateCallback: (data) => {
|
|
44
|
+
const inst = instanceRef.current;
|
|
44
45
|
// Filter only the items that block the UI (WakeUp+BlockUI)
|
|
45
46
|
const blockingItems = data.filter(
|
|
46
|
-
(item) =>
|
|
47
|
+
(item) => inst?.getBehavior(item.Name) === 'WakeUp+BlockUI'
|
|
47
48
|
);
|
|
48
49
|
|
|
49
50
|
// If all blocking items are ready, set isFirstStart to false
|
|
@@ -66,15 +67,18 @@ const PlanetSaver = ({ children, baseUrl, fetch, noActivityTimeout=60000, behavi
|
|
|
66
67
|
noActivityTimeout
|
|
67
68
|
});
|
|
68
69
|
|
|
69
|
-
|
|
70
|
+
instanceRef.current = instance;
|
|
70
71
|
|
|
71
72
|
// Initialiser les effets de bord
|
|
72
73
|
instance.initialize();
|
|
73
74
|
instance.startPolling();
|
|
74
75
|
|
|
75
76
|
return () => {
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
try {
|
|
78
|
+
instance.cleanup();
|
|
79
|
+
} finally {
|
|
80
|
+
instanceRef.current = null;
|
|
81
|
+
}
|
|
78
82
|
};
|
|
79
83
|
}, [baseUrl]);
|
|
80
84
|
|