Interface IStateStoredOrchestratingAggregate<C, S, E>

State stored orchestrating aggregate interface is using/delegating a decider of type IDecider<C, S, E> to handle commands and produce new state. In order to handle the command, aggregate needs to fetch the current state via StateRepository.fetchState function first, and then delegate the command to the decider which can produce new state as a result. If the decider is combined out of many deciders via combine function, an optional saga could be used to react on new events and send new commands to the decider recursively, in one transaction.

New state is then stored via function.


Иван Дугалић / Ivan Dugalic /


interface IStateStoredOrchestratingAggregate {
    decide: ((c, s) => readonly E[]);
    evolve: ((s, e) => S);
    fetchState: ((c) => Promise<null | S>);
    handle: ((command) => Promise<S>);
    initialState: S;
    react: ((ar) => readonly C[]);
    save: ((s) => Promise<S>);

Type Parameters

  • C

    Commands of type C that this aggregate can handle

  • S

    Aggregate state of type S

  • E

    Events of type E that this aggregate can publish


Implemented by


decide: ((c, s) => readonly E[])

Type declaration

    • (c, s): readonly E[]
    • Parameters

      • c: C
      • s: S

      Returns readonly E[]

evolve: ((s, e) => S)

Type declaration

    • (s, e): S
    • Parameters

      • s: S
      • e: E

      Returns S

fetchState: ((c) => Promise<null | S>)

Type declaration

    • (c): Promise<null | S>
    • Fetch state


      • c: C

        Command of type C

      Returns Promise<null | S>

      current state of type S

handle: ((command) => Promise<S>)

Type declaration

    • (command): Promise<S>
    • Parameters

      • command: C

      Returns Promise<S>

initialState: S
react: ((ar) => readonly C[])

Type declaration

    • (ar): readonly C[]
    • Parameters

      • ar: E

      Returns readonly C[]

save: ((s) => Promise<S>)

Type declaration

    • (s): Promise<S>
    • Save state


      • s: S

        State of type S

      Returns Promise<S>

      newly saved State of type S

Generated using TypeDoc