@oimdb/persist-json

JSON-dump persistence backend for @oimdb/persist โ€” SSR dehydrate/hydrate transport


Keywords
oimdb, persist, ssr, hydration, json
License
MIT
Install
npm install @oimdb/persist-json@3.0.1

Documentation

OIMDB - In-Memory Database for Frontend State Management

A high-performance, event-driven in-memory database designed specifically for frontend applications. OIMDB provides reactive collections, intelligent indexing, and configurable event processing for building fast, predictable state management solutions.

๐Ÿ“ฆ Packages

OIMDB is now organized as a monorepo with separate packages:

@oimdb/core - Core Library

The foundational reactive collections, indexing, and event processing library.

npm install @oimdb/core

Key Features:

  • Reactive collections/objects/indexes with key-scoped subscriptions
  • Intelligent event coalescing and reentrancy-safe delivery for optimal performance
  • Configurable schedulers (microtask, timeout, animationFrame, immediate)
  • Effects & Computed scheduled via OIMComputeRuntime (single draining queue.flush() boundary)
  • Type-safe operations with full TypeScript support
  • O(1) lookups and efficient indexing

๐Ÿ“– See @oimdb/core documentation

@oimdb/react - React Integration

React hooks for seamless integration with OIMDB reactive collections.

npm install @oimdb/react @oimdb/core

Key Features:

  • Direct integration with OIMReactiveCollection and collection-bound indexes
  • Automatic subscriptions using useSyncExternalStore
  • React Context support for centralized collection management
  • Key-specific subscriptions for efficient re-renders

๐Ÿ“– See @oimdb/react documentation

@oimdb/redux-adapter - Redux Integration

Production-ready Redux adapter for gradual migration from Redux to OIMDB or hybrid usage.

npm install @oimdb/redux-adapter @oimdb/core redux

Key Features:

  • ๐Ÿ”„ Two-Way Synchronization: Automatic sync between OIMDB and Redux in both directions
  • โšก Automatic Flushing: Built-in middleware automatically processes events after Redux actions
  • ๐Ÿ“ฆ Production Ready: Battle-tested, optimized for large datasets
  • ๐Ÿ”„ Gradual Migration: Integrate OIMDB into existing Redux projects without breaking changes
  • ๐ŸŽฏ Flexible State Mapping: Custom mappers for any Redux state structure
  • โšก Performance Optimized: Efficient diffing algorithms and batched updates

Perfect for:

  • Migrating from Redux to OIMDB incrementally
  • Using OIMDB for complex relational data alongside Redux
  • Replacing Redux entirely while maintaining compatibility

๐Ÿ“– See @oimdb/redux-adapter documentation

โœจ Quick Example

import { OIMReactiveCollection, OIMEventQueue, OIMEventQueueSchedulerFactory } from '@oimdb/core';

interface User {
  id: string;
  name: string;
  email: string;
}

// Create reactive collection
const queue = new OIMEventQueue({
  scheduler: OIMEventQueueSchedulerFactory.createMicrotask()
});

const users = new OIMReactiveCollection<User, string>(queue, {
  selectPk: (user) => user.id
});

// Subscribe to changes
users.updateEventEmitter.subscribeOnKey('user1', () => {
  console.log('User1 updated!');
});

// Insert and update data. Writes return canonical slots, which can be reused by indexes.
const userSlot = users.upsertOne({
  id: 'user1',
  name: 'John',
  email: 'john@example.com'
});
const updatedUserSlot = users.upsertOne({
  id: 'user1',
  name: 'John Doe',
  email: 'john@example.com'
});
console.log(userSlot === updatedUserSlot); // true
// Only one notification fires due to intelligent coalescing

๐ŸŽฏ Key Benefits

  • ๐Ÿš€ Performance First: Map-based storage with O(1) lookups
  • ๐Ÿ“ก Reactive Architecture: Automatic change notifications with intelligent coalescing
  • ๐Ÿ”ง Type Safety: Full TypeScript support with advanced generics
  • โšก Configurable: Multiple scheduler options for different use cases
  • ๐Ÿ—๏ธ Modular: Use only what you need, extend what you want

๐Ÿš€ Getting Started

For detailed documentation and API reference, visit the individual package READMEs:

๐Ÿงช Development

# Install dependencies
npm install

# Run tests
npm test

# Run benchmarks
npm run bench

# Build packages
npm run build

๐Ÿ“š Documentation

Full documentation is published at oimdb.org.

Source docs live in website/docs/.

๐Ÿค Contributing

Contributions are welcome! OIMDB is designed to be modular and extensible.

๐Ÿ“„ License

MIT License - see LICENSE file for details.

๐Ÿ†˜ Support


OIMDB - High-performance, reactive in-memory database for frontend applications. ๐Ÿš€