@oimdb/react 1.2.2 → 1.3.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 +39 -92
- package/dist/index.js +39 -92
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -49,31 +49,24 @@ var useSelectPksByIndexKeysSetBased = (reactiveIndex, keys) => {
|
|
|
49
49
|
if (!keysAreEqual) {
|
|
50
50
|
prevKeysRef.current = keys;
|
|
51
51
|
}
|
|
52
|
+
const stableKeys = keysAreEqual ? prevKeysRef.current ?? keys : keys;
|
|
52
53
|
const snapshotValueRef = (0, import_react.useRef)();
|
|
53
54
|
const subscribe = (0, import_react.useMemo)(() => {
|
|
54
|
-
snapshotValueRef.current =
|
|
55
|
+
snapshotValueRef.current = stableKeys.map((key) => Array.from(reactiveIndex.getPksByKey(key))).flat();
|
|
55
56
|
return (onStoreChange) => {
|
|
56
|
-
const prevKeys = prevKeysRef.current;
|
|
57
|
-
if (!prevKeys) {
|
|
58
|
-
return () => {
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
57
|
const updateSnapshot = () => {
|
|
62
|
-
snapshotValueRef.current =
|
|
58
|
+
snapshotValueRef.current = stableKeys.map((key) => Array.from(reactiveIndex.getPksByKey(key))).flat();
|
|
63
59
|
onStoreChange();
|
|
64
60
|
};
|
|
65
|
-
reactiveIndex.
|
|
66
|
-
|
|
61
|
+
const unsubscribe = reactiveIndex.subscribeOnKeys(
|
|
62
|
+
stableKeys,
|
|
67
63
|
updateSnapshot
|
|
68
64
|
);
|
|
69
65
|
return () => {
|
|
70
|
-
|
|
71
|
-
prevKeys,
|
|
72
|
-
updateSnapshot
|
|
73
|
-
);
|
|
66
|
+
unsubscribe();
|
|
74
67
|
};
|
|
75
68
|
};
|
|
76
|
-
}, [
|
|
69
|
+
}, [reactiveIndex, stableKeys]);
|
|
77
70
|
const getSnapshot = (0, import_react.useMemo)(() => {
|
|
78
71
|
return () => {
|
|
79
72
|
return snapshotValueRef.current;
|
|
@@ -90,15 +83,9 @@ var useSelectPksByIndexKeySetBased = (reactiveIndex, key) => {
|
|
|
90
83
|
}, [key, reactiveIndex]);
|
|
91
84
|
const subscribe = (0, import_react.useMemo)(() => {
|
|
92
85
|
return (onStoreChange) => {
|
|
93
|
-
reactiveIndex.
|
|
94
|
-
return () => {
|
|
95
|
-
reactiveIndex.updateEventEmitter.unsubscribeFromKey(
|
|
96
|
-
key,
|
|
97
|
-
onStoreChange
|
|
98
|
-
);
|
|
99
|
-
};
|
|
86
|
+
return reactiveIndex.subscribeOnKey(key, onStoreChange);
|
|
100
87
|
};
|
|
101
|
-
}, [key, reactiveIndex
|
|
88
|
+
}, [key, reactiveIndex]);
|
|
102
89
|
const snapshot = (0, import_react2.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
|
|
103
90
|
return snapshot;
|
|
104
91
|
};
|
|
@@ -108,31 +95,24 @@ var useSelectPksByIndexKeysArrayBased = (reactiveIndex, keys) => {
|
|
|
108
95
|
if (!keysAreEqual) {
|
|
109
96
|
prevKeysRef.current = keys;
|
|
110
97
|
}
|
|
98
|
+
const stableKeys = keysAreEqual ? prevKeysRef.current ?? keys : keys;
|
|
111
99
|
const snapshotValueRef = (0, import_react.useRef)();
|
|
112
100
|
const subscribe = (0, import_react.useMemo)(() => {
|
|
113
|
-
snapshotValueRef.current =
|
|
101
|
+
snapshotValueRef.current = stableKeys.map((key) => reactiveIndex.getPksByKey(key)).flat();
|
|
114
102
|
return (onStoreChange) => {
|
|
115
|
-
const prevKeys = prevKeysRef.current;
|
|
116
|
-
if (!prevKeys) {
|
|
117
|
-
return () => {
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
103
|
const updateSnapshot = () => {
|
|
121
|
-
snapshotValueRef.current =
|
|
104
|
+
snapshotValueRef.current = stableKeys.map((key) => reactiveIndex.getPksByKey(key)).flat();
|
|
122
105
|
onStoreChange();
|
|
123
106
|
};
|
|
124
|
-
reactiveIndex.
|
|
125
|
-
|
|
107
|
+
const unsubscribe = reactiveIndex.subscribeOnKeys(
|
|
108
|
+
stableKeys,
|
|
126
109
|
updateSnapshot
|
|
127
110
|
);
|
|
128
111
|
return () => {
|
|
129
|
-
|
|
130
|
-
prevKeys,
|
|
131
|
-
updateSnapshot
|
|
132
|
-
);
|
|
112
|
+
unsubscribe();
|
|
133
113
|
};
|
|
134
114
|
};
|
|
135
|
-
}, [
|
|
115
|
+
}, [reactiveIndex, stableKeys]);
|
|
136
116
|
const getSnapshot = (0, import_react.useMemo)(() => {
|
|
137
117
|
return () => {
|
|
138
118
|
return snapshotValueRef.current;
|
|
@@ -160,18 +140,15 @@ var useSelectPksByIndexKeyArrayBased = (reactiveIndex, key) => {
|
|
|
160
140
|
snapshotValueRef.current = reactiveIndex.getPksByKey(prevKey);
|
|
161
141
|
onStoreChange();
|
|
162
142
|
};
|
|
163
|
-
reactiveIndex.
|
|
143
|
+
const unsubscribe = reactiveIndex.subscribeOnKey(
|
|
164
144
|
prevKey,
|
|
165
145
|
updateSnapshot
|
|
166
146
|
);
|
|
167
147
|
return () => {
|
|
168
|
-
|
|
169
|
-
prevKey,
|
|
170
|
-
updateSnapshot
|
|
171
|
-
);
|
|
148
|
+
unsubscribe();
|
|
172
149
|
};
|
|
173
150
|
};
|
|
174
|
-
}, [key, reactiveIndex
|
|
151
|
+
}, [key, reactiveIndex]);
|
|
175
152
|
const getSnapshot = (0, import_react.useMemo)(() => {
|
|
176
153
|
return () => {
|
|
177
154
|
return snapshotValueRef.current;
|
|
@@ -187,18 +164,9 @@ var useSelectEntityByPk = (reactiveCollection, pk) => {
|
|
|
187
164
|
);
|
|
188
165
|
const subscribe = (0, import_react.useMemo)(() => {
|
|
189
166
|
return (onStoreChange) => {
|
|
190
|
-
reactiveCollection.
|
|
191
|
-
pk,
|
|
192
|
-
onStoreChange
|
|
193
|
-
);
|
|
194
|
-
return () => {
|
|
195
|
-
reactiveCollection.updateEventEmitter.unsubscribeFromKey(
|
|
196
|
-
pk,
|
|
197
|
-
onStoreChange
|
|
198
|
-
);
|
|
199
|
-
};
|
|
167
|
+
return reactiveCollection.subscribeOnKey(pk, onStoreChange);
|
|
200
168
|
};
|
|
201
|
-
}, [pk, reactiveCollection
|
|
169
|
+
}, [pk, reactiveCollection]);
|
|
202
170
|
const snapshot = (0, import_react2.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
|
|
203
171
|
return snapshot;
|
|
204
172
|
};
|
|
@@ -209,18 +177,9 @@ var useSelectValueByObjectKey = (reactiveObject, key) => {
|
|
|
209
177
|
);
|
|
210
178
|
const subscribe = (0, import_react.useMemo)(() => {
|
|
211
179
|
return (onStoreChange) => {
|
|
212
|
-
reactiveObject.
|
|
213
|
-
key,
|
|
214
|
-
onStoreChange
|
|
215
|
-
);
|
|
216
|
-
return () => {
|
|
217
|
-
reactiveObject.updateEventEmitter.unsubscribeFromKey(
|
|
218
|
-
key,
|
|
219
|
-
onStoreChange
|
|
220
|
-
);
|
|
221
|
-
};
|
|
180
|
+
return reactiveObject.subscribeOnKey(key, onStoreChange);
|
|
222
181
|
};
|
|
223
|
-
}, [key, reactiveObject
|
|
182
|
+
}, [key, reactiveObject]);
|
|
224
183
|
const snapshot = (0, import_react2.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
|
|
225
184
|
return snapshot;
|
|
226
185
|
};
|
|
@@ -230,33 +189,26 @@ var useSelectValuesByObjectKeys = (reactiveObject, keys) => {
|
|
|
230
189
|
if (!keysAreEqual) {
|
|
231
190
|
prevKeysRef.current = keys;
|
|
232
191
|
}
|
|
192
|
+
const stableKeys = keysAreEqual ? prevKeysRef.current ?? keys : keys;
|
|
233
193
|
const snapshotRef = (0, import_react.useRef)();
|
|
234
194
|
const subscribe = (0, import_react.useMemo)(() => {
|
|
235
|
-
snapshotRef.current =
|
|
195
|
+
snapshotRef.current = stableKeys.map((key) => reactiveObject.get(key));
|
|
236
196
|
return (onStoreChange) => {
|
|
237
|
-
const prevKeys = prevKeysRef.current;
|
|
238
|
-
if (!prevKeys) {
|
|
239
|
-
return () => {
|
|
240
|
-
};
|
|
241
|
-
}
|
|
242
197
|
const updateSnapshot = () => {
|
|
243
|
-
snapshotRef.current =
|
|
198
|
+
snapshotRef.current = stableKeys.map(
|
|
244
199
|
(key) => reactiveObject.get(key)
|
|
245
200
|
);
|
|
246
201
|
onStoreChange();
|
|
247
202
|
};
|
|
248
|
-
reactiveObject.
|
|
249
|
-
|
|
203
|
+
const unsubscribe = reactiveObject.subscribeOnKeys(
|
|
204
|
+
stableKeys,
|
|
250
205
|
updateSnapshot
|
|
251
206
|
);
|
|
252
207
|
return () => {
|
|
253
|
-
|
|
254
|
-
prevKeys,
|
|
255
|
-
updateSnapshot
|
|
256
|
-
);
|
|
208
|
+
unsubscribe();
|
|
257
209
|
};
|
|
258
210
|
};
|
|
259
|
-
}, [
|
|
211
|
+
}, [reactiveObject, stableKeys]);
|
|
260
212
|
const getSnapshot = (0, import_react.useMemo)(() => {
|
|
261
213
|
return () => {
|
|
262
214
|
return snapshotRef.current;
|
|
@@ -279,33 +231,28 @@ var useSelectEntitiesByPks = (reactiveCollection, pks) => {
|
|
|
279
231
|
if (!pksAreEqual) {
|
|
280
232
|
prevPksRef.current = pks;
|
|
281
233
|
}
|
|
234
|
+
const stablePks = pksAreEqual ? prevPksRef.current ?? pks : pks;
|
|
282
235
|
const snapshotRef = (0, import_react.useRef)();
|
|
283
236
|
const subscribe = (0, import_react.useMemo)(() => {
|
|
284
|
-
snapshotRef.current =
|
|
237
|
+
snapshotRef.current = stablePks.map(
|
|
238
|
+
(pk) => reactiveCollection.getOneByPk(pk)
|
|
239
|
+
);
|
|
285
240
|
return (onStoreChange) => {
|
|
286
|
-
const prevPks = prevPksRef.current;
|
|
287
|
-
if (!prevPks) {
|
|
288
|
-
return () => {
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
241
|
const updateSnapshot = () => {
|
|
292
|
-
snapshotRef.current =
|
|
242
|
+
snapshotRef.current = stablePks.map(
|
|
293
243
|
(pk) => reactiveCollection.getOneByPk(pk)
|
|
294
244
|
);
|
|
295
245
|
onStoreChange();
|
|
296
246
|
};
|
|
297
|
-
reactiveCollection.
|
|
298
|
-
|
|
247
|
+
const unsubscribe = reactiveCollection.subscribeOnKeys(
|
|
248
|
+
stablePks,
|
|
299
249
|
updateSnapshot
|
|
300
250
|
);
|
|
301
251
|
return () => {
|
|
302
|
-
|
|
303
|
-
prevPks,
|
|
304
|
-
updateSnapshot
|
|
305
|
-
);
|
|
252
|
+
unsubscribe();
|
|
306
253
|
};
|
|
307
254
|
};
|
|
308
|
-
}, [
|
|
255
|
+
}, [reactiveCollection, stablePks]);
|
|
309
256
|
const getSnapshot = (0, import_react.useMemo)(() => {
|
|
310
257
|
return () => {
|
|
311
258
|
return snapshotRef.current;
|
package/dist/index.js
CHANGED
|
@@ -8,31 +8,24 @@ var useSelectPksByIndexKeysSetBased = (reactiveIndex, keys) => {
|
|
|
8
8
|
if (!keysAreEqual) {
|
|
9
9
|
prevKeysRef.current = keys;
|
|
10
10
|
}
|
|
11
|
+
const stableKeys = keysAreEqual ? prevKeysRef.current ?? keys : keys;
|
|
11
12
|
const snapshotValueRef = useRef();
|
|
12
13
|
const subscribe = useMemo(() => {
|
|
13
|
-
snapshotValueRef.current =
|
|
14
|
+
snapshotValueRef.current = stableKeys.map((key) => Array.from(reactiveIndex.getPksByKey(key))).flat();
|
|
14
15
|
return (onStoreChange) => {
|
|
15
|
-
const prevKeys = prevKeysRef.current;
|
|
16
|
-
if (!prevKeys) {
|
|
17
|
-
return () => {
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
16
|
const updateSnapshot = () => {
|
|
21
|
-
snapshotValueRef.current =
|
|
17
|
+
snapshotValueRef.current = stableKeys.map((key) => Array.from(reactiveIndex.getPksByKey(key))).flat();
|
|
22
18
|
onStoreChange();
|
|
23
19
|
};
|
|
24
|
-
reactiveIndex.
|
|
25
|
-
|
|
20
|
+
const unsubscribe = reactiveIndex.subscribeOnKeys(
|
|
21
|
+
stableKeys,
|
|
26
22
|
updateSnapshot
|
|
27
23
|
);
|
|
28
24
|
return () => {
|
|
29
|
-
|
|
30
|
-
prevKeys,
|
|
31
|
-
updateSnapshot
|
|
32
|
-
);
|
|
25
|
+
unsubscribe();
|
|
33
26
|
};
|
|
34
27
|
};
|
|
35
|
-
}, [
|
|
28
|
+
}, [reactiveIndex, stableKeys]);
|
|
36
29
|
const getSnapshot = useMemo(() => {
|
|
37
30
|
return () => {
|
|
38
31
|
return snapshotValueRef.current;
|
|
@@ -49,15 +42,9 @@ var useSelectPksByIndexKeySetBased = (reactiveIndex, key) => {
|
|
|
49
42
|
}, [key, reactiveIndex]);
|
|
50
43
|
const subscribe = useMemo(() => {
|
|
51
44
|
return (onStoreChange) => {
|
|
52
|
-
reactiveIndex.
|
|
53
|
-
return () => {
|
|
54
|
-
reactiveIndex.updateEventEmitter.unsubscribeFromKey(
|
|
55
|
-
key,
|
|
56
|
-
onStoreChange
|
|
57
|
-
);
|
|
58
|
-
};
|
|
45
|
+
return reactiveIndex.subscribeOnKey(key, onStoreChange);
|
|
59
46
|
};
|
|
60
|
-
}, [key, reactiveIndex
|
|
47
|
+
}, [key, reactiveIndex]);
|
|
61
48
|
const snapshot = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
62
49
|
return snapshot;
|
|
63
50
|
};
|
|
@@ -67,31 +54,24 @@ var useSelectPksByIndexKeysArrayBased = (reactiveIndex, keys) => {
|
|
|
67
54
|
if (!keysAreEqual) {
|
|
68
55
|
prevKeysRef.current = keys;
|
|
69
56
|
}
|
|
57
|
+
const stableKeys = keysAreEqual ? prevKeysRef.current ?? keys : keys;
|
|
70
58
|
const snapshotValueRef = useRef();
|
|
71
59
|
const subscribe = useMemo(() => {
|
|
72
|
-
snapshotValueRef.current =
|
|
60
|
+
snapshotValueRef.current = stableKeys.map((key) => reactiveIndex.getPksByKey(key)).flat();
|
|
73
61
|
return (onStoreChange) => {
|
|
74
|
-
const prevKeys = prevKeysRef.current;
|
|
75
|
-
if (!prevKeys) {
|
|
76
|
-
return () => {
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
62
|
const updateSnapshot = () => {
|
|
80
|
-
snapshotValueRef.current =
|
|
63
|
+
snapshotValueRef.current = stableKeys.map((key) => reactiveIndex.getPksByKey(key)).flat();
|
|
81
64
|
onStoreChange();
|
|
82
65
|
};
|
|
83
|
-
reactiveIndex.
|
|
84
|
-
|
|
66
|
+
const unsubscribe = reactiveIndex.subscribeOnKeys(
|
|
67
|
+
stableKeys,
|
|
85
68
|
updateSnapshot
|
|
86
69
|
);
|
|
87
70
|
return () => {
|
|
88
|
-
|
|
89
|
-
prevKeys,
|
|
90
|
-
updateSnapshot
|
|
91
|
-
);
|
|
71
|
+
unsubscribe();
|
|
92
72
|
};
|
|
93
73
|
};
|
|
94
|
-
}, [
|
|
74
|
+
}, [reactiveIndex, stableKeys]);
|
|
95
75
|
const getSnapshot = useMemo(() => {
|
|
96
76
|
return () => {
|
|
97
77
|
return snapshotValueRef.current;
|
|
@@ -119,18 +99,15 @@ var useSelectPksByIndexKeyArrayBased = (reactiveIndex, key) => {
|
|
|
119
99
|
snapshotValueRef.current = reactiveIndex.getPksByKey(prevKey);
|
|
120
100
|
onStoreChange();
|
|
121
101
|
};
|
|
122
|
-
reactiveIndex.
|
|
102
|
+
const unsubscribe = reactiveIndex.subscribeOnKey(
|
|
123
103
|
prevKey,
|
|
124
104
|
updateSnapshot
|
|
125
105
|
);
|
|
126
106
|
return () => {
|
|
127
|
-
|
|
128
|
-
prevKey,
|
|
129
|
-
updateSnapshot
|
|
130
|
-
);
|
|
107
|
+
unsubscribe();
|
|
131
108
|
};
|
|
132
109
|
};
|
|
133
|
-
}, [key, reactiveIndex
|
|
110
|
+
}, [key, reactiveIndex]);
|
|
134
111
|
const getSnapshot = useMemo(() => {
|
|
135
112
|
return () => {
|
|
136
113
|
return snapshotValueRef.current;
|
|
@@ -146,18 +123,9 @@ var useSelectEntityByPk = (reactiveCollection, pk) => {
|
|
|
146
123
|
);
|
|
147
124
|
const subscribe = useMemo(() => {
|
|
148
125
|
return (onStoreChange) => {
|
|
149
|
-
reactiveCollection.
|
|
150
|
-
pk,
|
|
151
|
-
onStoreChange
|
|
152
|
-
);
|
|
153
|
-
return () => {
|
|
154
|
-
reactiveCollection.updateEventEmitter.unsubscribeFromKey(
|
|
155
|
-
pk,
|
|
156
|
-
onStoreChange
|
|
157
|
-
);
|
|
158
|
-
};
|
|
126
|
+
return reactiveCollection.subscribeOnKey(pk, onStoreChange);
|
|
159
127
|
};
|
|
160
|
-
}, [pk, reactiveCollection
|
|
128
|
+
}, [pk, reactiveCollection]);
|
|
161
129
|
const snapshot = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
162
130
|
return snapshot;
|
|
163
131
|
};
|
|
@@ -168,18 +136,9 @@ var useSelectValueByObjectKey = (reactiveObject, key) => {
|
|
|
168
136
|
);
|
|
169
137
|
const subscribe = useMemo(() => {
|
|
170
138
|
return (onStoreChange) => {
|
|
171
|
-
reactiveObject.
|
|
172
|
-
key,
|
|
173
|
-
onStoreChange
|
|
174
|
-
);
|
|
175
|
-
return () => {
|
|
176
|
-
reactiveObject.updateEventEmitter.unsubscribeFromKey(
|
|
177
|
-
key,
|
|
178
|
-
onStoreChange
|
|
179
|
-
);
|
|
180
|
-
};
|
|
139
|
+
return reactiveObject.subscribeOnKey(key, onStoreChange);
|
|
181
140
|
};
|
|
182
|
-
}, [key, reactiveObject
|
|
141
|
+
}, [key, reactiveObject]);
|
|
183
142
|
const snapshot = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
184
143
|
return snapshot;
|
|
185
144
|
};
|
|
@@ -189,33 +148,26 @@ var useSelectValuesByObjectKeys = (reactiveObject, keys) => {
|
|
|
189
148
|
if (!keysAreEqual) {
|
|
190
149
|
prevKeysRef.current = keys;
|
|
191
150
|
}
|
|
151
|
+
const stableKeys = keysAreEqual ? prevKeysRef.current ?? keys : keys;
|
|
192
152
|
const snapshotRef = useRef();
|
|
193
153
|
const subscribe = useMemo(() => {
|
|
194
|
-
snapshotRef.current =
|
|
154
|
+
snapshotRef.current = stableKeys.map((key) => reactiveObject.get(key));
|
|
195
155
|
return (onStoreChange) => {
|
|
196
|
-
const prevKeys = prevKeysRef.current;
|
|
197
|
-
if (!prevKeys) {
|
|
198
|
-
return () => {
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
156
|
const updateSnapshot = () => {
|
|
202
|
-
snapshotRef.current =
|
|
157
|
+
snapshotRef.current = stableKeys.map(
|
|
203
158
|
(key) => reactiveObject.get(key)
|
|
204
159
|
);
|
|
205
160
|
onStoreChange();
|
|
206
161
|
};
|
|
207
|
-
reactiveObject.
|
|
208
|
-
|
|
162
|
+
const unsubscribe = reactiveObject.subscribeOnKeys(
|
|
163
|
+
stableKeys,
|
|
209
164
|
updateSnapshot
|
|
210
165
|
);
|
|
211
166
|
return () => {
|
|
212
|
-
|
|
213
|
-
prevKeys,
|
|
214
|
-
updateSnapshot
|
|
215
|
-
);
|
|
167
|
+
unsubscribe();
|
|
216
168
|
};
|
|
217
169
|
};
|
|
218
|
-
}, [
|
|
170
|
+
}, [reactiveObject, stableKeys]);
|
|
219
171
|
const getSnapshot = useMemo(() => {
|
|
220
172
|
return () => {
|
|
221
173
|
return snapshotRef.current;
|
|
@@ -238,33 +190,28 @@ var useSelectEntitiesByPks = (reactiveCollection, pks) => {
|
|
|
238
190
|
if (!pksAreEqual) {
|
|
239
191
|
prevPksRef.current = pks;
|
|
240
192
|
}
|
|
193
|
+
const stablePks = pksAreEqual ? prevPksRef.current ?? pks : pks;
|
|
241
194
|
const snapshotRef = useRef();
|
|
242
195
|
const subscribe = useMemo(() => {
|
|
243
|
-
snapshotRef.current =
|
|
196
|
+
snapshotRef.current = stablePks.map(
|
|
197
|
+
(pk) => reactiveCollection.getOneByPk(pk)
|
|
198
|
+
);
|
|
244
199
|
return (onStoreChange) => {
|
|
245
|
-
const prevPks = prevPksRef.current;
|
|
246
|
-
if (!prevPks) {
|
|
247
|
-
return () => {
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
200
|
const updateSnapshot = () => {
|
|
251
|
-
snapshotRef.current =
|
|
201
|
+
snapshotRef.current = stablePks.map(
|
|
252
202
|
(pk) => reactiveCollection.getOneByPk(pk)
|
|
253
203
|
);
|
|
254
204
|
onStoreChange();
|
|
255
205
|
};
|
|
256
|
-
reactiveCollection.
|
|
257
|
-
|
|
206
|
+
const unsubscribe = reactiveCollection.subscribeOnKeys(
|
|
207
|
+
stablePks,
|
|
258
208
|
updateSnapshot
|
|
259
209
|
);
|
|
260
210
|
return () => {
|
|
261
|
-
|
|
262
|
-
prevPks,
|
|
263
|
-
updateSnapshot
|
|
264
|
-
);
|
|
211
|
+
unsubscribe();
|
|
265
212
|
};
|
|
266
213
|
};
|
|
267
|
-
}, [
|
|
214
|
+
}, [reactiveCollection, stablePks]);
|
|
268
215
|
const getSnapshot = useMemo(() => {
|
|
269
216
|
return () => {
|
|
270
217
|
return snapshotRef.current;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oimdb/react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
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",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
|
-
"build": "tsup
|
|
26
|
+
"build": "tsup --config tsup.config.ts --tsconfig tsconfig.build.json",
|
|
27
27
|
"test": "jest",
|
|
28
28
|
"type-check": "tsc --noEmit",
|
|
29
29
|
"clean": "rimraf dist",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"dist"
|
|
34
34
|
],
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@oimdb/core": "^1.4.
|
|
37
|
-
"react": "^18.0.0"
|
|
36
|
+
"@oimdb/core": "^1.4.1",
|
|
37
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@testing-library/react": "^14.3.1",
|