eventsrc.js
Extremely simple, storage agnostic event sourcing library.
- Allows for versioning of documents through events
- Lightweight without any dependencies
- Exposes a handful of methods
/* * This code creates a shopping cart event store * using a memory storage */const cartEventStore = /* * Subscribe to any events that are emitted on the store */cartEventStore /* * Emit an event with the key "CART_CREATED" * and a payload that contains the id, which always needs to be passed * and the items (see reduce method for logic) */cartEventStore /* * Emit a second event that adds another item to the cart */cartEventStore console // holds two itemsconsole // holds only one item
How to install
npm install eventsrc --save