Interface IEventSourcingOrchestratingAggregate<C, S, E>

Event sourcing orchestrating aggregate interface is using/delegating a decider of type IDecider<C, S, E> to handle commands and produce events. In order to handle the command, aggregate needs to fetch the current state (represented as a list of events) via EventRepository.fetchEvents function, and then delegate the command to the decider which can produce new event(s) as a result.

If the decider is combined out of many deciders via combine function, an optional EventSourcingOrchestratingAggregate.saga could be used to react on new events and send new commands to the decider recursively, in one transaction.

Produced events are then stored via EventRepository.save function.

Author

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

Idugalic

interface IEventSourcingOrchestratingAggregate {
    decide: ((c, s) => readonly E[]);
    evolve: ((s, e) => S);
    fetchEvents: ((c) => Promise<readonly E[]>);
    handle: ((command) => Promise<readonly E[]>);
    initialState: S;
    react: ((ar) => readonly C[]);
    save: ((e) => Promise<E>);
    saveAll: ((eList) => Promise<readonly E[]>);
}

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

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

fetchEvents: ((c) => Promise<readonly E[]>)

Type declaration

    • (c): Promise<readonly E[]>
    • Fetch events

      Parameters

      • c: C

        Command of type C

      Returns Promise<readonly E[]>

      list of Events of type E

handle: ((command) => Promise<readonly E[]>)

Type declaration

    • (command): Promise<readonly E[]>
    • Handles the command of type C, and returns new persisted events.

      Parameters

      • command: C

        Command of type C

      Returns Promise<readonly E[]>

      list of persisted events ot type E

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

Type declaration

    • (ar): readonly C[]
    • Parameters

      • ar: E

      Returns readonly C[]

save: ((e) => Promise<E>)

Type declaration

    • (e): Promise<E>
    • Save event

      Parameters

      • e: E

        Event of type E

      Returns Promise<E>

      newly saved Event of type E

saveAll: ((eList) => Promise<readonly E[]>)

Type declaration

    • (eList): Promise<readonly E[]>
    • Save events

      Parameters

      • eList: readonly E[]

        list of Events of type E

      Returns Promise<readonly E[]>

      newly saved list of Events of type E

Generated using TypeDoc