@lowentry/react-redux 1.2.3 → 1.3.1
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 +35 -1
- package/package.json +1 -1
package/LeRed.js
CHANGED
|
@@ -679,7 +679,7 @@ export const LeRed = (() =>
|
|
|
679
679
|
|
|
680
680
|
LeRed.useConfigureStore = (storeData) =>
|
|
681
681
|
{
|
|
682
|
-
return
|
|
682
|
+
return LeRed.useMemo(() => LeRed.configureStore(storeData), [storeData]);
|
|
683
683
|
};
|
|
684
684
|
|
|
685
685
|
LeRed.useSelector = (selector, equalsComparator) =>
|
|
@@ -951,6 +951,40 @@ export const LeRed = (() =>
|
|
|
951
951
|
};
|
|
952
952
|
};
|
|
953
953
|
|
|
954
|
+
LeRed.useTriggerable = (event) =>
|
|
955
|
+
{
|
|
956
|
+
const [[value, uniqueId], setValue] = LeRed.useState([null, LeUtils.uniqueId()]);
|
|
957
|
+
|
|
958
|
+
LeRed.useEffect(() =>
|
|
959
|
+
{
|
|
960
|
+
if(typeof window === 'undefined')
|
|
961
|
+
{
|
|
962
|
+
return;
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
const callback = (e) =>
|
|
966
|
+
{
|
|
967
|
+
setValue([e?.detail, LeUtils.uniqueId()]);
|
|
968
|
+
};
|
|
969
|
+
|
|
970
|
+
const eventName = 'lowentrytriggerable_' + event;
|
|
971
|
+
window.addEventListener(eventName, callback);
|
|
972
|
+
return () => window.removeEventListener(eventName, callback);
|
|
973
|
+
}, []);
|
|
974
|
+
|
|
975
|
+
return value;
|
|
976
|
+
};
|
|
977
|
+
|
|
978
|
+
LeRed.trigger = (event, value) =>
|
|
979
|
+
{
|
|
980
|
+
if(typeof window === 'undefined')
|
|
981
|
+
{
|
|
982
|
+
return;
|
|
983
|
+
}
|
|
984
|
+
const eventName = 'lowentrytriggerable_' + event;
|
|
985
|
+
window.dispatchEvent(new CustomEvent(eventName, {detail:value}));
|
|
986
|
+
};
|
|
987
|
+
|
|
954
988
|
|
|
955
989
|
LeRed.Root = LeRed.memo(({store, children}) =>
|
|
956
990
|
{
|