@oimdb/core 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.
Files changed (2) hide show
  1. package/README.md +16 -6
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -371,28 +371,38 @@ const teamUsers = useSelectEntitiesByPks(users, userIds);
371
371
  Migrate from Redux to OIMDB gradually or use both systems side-by-side with automatic two-way synchronization:
372
372
 
373
373
  ```typescript
374
- import { OIMDBReducerFactory } from '@oimdb/redux-adapter';
375
- import { createStore, combineReducers } from 'redux';
374
+ import { OIMDBAdapter } from '@oimdb/redux-adapter';
375
+ import { createStore, combineReducers, applyMiddleware } from 'redux';
376
+
377
+ // Create Redux adapter
378
+ const adapter = new OIMDBAdapter(queue);
376
379
 
377
380
  // Create Redux reducer from OIMDB collection
378
- const factory = new OIMDBReducerFactory(queue);
379
- const usersReducer = factory.createCollectionReducer(users);
381
+ const usersReducer = adapter.createCollectionReducer(users);
382
+
383
+ // Create middleware for automatic flushing
384
+ const middleware = adapter.createMiddleware();
380
385
 
381
386
  // Use in existing Redux store
382
387
  const store = createStore(
383
388
  combineReducers({
384
389
  users: usersReducer, // OIMDB-backed reducer
385
390
  ui: uiReducer, // Existing Redux reducer
386
- })
391
+ }),
392
+ applyMiddleware(middleware)
387
393
  );
388
394
 
395
+ adapter.setStore(store);
396
+
389
397
  // OIMDB changes automatically sync to Redux
390
- // Redux actions can sync back to OIMDB with child reducers
398
+ // Redux actions automatically sync back to OIMDB with child reducers
399
+ // Middleware automatically flushes queue after each action - no manual flush needed!
391
400
  ```
392
401
 
393
402
  **Key Benefits:**
394
403
  - **🔄 Gradual Migration**: Migrate one collection at a time without breaking changes
395
404
  - **🔄 Two-Way Sync**: Automatic synchronization between OIMDB and Redux
405
+ - **⚡ Automatic Flushing**: Middleware automatically processes events after Redux actions
396
406
  - **📦 Production Ready**: Battle-tested adapter optimized for large datasets
397
407
  - **🎯 Flexible**: Works with any Redux state structure via custom mappers
398
408
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oimdb/core",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "description": "Core in-memory data library with type-safe indices, reactive subscriptions, and event processing",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",