Package Exports
- @castore/inmemory-event-storage-adapter
- @castore/inmemory-event-storage-adapter/dist/cjs/index.js
- @castore/inmemory-event-storage-adapter/dist/esm/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@castore/inmemory-event-storage-adapter) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
In Memory Event Storage Adapter
DRY Castore EventStorageAdapter
implementation using a JS object.
This class is mainly useful for manual and unit tests. It is obviously not recommended for production uses 🙂
📥 Installation
# npm
npm install @castore/inmemory-event-storage-adapter
# yarn
yarn add @castore/inmemory-event-storage-adapter
This package has @castore/core
as peer dependency, so you will have to install it as well:
# npm
npm install @castore/core
# yarn
yarn add @castore/core
👩💻 Usage
import { InMemoryStorageAdapter } from '@castore/inmemory-event-storage-adapter';
const pokemonsEventsStorageAdapter = new InMemoryStorageAdapter({
// 👇 You can specify an initial state for your event store
initialEvents: [
{
aggregateId: '123',
...
},
],
});
const pokemonsEventStore = new EventStore({
...
storageAdapter: pokemonsEventsStorageAdapter,
});
🤔 How it works
This adapter simply persists events in a local dictionary. You can retrieve it at all time through the eventStore
property:
const eventStore = pokemonsEventStore.eventStore;
// => { [aggregateId: string]: EventDetail[] }