@eskit/core
TypeScript icon, indicating that this package has built-in type declarations

3.7.0 • Public • Published

@eskit/core

Core functionality for definition of aggregate roots & associated functionality

Usage

  • Defining an aggregate
import { createAggregateRoot, IAggregateRoot } from '@eskit/core';

interface ICounter {
  value: number;
}

const Counter = createAggregateRoot<ICounter>({
  commands: {
    incrementBy(entity, command) {
      const { by } = command.data;
      entity.publish('incremented', { by });
    }
  },
  initialState: {
    value: 0
  },
  name: 'counter',
  reducer: {
    incremented: (state, event) => ({
      ...state,
      value: state.value + event.data.by
    })
  }
});

Readme

Keywords

none

Package Sidebar

Install

npm i @eskit/core

Weekly Downloads

1

Version

3.7.0

License

MIT

Unpacked Size

55.9 kB

Total Files

52

Last publish

Collaborators

  • authentik8