Interface IStateStoredOrchestratingLockingAggregate<C, S, E, V>

State stored orchestrating and locking 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 StateLockingRepository.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 StateLockingRepository.save function.

Author

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

Idugalic

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

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

  • V

    The Version of the stored State

Hierarchy

Implemented by

Properties

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<readonly [null | S, null | V]>)

Type declaration

    • (c): Promise<readonly [null | S, null | V]>
    • Fetch state and version

      Parameters

      • c: C

        Command of type C

      Returns Promise<readonly [null | S, null | V]>

      the pair of current State/[S] and current Version/[V]

handle: ((command) => Promise<readonly [S, V]>)

Type declaration

    • (command): Promise<readonly [S, V]>
    • Parameters

      • command: C

      Returns Promise<readonly [S, V]>

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

Type declaration

    • (ar): readonly C[]
    • Parameters

      • ar: E

      Returns readonly C[]

save: ((s, v) => Promise<readonly [S, V]>)

Type declaration

    • (s, v): Promise<readonly [S, V]>
    • Save state

      You can update/save the item/state, but only if the version number in the storage has not changed.

      Parameters

      • s: S

        State of type S

      • v: null | V

        The current version of the state

      Returns Promise<readonly [S, V]>

      newly saved State of type [S, V]

Generated using TypeDoc