0.2.8 • Published 5 years ago

@authentik8/es-aggregate v0.2.8

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

ES-Aggregate

This package provides my take on an event-sourced aggregate, allowing a user to configure an aggregate based on it's name, initial state, command handling & event processing.

Installation

npm install @authentik8/es-aggregate

Usage

import { createAggregate } from '@authentik8/es-aggregate';

const name = 'Counter'

const initialState = { count: 0 };

const commands = {
  increment: (entity, command) => {
    const { by } = command;
    entity.publish('incremented', { incrementSize: by })
  }
}

const eventHandlers = {
  incremented: (state, event) => ({
    ...state,
    count: state.count + event.incrementSize
  })
}

const aggregate = createAggregate({ 
  name, 
  initialState, 
  commands, 
  eventHandlers 
})
0.2.8

5 years ago

0.2.7

5 years ago

0.2.6

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.2

5 years ago

0.1.0

5 years ago