@lowentry/react-redux 1.2.4 → 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 +34 -0
- package/package.json +1 -1
package/LeRed.js
CHANGED
|
@@ -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
|
{
|