@oimdb/core 1.0.6 → 1.2.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/README.md CHANGED
@@ -65,9 +65,7 @@ const queue = new OIMEventQueue({
65
65
 
66
66
  // Create reactive collection
67
67
  const users = new OIMReactiveCollection<User, string>(queue, {
68
- collectionOpts: {
69
- selectPk: (user) => user.id
70
- }
68
+ selectPk: (user) => user.id
71
69
  });
72
70
 
73
71
  // Subscribe to key-specific updates
@@ -249,10 +247,8 @@ const deepMergeUpdater: TOIMEntityUpdater<User> = (newEntity, oldEntity) => {
249
247
  // Use custom updater with reactive collection
250
248
  const queue = new OIMEventQueue();
251
249
  const users = new OIMReactiveCollection<User, string>(queue, {
252
- collectionOpts: {
253
- selectPk: (user) => user.id,
254
- updateEntity: deepMergeUpdater
255
- }
250
+ selectPk: (user) => user.id,
251
+ updateEntity: deepMergeUpdater
256
252
  });
257
253
 
258
254
  // Now updates will use deep merge logic
@@ -370,6 +366,38 @@ const user = selectEntityByPk(users, 'user1');
370
366
  const teamUsers = useSelectEntitiesByPks(users, userIds);
371
367
  ```
372
368
 
369
+ ### With Redux (@oimdb/redux-adapter)
370
+
371
+ Migrate from Redux to OIMDB gradually or use both systems side-by-side with automatic two-way synchronization:
372
+
373
+ ```typescript
374
+ import { OIMDBReducerFactory } from '@oimdb/redux-adapter';
375
+ import { createStore, combineReducers } from 'redux';
376
+
377
+ // Create Redux reducer from OIMDB collection
378
+ const factory = new OIMDBReducerFactory(queue);
379
+ const usersReducer = factory.createCollectionReducer(users);
380
+
381
+ // Use in existing Redux store
382
+ const store = createStore(
383
+ combineReducers({
384
+ users: usersReducer, // OIMDB-backed reducer
385
+ ui: uiReducer, // Existing Redux reducer
386
+ })
387
+ );
388
+
389
+ // OIMDB changes automatically sync to Redux
390
+ // Redux actions can sync back to OIMDB with child reducers
391
+ ```
392
+
393
+ **Key Benefits:**
394
+ - **🔄 Gradual Migration**: Migrate one collection at a time without breaking changes
395
+ - **🔄 Two-Way Sync**: Automatic synchronization between OIMDB and Redux
396
+ - **📦 Production Ready**: Battle-tested adapter optimized for large datasets
397
+ - **🎯 Flexible**: Works with any Redux state structure via custom mappers
398
+
399
+ [📖 See @oimdb/redux-adapter documentation](../redux-adapter/README.md) for complete migration guide and examples.
400
+
373
401
  ### Standalone Usage
374
402
 
375
403
  Use core classes directly for maximum control:
@@ -393,9 +421,7 @@ Reactive collection with automatic change notifications and event coalescing.
393
421
 
394
422
  **Constructor:**
395
423
  ```typescript
396
- new OIMReactiveCollection(queue: OIMEventQueue, opts?: {
397
- collectionOpts?: TOIMCollectionOptions<TEntity, TPk>
398
- })
424
+ new OIMReactiveCollection(queue: OIMEventQueue, opts?: TOIMCollectionOptions<TEntity, TPk>)
399
425
  ```
400
426
 
401
427
  **Properties:**
@@ -411,19 +437,19 @@ new OIMReactiveCollection(queue: OIMEventQueue, opts?: {
411
437
  - `getOneByPk(pk: TPk): TEntity | undefined` - Get entity by primary key
412
438
  - `getManyByPks(pks: readonly TPk[]): Map<TPk, TEntity | undefined>` - Get multiple entities
413
439
 
414
- #### `OIMRICollection<TEntity, TPk, TIndexName, TIndexKey, TIndex, TReactiveIndex>`
440
+ #### `OIMRICollection<TEntity, TPk, TIndexName, TIndexKey, TIndex, TReactiveIndex, TReactiveIndexMap>`
415
441
  Reactive collection with integrated indexing capabilities.
416
442
 
417
443
  **Constructor:**
418
444
  ```typescript
419
445
  new OIMRICollection(queue: OIMEventQueue, opts: {
420
446
  collectionOpts?: TOIMCollectionOptions<TEntity, TPk>;
421
- indexes: Record<TIndexName, TReactiveIndex>;
447
+ indexes: TReactiveIndexMap;
422
448
  })
423
449
  ```
424
450
 
425
451
  **Properties:**
426
- - `indexes: Record<TIndexName, TReactiveIndex>` - Named reactive indexes
452
+ - `indexes: TReactiveIndexMap` - Named reactive indexes preserving index-to-name mapping
427
453
  - *(inherits all OIMReactiveCollection properties)*
428
454
 
429
455
  #### `OIMReactiveIndexManual<TKey, TPk>`
@@ -529,9 +555,7 @@ describe('OIMReactiveCollection', () => {
529
555
  });
530
556
 
531
557
  users = new OIMReactiveCollection(queue, {
532
- collectionOpts: {
533
- selectPk: (user) => user.id
534
- }
558
+ selectPk: (user) => user.id
535
559
  });
536
560
  });
537
561