@oimdb/react 1.0.3 → 1.0.5

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 CHANGED
@@ -38,7 +38,9 @@ var import_react = require("react");
38
38
  var import_react2 = require("react");
39
39
  var EMPTY_ARRAY = [];
40
40
  var useSelectPksByIndexKeys = (reactiveIndex, keys) => {
41
- const snapshotValueRef = (0, import_react.useRef)(null);
41
+ const snapshotValueRef = (0, import_react.useRef)(
42
+ keys.map((key) => Array.from(reactiveIndex.getPksByKey(key))).flat()
43
+ );
42
44
  const subscribe = (0, import_react.useMemo)(() => {
43
45
  return (onStoreChange) => reactiveIndex.updateEventEmitter.subscribeOnKeys(keys, () => {
44
46
  snapshotValueRef.current = keys.map((key) => Array.from(reactiveIndex.getPksByKey(key))).flat();
@@ -54,7 +56,9 @@ var useSelectPksByIndexKeys = (reactiveIndex, keys) => {
54
56
  return snapshot;
55
57
  };
56
58
  var useSelectPksByIndexKey = (reactiveIndex, key) => {
57
- const snapshotValueRef = (0, import_react.useRef)(null);
59
+ const snapshotValueRef = (0, import_react.useRef)(
60
+ Array.from(reactiveIndex.getPksByKey(key))
61
+ );
58
62
  const subscribe = (0, import_react.useMemo)(() => {
59
63
  return (onStoreChange) => reactiveIndex.updateEventEmitter.subscribeOnKey(key, () => {
60
64
  snapshotValueRef.current = Array.from(
@@ -72,7 +76,9 @@ var useSelectPksByIndexKey = (reactiveIndex, key) => {
72
76
  return snapshot;
73
77
  };
74
78
  var selectEntityByPk = (reactiveCollection, pk) => {
75
- const snapshotValueRef = (0, import_react.useRef)(void 0);
79
+ const snapshotValueRef = (0, import_react.useRef)(
80
+ reactiveCollection.getOneByPk(pk)
81
+ );
76
82
  const subscribe = (0, import_react.useMemo)(() => {
77
83
  return (onStoreChange) => reactiveCollection.updateEventEmitter.subscribeOnKey(pk, () => {
78
84
  snapshotValueRef.current = reactiveCollection.getOneByPk(pk);
@@ -84,7 +90,9 @@ var selectEntityByPk = (reactiveCollection, pk) => {
84
90
  return snapshot;
85
91
  };
86
92
  var useSelectEntitiesByPks = (reactiveCollection, pks) => {
87
- const snapshotValueRef = (0, import_react.useRef)(null);
93
+ const snapshotValueRef = (0, import_react.useRef)(
94
+ pks.map((pk) => reactiveCollection.getOneByPk(pk))
95
+ );
88
96
  const subscribe = (0, import_react.useMemo)(() => {
89
97
  return (onStoreChange) => reactiveCollection.updateEventEmitter.subscribeOnKeys(pks, () => {
90
98
  snapshotValueRef.current = pks.map(
package/dist/index.js CHANGED
@@ -3,7 +3,9 @@ import { useMemo, useRef } from "react";
3
3
  import { useSyncExternalStore } from "react";
4
4
  var EMPTY_ARRAY = [];
5
5
  var useSelectPksByIndexKeys = (reactiveIndex, keys) => {
6
- const snapshotValueRef = useRef(null);
6
+ const snapshotValueRef = useRef(
7
+ keys.map((key) => Array.from(reactiveIndex.getPksByKey(key))).flat()
8
+ );
7
9
  const subscribe = useMemo(() => {
8
10
  return (onStoreChange) => reactiveIndex.updateEventEmitter.subscribeOnKeys(keys, () => {
9
11
  snapshotValueRef.current = keys.map((key) => Array.from(reactiveIndex.getPksByKey(key))).flat();
@@ -19,7 +21,9 @@ var useSelectPksByIndexKeys = (reactiveIndex, keys) => {
19
21
  return snapshot;
20
22
  };
21
23
  var useSelectPksByIndexKey = (reactiveIndex, key) => {
22
- const snapshotValueRef = useRef(null);
24
+ const snapshotValueRef = useRef(
25
+ Array.from(reactiveIndex.getPksByKey(key))
26
+ );
23
27
  const subscribe = useMemo(() => {
24
28
  return (onStoreChange) => reactiveIndex.updateEventEmitter.subscribeOnKey(key, () => {
25
29
  snapshotValueRef.current = Array.from(
@@ -37,7 +41,9 @@ var useSelectPksByIndexKey = (reactiveIndex, key) => {
37
41
  return snapshot;
38
42
  };
39
43
  var selectEntityByPk = (reactiveCollection, pk) => {
40
- const snapshotValueRef = useRef(void 0);
44
+ const snapshotValueRef = useRef(
45
+ reactiveCollection.getOneByPk(pk)
46
+ );
41
47
  const subscribe = useMemo(() => {
42
48
  return (onStoreChange) => reactiveCollection.updateEventEmitter.subscribeOnKey(pk, () => {
43
49
  snapshotValueRef.current = reactiveCollection.getOneByPk(pk);
@@ -49,7 +55,9 @@ var selectEntityByPk = (reactiveCollection, pk) => {
49
55
  return snapshot;
50
56
  };
51
57
  var useSelectEntitiesByPks = (reactiveCollection, pks) => {
52
- const snapshotValueRef = useRef(null);
58
+ const snapshotValueRef = useRef(
59
+ pks.map((pk) => reactiveCollection.getOneByPk(pk))
60
+ );
53
61
  const subscribe = useMemo(() => {
54
62
  return (onStoreChange) => reactiveCollection.updateEventEmitter.subscribeOnKeys(pks, () => {
55
63
  snapshotValueRef.current = pks.map(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oimdb/react",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "React integration for OIMDB - Hooks for selection and subscription with external storage",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",