@oimdb/react 1.0.6 → 1.0.8
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 +55 -84
- package/dist/index.js +55 -84
- package/package.json +2 -5
package/dist/index.cjs
CHANGED
|
@@ -41,31 +41,23 @@ var useSelectPksByIndexKeys = (reactiveIndex, keys) => {
|
|
|
41
41
|
const snapshotValueRef = (0, import_react.useRef)(
|
|
42
42
|
keys.map((key) => Array.from(reactiveIndex.getPksByKey(key))).flat()
|
|
43
43
|
);
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
const osc = (0, import_react.useRef)(() => {
|
|
45
|
+
});
|
|
46
|
+
const subscribe = (0, import_react.useRef)((onStoreChange) => {
|
|
47
|
+
osc.current = onStoreChange;
|
|
48
|
+
return () => {
|
|
49
|
+
osc.current = () => {
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
});
|
|
48
53
|
(0, import_react.useEffect)(() => {
|
|
49
|
-
const list = (
|
|
54
|
+
const list = () => {
|
|
50
55
|
snapshotValueRef.current = keys.map((key) => Array.from(reactiveIndex.getPksByKey(key))).flat();
|
|
51
|
-
|
|
52
|
-
return () => {
|
|
53
|
-
reactiveIndex.updateEventEmitter.unsubscribeFromKeys(
|
|
54
|
-
keys,
|
|
55
|
-
list
|
|
56
|
-
);
|
|
57
|
-
};
|
|
56
|
+
osc.current();
|
|
58
57
|
};
|
|
59
|
-
reactiveIndex.updateEventEmitter.subscribeOnKeys(
|
|
60
|
-
keys,
|
|
61
|
-
list
|
|
62
|
-
);
|
|
63
|
-
listener.current = list;
|
|
58
|
+
reactiveIndex.updateEventEmitter.subscribeOnKeys(keys, list);
|
|
64
59
|
return () => {
|
|
65
|
-
reactiveIndex.updateEventEmitter.unsubscribeFromKeys(
|
|
66
|
-
keys,
|
|
67
|
-
list
|
|
68
|
-
);
|
|
60
|
+
reactiveIndex.updateEventEmitter.unsubscribeFromKeys(keys, list);
|
|
69
61
|
};
|
|
70
62
|
}, [keys, reactiveIndex.updateEventEmitter, reactiveIndex]);
|
|
71
63
|
const getSnapshot = (0, import_react.useMemo)(() => {
|
|
@@ -74,7 +66,7 @@ var useSelectPksByIndexKeys = (reactiveIndex, keys) => {
|
|
|
74
66
|
};
|
|
75
67
|
}, []);
|
|
76
68
|
const snapshot = (0, import_react2.useSyncExternalStore)(
|
|
77
|
-
|
|
69
|
+
subscribe.current,
|
|
78
70
|
getSnapshot,
|
|
79
71
|
getSnapshot
|
|
80
72
|
);
|
|
@@ -84,33 +76,25 @@ var useSelectPksByIndexKey = (reactiveIndex, key) => {
|
|
|
84
76
|
const snapshotValueRef = (0, import_react.useRef)(
|
|
85
77
|
Array.from(reactiveIndex.getPksByKey(key))
|
|
86
78
|
);
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
79
|
+
const osc = (0, import_react.useRef)(() => {
|
|
80
|
+
});
|
|
81
|
+
const subscribe = (0, import_react.useRef)((onStoreChange) => {
|
|
82
|
+
osc.current = onStoreChange;
|
|
83
|
+
return () => {
|
|
84
|
+
osc.current = () => {
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
});
|
|
91
88
|
(0, import_react.useEffect)(() => {
|
|
92
|
-
const list = (
|
|
89
|
+
const list = () => {
|
|
93
90
|
snapshotValueRef.current = Array.from(
|
|
94
91
|
reactiveIndex.getPksByKey(key)
|
|
95
92
|
);
|
|
96
|
-
|
|
97
|
-
return () => {
|
|
98
|
-
reactiveIndex.updateEventEmitter.unsubscribeFromKey(
|
|
99
|
-
key,
|
|
100
|
-
list
|
|
101
|
-
);
|
|
102
|
-
};
|
|
93
|
+
osc.current();
|
|
103
94
|
};
|
|
104
|
-
reactiveIndex.updateEventEmitter.subscribeOnKey(
|
|
105
|
-
key,
|
|
106
|
-
list
|
|
107
|
-
);
|
|
108
|
-
listener.current = list;
|
|
95
|
+
reactiveIndex.updateEventEmitter.subscribeOnKey(key, list);
|
|
109
96
|
return () => {
|
|
110
|
-
reactiveIndex.updateEventEmitter.unsubscribeFromKey(
|
|
111
|
-
key,
|
|
112
|
-
list
|
|
113
|
-
);
|
|
97
|
+
reactiveIndex.updateEventEmitter.unsubscribeFromKey(key, list);
|
|
114
98
|
};
|
|
115
99
|
}, [key, reactiveIndex.updateEventEmitter, reactiveIndex]);
|
|
116
100
|
const getSnapshot = (0, import_react.useMemo)(() => {
|
|
@@ -119,7 +103,7 @@ var useSelectPksByIndexKey = (reactiveIndex, key) => {
|
|
|
119
103
|
};
|
|
120
104
|
}, []);
|
|
121
105
|
const snapshot = (0, import_react2.useSyncExternalStore)(
|
|
122
|
-
|
|
106
|
+
subscribe.current,
|
|
123
107
|
getSnapshot,
|
|
124
108
|
getSnapshot
|
|
125
109
|
);
|
|
@@ -129,36 +113,28 @@ var selectEntityByPk = (reactiveCollection, pk) => {
|
|
|
129
113
|
const snapshotValueRef = (0, import_react.useRef)(
|
|
130
114
|
reactiveCollection.getOneByPk(pk)
|
|
131
115
|
);
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
116
|
+
const osc = (0, import_react.useRef)(() => {
|
|
117
|
+
});
|
|
118
|
+
const subscribe = (0, import_react.useRef)((onStoreChange) => {
|
|
119
|
+
osc.current = onStoreChange;
|
|
120
|
+
return () => {
|
|
121
|
+
osc.current = () => {
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
});
|
|
136
125
|
(0, import_react.useEffect)(() => {
|
|
137
|
-
const list = (
|
|
126
|
+
const list = () => {
|
|
138
127
|
snapshotValueRef.current = reactiveCollection.getOneByPk(pk);
|
|
139
|
-
|
|
140
|
-
return () => {
|
|
141
|
-
reactiveCollection.updateEventEmitter.unsubscribeFromKey(
|
|
142
|
-
pk,
|
|
143
|
-
list
|
|
144
|
-
);
|
|
145
|
-
};
|
|
128
|
+
osc.current();
|
|
146
129
|
};
|
|
147
|
-
reactiveCollection.updateEventEmitter.subscribeOnKey(
|
|
148
|
-
pk,
|
|
149
|
-
list
|
|
150
|
-
);
|
|
151
|
-
listener.current = list;
|
|
130
|
+
reactiveCollection.updateEventEmitter.subscribeOnKey(pk, list);
|
|
152
131
|
return () => {
|
|
153
|
-
reactiveCollection.updateEventEmitter.unsubscribeFromKey(
|
|
154
|
-
pk,
|
|
155
|
-
list
|
|
156
|
-
);
|
|
132
|
+
reactiveCollection.updateEventEmitter.unsubscribeFromKey(pk, list);
|
|
157
133
|
};
|
|
158
134
|
}, [pk, reactiveCollection.updateEventEmitter, reactiveCollection]);
|
|
159
135
|
const getSnapshot = (0, import_react.useMemo)(() => () => snapshotValueRef.current, []);
|
|
160
136
|
const snapshot = (0, import_react2.useSyncExternalStore)(
|
|
161
|
-
|
|
137
|
+
subscribe.current,
|
|
162
138
|
getSnapshot,
|
|
163
139
|
getSnapshot
|
|
164
140
|
);
|
|
@@ -168,28 +144,23 @@ var useSelectEntitiesByPks = (reactiveCollection, pks) => {
|
|
|
168
144
|
const snapshotValueRef = (0, import_react.useRef)(
|
|
169
145
|
pks.map((pk) => reactiveCollection.getOneByPk(pk))
|
|
170
146
|
);
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
147
|
+
const osc = (0, import_react.useRef)(() => {
|
|
148
|
+
});
|
|
149
|
+
const subscribe = (0, import_react.useRef)((onStoreChange) => {
|
|
150
|
+
osc.current = onStoreChange;
|
|
151
|
+
return () => {
|
|
152
|
+
osc.current = () => {
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
});
|
|
175
156
|
(0, import_react.useEffect)(() => {
|
|
176
|
-
const list = (
|
|
157
|
+
const list = () => {
|
|
177
158
|
snapshotValueRef.current = pks.map(
|
|
178
159
|
(pk) => reactiveCollection.getOneByPk(pk)
|
|
179
160
|
);
|
|
180
|
-
|
|
181
|
-
return () => {
|
|
182
|
-
reactiveCollection.updateEventEmitter.unsubscribeFromKeys(
|
|
183
|
-
pks,
|
|
184
|
-
list
|
|
185
|
-
);
|
|
186
|
-
};
|
|
161
|
+
osc.current();
|
|
187
162
|
};
|
|
188
|
-
reactiveCollection.updateEventEmitter.subscribeOnKeys(
|
|
189
|
-
pks,
|
|
190
|
-
list
|
|
191
|
-
);
|
|
192
|
-
listener.current = list;
|
|
163
|
+
reactiveCollection.updateEventEmitter.subscribeOnKeys(pks, list);
|
|
193
164
|
return () => {
|
|
194
165
|
reactiveCollection.updateEventEmitter.unsubscribeFromKeys(
|
|
195
166
|
pks,
|
|
@@ -203,7 +174,7 @@ var useSelectEntitiesByPks = (reactiveCollection, pks) => {
|
|
|
203
174
|
};
|
|
204
175
|
}, []);
|
|
205
176
|
const snapshot = (0, import_react2.useSyncExternalStore)(
|
|
206
|
-
|
|
177
|
+
subscribe.current,
|
|
207
178
|
getSnapshot,
|
|
208
179
|
getSnapshot
|
|
209
180
|
);
|
package/dist/index.js
CHANGED
|
@@ -6,31 +6,23 @@ var useSelectPksByIndexKeys = (reactiveIndex, keys) => {
|
|
|
6
6
|
const snapshotValueRef = useRef(
|
|
7
7
|
keys.map((key) => Array.from(reactiveIndex.getPksByKey(key))).flat()
|
|
8
8
|
);
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const osc = useRef(() => {
|
|
10
|
+
});
|
|
11
|
+
const subscribe = useRef((onStoreChange) => {
|
|
12
|
+
osc.current = onStoreChange;
|
|
13
|
+
return () => {
|
|
14
|
+
osc.current = () => {
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
});
|
|
13
18
|
useEffect(() => {
|
|
14
|
-
const list = (
|
|
19
|
+
const list = () => {
|
|
15
20
|
snapshotValueRef.current = keys.map((key) => Array.from(reactiveIndex.getPksByKey(key))).flat();
|
|
16
|
-
|
|
17
|
-
return () => {
|
|
18
|
-
reactiveIndex.updateEventEmitter.unsubscribeFromKeys(
|
|
19
|
-
keys,
|
|
20
|
-
list
|
|
21
|
-
);
|
|
22
|
-
};
|
|
21
|
+
osc.current();
|
|
23
22
|
};
|
|
24
|
-
reactiveIndex.updateEventEmitter.subscribeOnKeys(
|
|
25
|
-
keys,
|
|
26
|
-
list
|
|
27
|
-
);
|
|
28
|
-
listener.current = list;
|
|
23
|
+
reactiveIndex.updateEventEmitter.subscribeOnKeys(keys, list);
|
|
29
24
|
return () => {
|
|
30
|
-
reactiveIndex.updateEventEmitter.unsubscribeFromKeys(
|
|
31
|
-
keys,
|
|
32
|
-
list
|
|
33
|
-
);
|
|
25
|
+
reactiveIndex.updateEventEmitter.unsubscribeFromKeys(keys, list);
|
|
34
26
|
};
|
|
35
27
|
}, [keys, reactiveIndex.updateEventEmitter, reactiveIndex]);
|
|
36
28
|
const getSnapshot = useMemo(() => {
|
|
@@ -39,7 +31,7 @@ var useSelectPksByIndexKeys = (reactiveIndex, keys) => {
|
|
|
39
31
|
};
|
|
40
32
|
}, []);
|
|
41
33
|
const snapshot = useSyncExternalStore(
|
|
42
|
-
|
|
34
|
+
subscribe.current,
|
|
43
35
|
getSnapshot,
|
|
44
36
|
getSnapshot
|
|
45
37
|
);
|
|
@@ -49,33 +41,25 @@ var useSelectPksByIndexKey = (reactiveIndex, key) => {
|
|
|
49
41
|
const snapshotValueRef = useRef(
|
|
50
42
|
Array.from(reactiveIndex.getPksByKey(key))
|
|
51
43
|
);
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
44
|
+
const osc = useRef(() => {
|
|
45
|
+
});
|
|
46
|
+
const subscribe = useRef((onStoreChange) => {
|
|
47
|
+
osc.current = onStoreChange;
|
|
48
|
+
return () => {
|
|
49
|
+
osc.current = () => {
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
});
|
|
56
53
|
useEffect(() => {
|
|
57
|
-
const list = (
|
|
54
|
+
const list = () => {
|
|
58
55
|
snapshotValueRef.current = Array.from(
|
|
59
56
|
reactiveIndex.getPksByKey(key)
|
|
60
57
|
);
|
|
61
|
-
|
|
62
|
-
return () => {
|
|
63
|
-
reactiveIndex.updateEventEmitter.unsubscribeFromKey(
|
|
64
|
-
key,
|
|
65
|
-
list
|
|
66
|
-
);
|
|
67
|
-
};
|
|
58
|
+
osc.current();
|
|
68
59
|
};
|
|
69
|
-
reactiveIndex.updateEventEmitter.subscribeOnKey(
|
|
70
|
-
key,
|
|
71
|
-
list
|
|
72
|
-
);
|
|
73
|
-
listener.current = list;
|
|
60
|
+
reactiveIndex.updateEventEmitter.subscribeOnKey(key, list);
|
|
74
61
|
return () => {
|
|
75
|
-
reactiveIndex.updateEventEmitter.unsubscribeFromKey(
|
|
76
|
-
key,
|
|
77
|
-
list
|
|
78
|
-
);
|
|
62
|
+
reactiveIndex.updateEventEmitter.unsubscribeFromKey(key, list);
|
|
79
63
|
};
|
|
80
64
|
}, [key, reactiveIndex.updateEventEmitter, reactiveIndex]);
|
|
81
65
|
const getSnapshot = useMemo(() => {
|
|
@@ -84,7 +68,7 @@ var useSelectPksByIndexKey = (reactiveIndex, key) => {
|
|
|
84
68
|
};
|
|
85
69
|
}, []);
|
|
86
70
|
const snapshot = useSyncExternalStore(
|
|
87
|
-
|
|
71
|
+
subscribe.current,
|
|
88
72
|
getSnapshot,
|
|
89
73
|
getSnapshot
|
|
90
74
|
);
|
|
@@ -94,36 +78,28 @@ var selectEntityByPk = (reactiveCollection, pk) => {
|
|
|
94
78
|
const snapshotValueRef = useRef(
|
|
95
79
|
reactiveCollection.getOneByPk(pk)
|
|
96
80
|
);
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
81
|
+
const osc = useRef(() => {
|
|
82
|
+
});
|
|
83
|
+
const subscribe = useRef((onStoreChange) => {
|
|
84
|
+
osc.current = onStoreChange;
|
|
85
|
+
return () => {
|
|
86
|
+
osc.current = () => {
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
});
|
|
101
90
|
useEffect(() => {
|
|
102
|
-
const list = (
|
|
91
|
+
const list = () => {
|
|
103
92
|
snapshotValueRef.current = reactiveCollection.getOneByPk(pk);
|
|
104
|
-
|
|
105
|
-
return () => {
|
|
106
|
-
reactiveCollection.updateEventEmitter.unsubscribeFromKey(
|
|
107
|
-
pk,
|
|
108
|
-
list
|
|
109
|
-
);
|
|
110
|
-
};
|
|
93
|
+
osc.current();
|
|
111
94
|
};
|
|
112
|
-
reactiveCollection.updateEventEmitter.subscribeOnKey(
|
|
113
|
-
pk,
|
|
114
|
-
list
|
|
115
|
-
);
|
|
116
|
-
listener.current = list;
|
|
95
|
+
reactiveCollection.updateEventEmitter.subscribeOnKey(pk, list);
|
|
117
96
|
return () => {
|
|
118
|
-
reactiveCollection.updateEventEmitter.unsubscribeFromKey(
|
|
119
|
-
pk,
|
|
120
|
-
list
|
|
121
|
-
);
|
|
97
|
+
reactiveCollection.updateEventEmitter.unsubscribeFromKey(pk, list);
|
|
122
98
|
};
|
|
123
99
|
}, [pk, reactiveCollection.updateEventEmitter, reactiveCollection]);
|
|
124
100
|
const getSnapshot = useMemo(() => () => snapshotValueRef.current, []);
|
|
125
101
|
const snapshot = useSyncExternalStore(
|
|
126
|
-
|
|
102
|
+
subscribe.current,
|
|
127
103
|
getSnapshot,
|
|
128
104
|
getSnapshot
|
|
129
105
|
);
|
|
@@ -133,28 +109,23 @@ var useSelectEntitiesByPks = (reactiveCollection, pks) => {
|
|
|
133
109
|
const snapshotValueRef = useRef(
|
|
134
110
|
pks.map((pk) => reactiveCollection.getOneByPk(pk))
|
|
135
111
|
);
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
112
|
+
const osc = useRef(() => {
|
|
113
|
+
});
|
|
114
|
+
const subscribe = useRef((onStoreChange) => {
|
|
115
|
+
osc.current = onStoreChange;
|
|
116
|
+
return () => {
|
|
117
|
+
osc.current = () => {
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
});
|
|
140
121
|
useEffect(() => {
|
|
141
|
-
const list = (
|
|
122
|
+
const list = () => {
|
|
142
123
|
snapshotValueRef.current = pks.map(
|
|
143
124
|
(pk) => reactiveCollection.getOneByPk(pk)
|
|
144
125
|
);
|
|
145
|
-
|
|
146
|
-
return () => {
|
|
147
|
-
reactiveCollection.updateEventEmitter.unsubscribeFromKeys(
|
|
148
|
-
pks,
|
|
149
|
-
list
|
|
150
|
-
);
|
|
151
|
-
};
|
|
126
|
+
osc.current();
|
|
152
127
|
};
|
|
153
|
-
reactiveCollection.updateEventEmitter.subscribeOnKeys(
|
|
154
|
-
pks,
|
|
155
|
-
list
|
|
156
|
-
);
|
|
157
|
-
listener.current = list;
|
|
128
|
+
reactiveCollection.updateEventEmitter.subscribeOnKeys(pks, list);
|
|
158
129
|
return () => {
|
|
159
130
|
reactiveCollection.updateEventEmitter.unsubscribeFromKeys(
|
|
160
131
|
pks,
|
|
@@ -168,7 +139,7 @@ var useSelectEntitiesByPks = (reactiveCollection, pks) => {
|
|
|
168
139
|
};
|
|
169
140
|
}, []);
|
|
170
141
|
const snapshot = useSyncExternalStore(
|
|
171
|
-
|
|
142
|
+
subscribe.current,
|
|
172
143
|
getSnapshot,
|
|
173
144
|
getSnapshot
|
|
174
145
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oimdb/react",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
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",
|
|
@@ -30,11 +30,8 @@
|
|
|
30
30
|
"files": [
|
|
31
31
|
"dist"
|
|
32
32
|
],
|
|
33
|
-
"dependencies": {
|
|
34
|
-
"@oimdb/core": "^1.0.0"
|
|
35
|
-
},
|
|
36
33
|
"peerDependencies": {
|
|
37
|
-
"@oimdb/core": "^1.0.
|
|
34
|
+
"@oimdb/core": "^1.0.6",
|
|
38
35
|
"react": "^18.0.0"
|
|
39
36
|
},
|
|
40
37
|
"devDependencies": {
|