Options
All
  • Public
  • Public/Protected
  • All
Menu

The object that you need to create your entities from the underlying storage.

const catStore = new Store<Cat, boolean>(
  (id, decisionProjection, publish) => new Cat(id, decisionProjection, publish),
  catDecisionProvider,
  (event) => bus.publish(event),
);
const felix = await catStore.get("felix");

Type parameters

  • TEntity

  • TDecision

Hierarchy

  • Store

Index

Constructors

constructor

  • new Store(createEntity: function, decisionProvider: DecisionProvider<TDecision>, publishEvent: function): Store
  • Parameters

    • createEntity: function

      a function that the store will call each time you request an entity. An Entity constructor is perfect here.

        • (id: string, decisionSequence: DecisionSequence<TDecision>, publish: function): TEntity
        • Parameters

          • id: string

            the id of the entity

          • decisionSequence: DecisionSequence<TDecision>

            the current DecisionSequence (decision projection + sequence of last event)

          • publish: function

            the publish method to call when the entity wants to emit an event

              • Parameters

                • event: Event

                  the event to publish

                • decisionSequence: DecisionSequence<TDecision>

                  the DecisionSequence up to date with the event to publish

                Returns Promise<void>

          Returns TEntity

    • decisionProvider: DecisionProvider<TDecision>

      an object to get the decision state for an entity

    • publishEvent: function

      the publish method that will be passed to the entities

        • (event: Event): Promise<void>
        • Parameters

          Returns Promise<void>

    Returns Store

Properties

Private createEntity

createEntity: function

a function that the store will call each time you request an entity. An Entity constructor is perfect here.

Type declaration

Private decisionProvider

decisionProvider: DecisionProvider<TDecision>

an object to get the decision state for an entity

Private publishEvent

publishEvent: function

the publish method that will be passed to the entities

Type declaration

    • (event: Event): Promise<void>
    • Parameters

      Returns Promise<void>

Methods

get

  • get(id: string): Promise<TEntity>
  • Parameters

    • id: string

      an entity id

    Returns Promise<TEntity>

    an entity initialized with its decision projection and ready to emit events

Private publish

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc