Interface IMaterializedLockingDeduplicationView<S, E, EV, SV>

Materialized Locking and Deduplication view interface is using/delegating a IView to handle events of type E and to maintain a state of projection(s) via ViewStateLockingDeduplicationRepository as a result. Essentially, it represents the query/view side of the CQRS pattern.

It can deduplicate events within at-least-once delivery guaranty - inspired by optimistic locking


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


interface IMaterializedLockingDeduplicationView {
    evolve: ((s, e) => S);
    fetchState: ((e) => Promise<readonly [null | S, null | SV]>);
    handle: ((eventAndVersion) => Promise<readonly [S, SV]>);
    initialState: S;
    save: ((s, eventVersion, currentStateVersion) => Promise<readonly [S, SV]>);

Type Parameters

  • S

    Materialized IView state of type S

  • E

    Events of type E that are handled by this Materialized View

  • EV

    Version of the event

  • SV

    Version of the state


Implemented by


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

Type declaration

    • (s, e): S
    • Parameters

      • s: S
      • e: E

      Returns S

fetchState: ((e) => Promise<readonly [null | S, null | SV]>)

Type declaration

    • (e): Promise<readonly [null | S, null | SV]>
    • Fetch state


      • e: E

        Event of type E

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

      current state of type [S , SV]

handle: ((eventAndVersion) => Promise<readonly [S, SV]>)

Type declaration

    • (eventAndVersion): Promise<readonly [S, SV]>
    • Handles the event of type E, and returns new persisted state of type S


      • eventAndVersion: readonly [E, EV]

        Event and Version of type [E, EV] to be handled

      Returns Promise<readonly [S, SV]>

      State of type [S, V]

initialState: S
save: ((s, eventVersion, currentStateVersion) => Promise<readonly [S, SV]>)

Type declaration

    • (s, eventVersion, currentStateVersion): Promise<readonly [S, SV]>
    • Save state


      • s: S

        State of type S

      • eventVersion: EV

        Event version of type EV

      • currentStateVersion: null | SV

        State version of type SV | null

      Returns Promise<readonly [S, SV]>

      newly saved State of type [S, V]

Generated using TypeDoc