@prometheus-ags/prometheus-entity-management 1.2.0 → 1.2.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/dist/index.js +8 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1174,10 +1174,11 @@ function useEntity(opts) {
|
|
|
1174
1174
|
fetchRef.current = opts.fetch;
|
|
1175
1175
|
const normalizeRef = useRef(opts.normalize);
|
|
1176
1176
|
normalizeRef.current = opts.normalize;
|
|
1177
|
-
const
|
|
1177
|
+
const dataSelector = useCallback((state) => {
|
|
1178
1178
|
if (!id) return null;
|
|
1179
1179
|
return state.readEntitySnapshot(type, id);
|
|
1180
|
-
})
|
|
1180
|
+
}, [id, type]);
|
|
1181
|
+
const data = useStore(useGraphStore, useShallow(dataSelector));
|
|
1181
1182
|
const entityState = useStore(useGraphStore, useCallback(
|
|
1182
1183
|
(state) => state.entityStates[`${type}:${id}`] ?? EMPTY_ENTITY_STATE,
|
|
1183
1184
|
[type, id]
|
|
@@ -1210,13 +1211,11 @@ function useEntityList(opts) {
|
|
|
1210
1211
|
const normalizeRef = useRef(opts.normalize);
|
|
1211
1212
|
normalizeRef.current = opts.normalize;
|
|
1212
1213
|
const listState = useStore(useGraphStore, useCallback((state) => state.lists[key] ?? EMPTY_LIST_STATE, [key]));
|
|
1213
|
-
const
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
})
|
|
1219
|
-
);
|
|
1214
|
+
const itemsSelector = useCallback((state) => {
|
|
1215
|
+
const ids = state.lists[key]?.ids ?? EMPTY_IDS;
|
|
1216
|
+
return ids.map((id) => state.readEntitySnapshot(type, id)).filter((x) => x !== null);
|
|
1217
|
+
}, [key, type]);
|
|
1218
|
+
const items = useStore(useGraphStore, useShallow(itemsSelector));
|
|
1220
1219
|
const doFetch = useCallback((params = {}) => {
|
|
1221
1220
|
if (!enabled) return;
|
|
1222
1221
|
fetchList({ type, queryKey, mode, fetch: fetchRef.current, normalize: normalizeRef.current }, params, getEngineOptions(), false);
|