@calimero-network/mero-react 4.5.0 → 4.6.0
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/dist/index.cjs +6 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -4
- package/dist/index.d.ts +12 -4
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1470,13 +1470,15 @@ function useExecute(contextId, executorId) {
|
|
|
1470
1470
|
);
|
|
1471
1471
|
return { execute, loading, error };
|
|
1472
1472
|
}
|
|
1473
|
-
function useSubscription(
|
|
1473
|
+
function useSubscription(input, callback) {
|
|
1474
1474
|
const { mero } = useMero();
|
|
1475
1475
|
const callbackRef = react.useRef(callback);
|
|
1476
1476
|
callbackRef.current = callback;
|
|
1477
|
+
const { contextIds = [], groupIds = [] } = Array.isArray(input) ? { contextIds: input, groupIds: [] } : input;
|
|
1477
1478
|
const contextIdsKey = JSON.stringify(contextIds);
|
|
1479
|
+
const groupIdsKey = JSON.stringify(groupIds);
|
|
1478
1480
|
react.useEffect(() => {
|
|
1479
|
-
if (!mero || contextIds.length === 0) return;
|
|
1481
|
+
if (!mero || contextIds.length === 0 && groupIds.length === 0) return;
|
|
1480
1482
|
const sse = mero.events;
|
|
1481
1483
|
const handler = (event) => {
|
|
1482
1484
|
callbackRef.current(event);
|
|
@@ -1484,12 +1486,12 @@ function useSubscription(contextIds, callback) {
|
|
|
1484
1486
|
sse.on("event", handler);
|
|
1485
1487
|
sse.connect().catch(() => {
|
|
1486
1488
|
});
|
|
1487
|
-
sse.subscribe(contextIds).catch(() => {
|
|
1489
|
+
sse.subscribe({ contextIds, groupIds }).catch(() => {
|
|
1488
1490
|
});
|
|
1489
1491
|
return () => {
|
|
1490
1492
|
sse.off("event", handler);
|
|
1491
1493
|
};
|
|
1492
|
-
}, [mero, contextIdsKey]);
|
|
1494
|
+
}, [mero, contextIdsKey, groupIdsKey]);
|
|
1493
1495
|
}
|
|
1494
1496
|
function useContexts(applicationId) {
|
|
1495
1497
|
const { mero } = useMero();
|