Interface IEventSourcingLockingAggregate<C, S, E, V>

Event sourcing locking 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 EventLockingRepository.fetchEvents function, and then delegate the command to the decider which can produce new event(s) as a result.

Produced events are then stored via EventLockingRepository.save function.

Author

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

Idugalic

interface IEventSourcingLockingAggregate {
    decide: ((c, s) => readonly E[]);
    evolve: ((s, e) => S);
    fetchEvents: ((c) => Promise<readonly (readonly [E, V])[]>);
    handle: ((command) => Promise<readonly (readonly [E, V])[]>);
    initialState: S;
    latestVersionProvider: LatestVersionProvider<E, V>;
    save: ((e, latestVersion) => Promise<readonly [E, V]>);
    saveAll: ((eList, latestVersion) => Promise<readonly (readonly [E, V])[]>);
    saveAllByLatestVersionProvided: ((eList, latestVersionProvider) => Promise<readonly (readonly [E, V])[]>);
    saveByLatestVersionProvided: ((e, latestVersionProvider) => Promise<readonly [E, 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

    Version

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 (readonly [E, V])[]>)

Type declaration

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

      Parameters

      • c: C

        Command of type C

      Returns Promise<readonly (readonly [E, V])[]>

      list of pairs of Event and Version

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

Type declaration

    • (command): Promise<readonly (readonly [E, V])[]>
    • Handles the command of type C, and returns new persisted list of pairs of event and its version.

      Parameters

      • command: C

        Command of type C

      Returns Promise<readonly (readonly [E, V])[]>

      list of persisted events ot type [E, V`]

initialState: S
latestVersionProvider: LatestVersionProvider<E, V>

The latest event stream version provider

save: ((e, latestVersion) => Promise<readonly [E, V]>)

Type declaration

    • (e, latestVersion): Promise<readonly [E, V]>
    • Save event

      Parameters

      • e: E

        Event of type E

      • latestVersion: null | V

        Latest Event in this stream and its Version

      Returns Promise<readonly [E, V]>

      a pair of newly saved Event of type E and its Version of type V

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

Type declaration

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

      Parameters

      • eList: readonly E[]

        list of Events of type E

      • latestVersion: null | V

        Latest Event in this stream and its Version

      Returns Promise<readonly (readonly [E, V])[]>

      a list of pairs of newly saved Event of type E and its Version of type V

saveAllByLatestVersionProvided: ((eList, latestVersionProvider) => Promise<readonly (readonly [E, V])[]>)

Type declaration

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

      Parameters

      • eList: readonly E[]

        list of Events of type E

      • latestVersionProvider: LatestVersionProvider<E, V>

        A provider for the Latest Event in this stream and its Version

      Returns Promise<readonly (readonly [E, V])[]>

      a list of pairs of newly saved Event of type E and its Version of type V

saveByLatestVersionProvided: ((e, latestVersionProvider) => Promise<readonly [E, V]>)

Type declaration

    • (e, latestVersionProvider): Promise<readonly [E, V]>
    • Save event

      Parameters

      • e: E

        Event of type E

      • latestVersionProvider: LatestVersionProvider<E, V>

        A provider for the Latest Event in this stream and its Version

      Returns Promise<readonly [E, V]>

      a pair of newly saved Event of type E and its Version of type V

Generated using TypeDoc